Last updated:
0 purchases
safe cast
DIG Dart Safe Cast #
Simple syntax
Reduces boillerplate
Usage #
import 'package:safe_cast/safe_cast.dart';
⋮
Fruit? fruit = Cast.asNullable<Fruit>(maybeFruit);
// or, if you need a fruit
Fruit fruit = SafeCast.as<Fruit>(maybeFruit, ifNull: () => availableFruit());
copied to clipboard
How effective it is #
It is better for chained operations..
CuttedFruit? cutted = maybeFruit is Fruit ? maybeFruit.cut(fruitCutter) : null;
// intead of
CuttedFruit? cutted = Cast.asNullable<Fruit>(maybeFruit)?.cut(fruitCutter);
copied to clipboard
License #
GNU Lesser General Public License version 3 (LGPL-3.0)
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.