screwdriver
library
Classes
BoolList
A space-efficient list of boolean values.
CanonicalizedMap <C , K , V >
A map whose keys are converted to canonical values of type C
.
CaseInsensitiveEquality
String equality that's insensitive to differences in ASCII case.
CombinedIterableView <T >
A view of several iterables combined sequentially into a single iterable.
CombinedListView <T >
A view of several lists combined into a single list.
CombinedMapView <K , V >
Returns a new map that represents maps flattened into a single map.
DeBouncer
de-bounces run method calls and runs it only once in given duration .
It will ignore any calls to run until duration has passed since the
last call to run .
It can be used to de-bounce any method calls like search, filter, etc.
DeepCollectionEquality
Deep equality on collections.
DefaultEquality <E >
Equality of objects that compares only the natural equality of the objects.
DelegatingIterable <E >
An Iterable that delegates all operations to a base iterable.
DelegatingList <E >
A List that delegates all operations to a base list.
DelegatingMap <K , V >
A Map that delegates all operations to a base map.
DelegatingQueue <E >
A Queue that delegates all operations to a base queue.
DelegatingSet <E >
A Set that delegates all operations to a base set.
Equality <E >
A generic equality relation on objects.
EqualityBy <E , F >
Equality of objects based on derived values.
EqualityMap <K , V >
A Map whose key equality is determined by an Equality object.
EqualitySet <E >
A Set whose key equality is determined by an Equality object.
HeapPriorityQueue <E >
Heap based priority queue.
IdentityEquality <E >
Equality of objects that compares only the identity of the objects.
IntRange
A progression of values of type int .
An iterable that can iterate between start and end value with step size
of step .
IntRangeIterator
An iterator over a progression of values of type int .
Iterable that gives items between start and end with step size step .
It iterates through given range with step size step .
Default value of step is 1.
This implementation is end inclusive, meaning that the end value is also
a part of the range.
For Example,
IntRangeIterator(1, 5) would give elements 1,2,3,4,5
IntRangeIterator(1, 10, step: 2) would give elements 1,3.5.7.9
IterableEquality <E >
Equality on iterables.
IterableZip <T >
Iterable that iterates over lists of values from other iterables.
ListEquality <E >
Equality on lists.
ListSlice <E >
A list view of a range of another list.
MapEquality <K , V >
Equality on maps.
MapKeySet <E >
An unmodifiable Set view of the keys of a Map .
MapValueSet <K , V >
Creates a modifiable Set view of the values of a Map .
MultiEquality <E >
Combines several equalities into a single equality.
NonGrowableListMixin <E >
Mixin class that implements a throwing version of all list operations that
change the List's length.
NonGrowableListView <E >
A fixed-length list.
PriorityQueue <E >
A priority queue is a priority based work-list of elements.
QueueList <E >
A class that efficiently implements both Queue and List .
SetEquality <E >
Equality of sets.
UnionSet <E >
A single set that provides a view of the union over a set of sets.
UnionSetController <E >
A controller that exposes a view of the union of a collection of sets.
UnmodifiableListView <E >
An unmodifiable List view of another List.
UnmodifiableMapMixin <K , V >
Mixin class that implements a throwing version of all map operations that
change the Map.
UnmodifiableMapView <K , V >
View of a Map that disallow modifying the map.
UnmodifiableSetMixin <E >
Mixin class that implements a throwing version of all set operations that
change the Set.
UnmodifiableSetView <E >
An unmodifiable set.
UnorderedIterableEquality <E >
Equality of the elements of two iterables without considering order.
Extension Types
Degrees
Represents an angle in degrees.
This extension type is zero-cost wrapper for double value representing
an angle in degrees making the code more readable and safe.
Radians
Represents an angle in radians.
This extension type is zero-cost wrapper for double value representing
an angle in radians making the code more readable and safe.
Turns
Represents an angle in turns.
This extension type is zero-cost wrapper for double value representing
an angle in turns making the code more readable and safe.
Constants
MAX_INT_VALUE
→ const int
Maximum value that an 64bit int can store. This is different from when
dart is compiled to JS becauseJS can only represent 2^53 as max int value.
MIN_INT_VALUE
→ const int
Minimum value that an 64bit int can store. This is different from when
dart is compiled to JS because JS can only represent -2^53 as min int value.
Properties
debouncer
→ DeBouncer
global instance of DeBouncer to be used for debouncing actions. It can be
used to debounce actions across the application. Use debounce function to
debounce actions using this instance.
final
today
→ DateTime
Returns current date without time information.
no setter
tomorrow
→ DateTime
Returns tomorrow's date without time information.
no setter
yesterday
→ DateTime
Returns yesterday's date without time information.
no setter
Functions
binarySearch <E > (List <E > sortedList , E value , {int compare (E , E )? })
→ int
Returns a position of the value
in sortedList
, if it is there.
buildString (void builder (StringBuffer buffer ) )
→ String
Allows to build a string with StringBuffer using builder
.
check (bool value , [String ? message ])
→ void
Throws IllegalStateException if value
is false.
checkLeapYear (int year )
→ bool
checks whether given year is a leap year or not
How to determine whether a year is a leap year
To determine whether a year is a leap year, follow these steps:
checkNotNull <T > (T argument , [String ? message ])
→ T
Throws IllegalStateException if argument
is null
.
If name
is supplied, it is used as the parameter name
in the error message.
Returns the argument
if it is not null.
compareAsciiLowerCase (String a , String b )
→ int
Compares a
and b
lexically, converting ASCII letters to lower case.
compareAsciiLowerCaseNatural (String a , String b )
→ int
Compares strings a
and b
according to lower-case
natural sort ordering .
compareAsciiUpperCase (String a , String b )
→ int
Compares a
and b
lexically, converting ASCII letters to upper case.
compareAsciiUpperCaseNatural (String a , String b )
→ int
Compares strings a
and b
according to upper-case
natural sort ordering .
compareNatural (String a , String b )
→ int
Compares strings a
and b
according to natural sort ordering .
complete <T > (void action (Completer <T > completer ) )
→ Future <T >
Waits for the given action
to complete and returns the result.
This is useful when an async operation doesn't support async/await and
you have to use a callback-based approach that requires you to utilize
a completer. This function helps you to avoid writing boilerplate code
for creating a completer and returning its future.
debounce <R > (DeBounceAction <R > action , {bool immediateFirstRun = false })
→ Future <R >
Helper function to debounce action
calls using global deBouncer
instance.
If immediateFirstRun
is set to true, it will run the action
immediately
for the first call and then it will wait for duration
to run the next call
if there's any.
equalsIgnoreAsciiCase (String a , String b )
→ bool
Checks if strings a
and b
differ only on the case of ASCII letters.
groupBy <S , T > (Iterable <S > values , T key (S ) )
→ Map <T , List <S > >
Groups the elements in values
by the value returned by key
.
hashIgnoreAsciiCase (String string )
→ int
Hash code for a string which is compatible with equalsIgnoreAsciiCase .
insertionSort <E > (List <E > elements , {int compare (E , E )?, int start = 0 , int ? end })
→ void
Sort a list between start
(inclusive) and end
(exclusive) using
insertion sort.
lastBy <S , T > (Iterable <S > values , T key (S ) )
→ Map <T , S >
Associates the elements in values
by the value returned by key
.
lowerBound <E > (List <E > sortedList , E value , {int compare (E , E )? })
→ int
Returns the first position in sortedList
that does not compare less than
value
.
mapMap <K1 , V1 , K2 , V2 > (Map <K1 , V1 > map , {K2 key (K1 , V1 )?, V2 value (K1 , V1 )? })
→ Map <K2 , V2 >
Creates a new map from map
with new keys and values.
maxBy <S , T > (Iterable <S > values , T orderBy (S ), {int compare (T , T )? })
→ S?
Returns the element of values
for which orderBy
returns the maximum
value.
mergeMaps <K , V > (Map <K , V > map1 , Map <K , V > map2 , {V value (V , V )? })
→ Map <K , V >
Returns a new map with all key/value pairs in both map1
and map2
.
mergeSort <E > (List <E > elements , {int start = 0 , int ? end , int compare (E , E )? })
→ void
Sorts a list between start
(inclusive) and end
(exclusive) using the
merge sort algorithm.
minBy <S , T > (Iterable <S > values , T orderBy (S ), {int compare (T , T )? })
→ S?
Returns the element of values
for which orderBy
returns the minimum
value.
now ()
→ DateTime
shot for DateTime.now
post <T > (FutureOr <T > action () )
→ Future <T >
Runs given action
no sooner than in the next event-loop iteration,
after all micro-tasks have run.
postDelayed <T > (int millis , FutureOr <T > action () )
→ Future <T >
Runs given action
after a delay of millis
, no sooner than in the
next event-loop iteration, after all micro-tasks have run.
randomBool ()
→ bool
Generates a random boolean value.
randomDouble ({double ? max })
→ double
Generates a non-negative random floating point value uniformly distributed
in the range from 0.0, inclusive, to 1.0, exclusive.
randomInt ({int ? max , int ? seed })
→ int
Generates a non-negative random integer uniformly distributed in the range
rom 0, inclusive, to max
, exclusive.
default max
is a max int value allowed by Random .
randomString (int length , {bool alphabets = true , bool digits = true , bool specialChars = false , int ? seed , String ? pool })
→ String
Generates a random string of given length
.
alphabets
decides whether to include alphabets or not.
digits
decides whether to include digits or not.
specialChars
decides whether to include special characters or not.
require (bool value , [String ? message ])
→ void
Throws IllegalArgumentException if value
is false.
If message
is supplied, it is used as the error message.
requireNotNull <T > (T argument , [String ? message ])
→ T
Throws IllegalArgumentException if argument
is null
.
If message
is supplied, it is used as the error message.
Returns the argument
if it is not null.
reverse <E > (List <E > elements , [int start = 0 , int ? end ])
→ void
Reverses a list, or a part of a list, in-place.
runCaching <T > (FutureOr <T? > action (), {FutureOr <T? > onError (dynamic error , StackTrace stacktrace )? })
→ FutureOr <T? >
Executes a provided action and handles potential errors.
shuffle (List elements , [int start = 0 , int ? end , Random ? random ])
→ void
Shuffles a list randomly.
stronglyConnectedComponents <T > (Map <T , Iterable <T > > graph )
→ List <Set <T > >
Returns the strongly connected components of graph
, in topological
order.
TODO ([String ? reason ])
→ void
Always throws UnimplementedError stating that operation is
not implemented.
transitiveClosure <T > (Map <T , Iterable <T > > graph )
→ Map <T , Set <T > >
Returns the transitive closure of graph
.
tryJsonDecode (String value , {Object ? reviver (Object ? key , Object ? value )? })
→ dynamic
A safe json decode function that uses jsonDecode and returns null if
decoding fails.
Exceptions / Errors
IllegalArgumentException
Thrown to indicate that a method has been passed an illegal or
inappropriate argument.
IllegalStateException
Signals that a method has been invoked at an illegal or
inappropriate time.