control_flow library
Adding control flow methods for writing more readable code.
Classes
-
On<
T>
Extensions
- Also on T
- also can be used for performing actions that need the current value as an argument. It returns the current value.
- ElseIf on T?
- Let on T
- let can be used to invoke one or more functions on results of call chains.
- OrElse on T?
- TakeIf on T?
-
takeIf returns the current value if the given block is satisifed, will
return
null
if not. - TakeUnless on T?
-
takeUnless returns the current value if the given block is not satisifed,
will return
null
if it is.
Functions
-
iff<
T> (bool statement, T branch()) → T? - The iff method can be used as a normal if statement, or as an expression, i.e. it returns a value.
-
isIn<
T> (Iterable< T> list) → _WhenCheck - Allows for checking if a when value is in a list.
-
isNotIn<
T> (Iterable< T> list) → _WhenCheck - Allows for checking if a when value is not in a list.
-
isNotType<
V> () → _WhenCheck - Allows for checking if a when value is not of a certain type.
-
isType<
V> () → _WhenCheck - Allows for checking if a when value is of a certain type.
-
tryy<
T> (T branch(), {List< On> catches = const []}) → T? - The tryy method can be used as a normal try-catch block, or as an expression, i.e. it returns a value.
-
when<
T, V> (T value, Map< T, V Function()> branches) → V? - when defines a conditional expression with multiple branches.