dartbag 0.6.0
dartbag: ^0.6.0 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.
collection #
-
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.sortWithAsyncKeyis a version ofsortWithKeythat allows the sort key to be computed asynchronously. -
compareIterablescompares twoIterables in a manner similar to string comparison. -
LinkedHashMap.sort. -
mergeMapss combines anIterableofMaps into a singleMap.
debug #
-
assertsEnabledreturns whetherassertis enabled. -
currentDartPackagePathreturns the path to the current Dart library for Dart VM builds. -
staticTypereturns the static type of an object.
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>. -
hoursOnly,minutesOnly,secondsOnly,millisecondsOnly, andmicrosecondsOnlyretrieve specific components of aDuration.
parse #
-
tryParseBoolparses aboolfrom aString?. -
tryParseIntandtryParseDoubleare wrappers aroundint.tryParseanddouble.tryParsethat acceptnullarguments. -
List<Enum>.tryParseparses anEnumvalue from aString?. -
tryParseDurationparses aDurationfrom aString?.
random #
-
randMaxIntportably returns the maximum value allowed byRandom.nextInt. -
Random.nextIntFromreturns a random integer in a specified range. -
lazyShufflershuffles aListlazily. -
RepeatableRandomwraps an existing pseudo-random number generator to allow a random sequence to be easily restarted and to allow 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 frompackage:args.