dfunc
library
Classes
Either <L , R >
Represents a value that can be either of type L
or of type R
.
Usually L
is assumed to be of Error type and R
of Right type, e.g.:
Eithers
Left <L , R >
Right <L , R >
Extensions
Also
on T
AlsoAsync
on Future <T >
Compact
on Iterable <T? >
Compose
on Func1 <B , C >
Curry
on Func2 <A , B , C >
DoEither
on Either <L , R >
EitherAsync
on Either <L , R >
EitherFutureExtension
on Either <FutureOr <L > , FutureOr <R > >
FutureEitherExtension
on AsyncEither <L , R >
FutureToEitherExt
on Future <T >
GroupBy
on Iterable <V >
Intersperse
on Iterable <A >
IterableResultExt
on Iterable <Result <T > >
Let
on T
LetAsync
on Future <T >
MapBy
on Iterable <V >
MapFoldStreamEither
on Stream <Either <L , R > >
MapIndexed
on Iterable <E >
Maybe
on A?
MaybeFirstWhere
on Iterable <T >
NullableStringExt
on String ?
Partial
on Func2 <A , B , C >
Pipe
on Func1 <A , B >
SameEitherExtension
on FutureOr <Either <T , T > >
StringExt
on String
Uncurry
on Func1 <A , Func1 <B , C > >
Zip
on Iterable <A >
Functions
always <T > (T value )
→ T Function([dynamic _ ])
Returns a function that always returns the given value.
castOrElse <T > (dynamic t , T orElse () )
→ T
Safely casts t
to type T
.
castOrNull <T > (dynamic t )
→ T?
Safely casts t
to type T
.
catches <A extends Object > (Func0 <A? > a )
→ A?
Catches all exceptions and returns null in case of an exception.
compact <T > (Iterable <T? > items )
→ Iterable <T >
Filters out all null
values from Iterable .
complement <A > (Predicate <A > f )
→ Predicate <A >
Takes a function f
and returns a function g
such that if called with
the same argument when f
returns true
, g returns false
and when
f
returns a false
g
returns true
.
curry <A , B , C > (Func2 <A , B , C > f )
→ Func1 <A , Func1 <B , C > >
F ([dynamic _ ])
→ bool
A function that always returns false
. Any passed in parameter is ignored.
groupBy <K , V > (Func1 <V , K > getKey , Iterable <V > items )
→ Map <K , List <V > >
Splits an iterable into sub-lists stored in a map, based on result of
calling getKey
function on each element of items
, and grouping the
results according to values returned.
identity <T > (T value )
→ T
A function that returns the parameter supplied to it.
Can be used e.g. as a placeholder function.
ignore ([dynamic _ ])
→ void
Ignores passed argument.
isEmpty (String ? s )
→ bool
Returns true
if passed string is null or empty;
left <L , R > (L value )
→ Either <L , R >
Sortcut for Either.left .
lift <A extends Object , B extends Object > (Func1 <B , A? > f )
→ Func1 <B? , A? >
Transforms function f
taking non-nullable argument into a function
taking nullable argument.
limit (int maxLength )
→ String Function(String ? )
Returns functions that limits passed string to the maxLength
number of characters.
map <T , S > (S f (T ) )
→ Mapper <T , S >
Creates a mapper, i.e. a function that takes a list of S
and maps it
into a list of T
.
map2 <A extends Object , B extends Object , C extends Object > (A? a , B? b , Func2 <A , B , C? > f )
→ C?
Combines to nullable values a
and b
using a binary function f
.
If either nullable value is null, the result is null.
mapBy <K , V > (Func1 <V , K > getKey , Iterable <V > items )
→ Map <K , V >
Creates map from items
. Keys of the map are created by
applying getKey
function to the corresponding item of the list.
mapIndexed <T , E > (Func2 <int , E , T > f , Iterable <E > items )
→ Iterable <T >
Returns a new Iterable with elements that are created by
calling f
on each element of items
in iteration order and
provides position of the element as a first argument of f
.
partial1 <A , B , C > (A a , Func2 <A , B , C > f )
→ Func1 <B , C >
pipe2 <S , T , U > (Func1 <S , T > f1 , Func1 <T , U > f2 )
→ Func1 <S , U >
Performs left-to-right function composition.
pipe3 <S , T , U , V > (Func1 <S , T > f1 , Func1 <T , U > f2 , Func1 <U , V > f3 )
→ Func1 <S , V >
Performs left-to-right function composition.
right <L , R > (R value )
→ Either <L , R >
Shortcut for Either.right .
sequence <A extends Object > (List <A? > xs )
→ List <A > ?
Combines a list of nullable values into one nullable list with non-nullable
values. If any of the values is null, the result is null.
substring (String ? str , int startIndex , [int ? endIndex ])
→ String
Safely returns the substring of this string that extends from startIndex
,
inclusive, to endIndex
, exclusive.
sum <T extends num > (Iterable <T > items )
→ T
Returns sum of all elements in Iterable
.
Returns 0 if iterable is empty.
T ([dynamic _ ])
→ bool
A function that always returns true
. Any passed in parameter is ignored.
traverse <A extends Object , B extends Object > (List <A? > xa , Func1 <A , B? > f )
→ List <B > ?
Maps over the list and applies f
to each non-null element.
Returns the list of non-null values if all elements and results of
applying f
are not null, otherwise returns null.
tryEither <T > (T block (BindEither bind ) )
→ Result <T >
tryEitherAsync <T > (FutureOr <T > block (BindEither bind ) )
→ AsyncResult <T >
uncurry <A , B , C > (Func1 <A , Func1 <B , C > > f )
→ Func2 <A , B , C >
zip2 <A , B > (Iterable <A > a , Iterable <B > b )
→ Iterable <(A , B ) >
Creates an iterable of Product2<A, B>
by pairing up equally positioned
items from both iterables a
and b
. The returned iterable is truncated to
the length of the shorter of the two iterables.
Typedefs
AsyncEither <L , R >
= Future <Either <L , R > >
AsyncResult <T >
= Future <Result <T > >
BindEither
= T Function<T >(Result <T > )
Func0 <A >
= A Function()
Func1 <A , B >
= B Function(A )
Func2 <A , B , C >
= C Function(A , B )
Mapper <T , S >
= Iterable <S > Function(Iterable <T > )
Predicate <A >
= bool Function(A )
Result <T >
= Either <Exception , T >
SeparatorBuilder <A , B >
= B Function(A prev , A next )
Signature for the separator builder in intersperseWith
method.
Transformer <A , B >
= B Function(A )
Function that transforms object of type A
into object of type B
.