dartbag 0.4.1+1
dartbag: ^0.4.1+1 copied to clipboard
A grab-bag of miscellaneous, lightweight utility code for Dart.
dartbag #
A grab-bag of miscellaneous, lightweight utility code for Dart. Functionality includes (but is not limited to):
byte_data #
List<int>.asUint8Listconverts aList<int>to aUint8Listwithout copying, if possible.
debug #
-
assertsEnabledreturns whetherassertis enabled. -
currentDartPackagePathreturns the path to the current Dart library for Dart VM builds. -
staticTypereturns the static type of an object.
iterables #
-
List.reversereverses aListin place. -
List.rotateLeftrotates aListin place. -
List.sortWithKeysorts aListby computing and caching sort keys, which can be significantly faster if comparisons are expensive. -
List.sortWithAsyncKey, a version ofsortWithKeythat allows the sort key to be computed asynchronously.
matcher #
toStringMatchesverifies that a tested value has a matching type and string representation.
misc #
-
chainIfallows conditional method chaining based on a condition. -
tryAscasts an object and returnsnullon failure instead of throwing aTypeError. -
OutputParameterallows specifying output parameters from functions as a crude mechanism to return multiple values. -
int.padDigitsconverts anintto aString, left-padded with zeroes to have a minimum number of digits. -
int.multipleOfrounds a non-negative integer to the nearest multiple of another number. -
Uri.updateQueryParametersadds or replaces query parameters in aUri. -
Rectangle.centerreturns the center of aRectangle. -
bool.impliesreturns whether oneboollogically implies another. -
Future.castcasts aFuture<T>to aFuture<R>.
[parse] #
-
tryParseBoolparses aboolfrom aString?. -
tryParseIntandtryParseDoubleare wrappers aroundint.tryParseanddouble.tryParsethat acceptnullarguments. -
List<Enum>.tryParseparses anEnumvalue from aString?.
[random] #
-
randMaxIntreturns the maximum value allowed byRandom.nextIntportably. -
Random.nextIntFromreturns a random integer in a specified range. -
lazyShufflershuffles aListlazily. -
RepeatableRandomwraps an existing pseudo-random number generator and allows a random sequence to be easily restarted and that allows the seed to be retrieved.
[readable_numbers] #
-
readableDurationreturns aDurationas a human-readable string. -
readableNumberreturns a number as a human-readable string with SI prefixes and units.
[timer] #
ExpiringPeriodicTimeris a periodicTimerthat automatically stops after a time limit.
[tty] #
-
getTerminalSizeattempts to get the number of columns and lines of a terminal. -
wordWrapwraps a string to a maximum line length. -
ArgResults.parseOptionValuereduces some boilerplate when parsing option values from [package:args].
[package:args] https://pub.dev/packages/args
[parse]: https://pub.dev/documentation/dartbag/latest/parse/parse-library.html
[random]: https://pub.dev/documentation/dartbag/latest/random/random-library.html
[readable_numbers]: https://pub.dev/documentation/dartbag/latest/readable_numbers/readable_numbers-library.html
[timer]: https://pub.dev/documentation/dartbag/latest/timer/timer-library.html
[tty]: https://pub.dev/documentation/dartbag/latest/tty/tty-library.html