Utils class

General-purpose helpers shared by extension methods and package consumers.

Constructors

Utils()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

today DateTime
Current date (same as DateTime.now()).
no setter
tomorrow DateTime
Tomorrow at same hour / minute / second than now
no setter
yesterday DateTime
Yesterday at same hour / minute / second than now
no setter

Static Methods

areListsEqual(List list1, List list2) bool
Compare two lists for equality.
areMapsEqual(Map map1, Map map2) bool
Compare two maps for equality.
daysInRange(DateTime start, DateTime end) Iterable<DateTime>
Returns a DateTime for each day the given range.
debounce(void action(), {Duration delay = const Duration(milliseconds: 300)}) → void Function()
Debounces repeated calls and runs only the latest action.
deepEquals(dynamic value1, dynamic value2) bool
Deep equality for lists, maps, and primitive values.
deepMerge<K>(Map<K, dynamic> target, Map<K, dynamic> source) Map<K, dynamic>
Deep merges source into target.
fastUUID({String prefix = "", bool withDashes = true}) String
Generate fast uuid with supports for prefix and with dashes or not
futureAll(Iterable<Future> futures, {void onProgress(int, int, Map<int, dynamic>)?, void onAnySuccess(dynamic, int)?, void onAnyError(Object, StackTrace, int)?, int delayMillis = 0}) Future<List>
Waits for all futures and returns results in the original order.
isEmpty(dynamic value) bool
is null or empty for Map, String, Iterable
isToday(DateTime date) bool
Returns true if is today, otherwise false
isTomorrow(DateTime date) bool
Returns true if is tomorrow, otherwise false
isYesterday(int current) bool
Returns true if is yesterday, otherwise false
pickup<T>(dynamic target, String keywordsStr) List<T>
pickup target attributes for Map, List
queryString(Map<String, dynamic> parameters) String
Returns a query string built from parameters.
randomString(int length, {String chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'}) String
Generate a random string.
removeNullValues(dynamic value) → dynamic
Removes null values from maps and lists recursively.
retry<T>(Future<T> action(), {int retries = 3, Duration delay = Duration.zero, bool retryIf(Object error)?}) Future<T>
Retries an async action until it succeeds or retries is exhausted.
throttle(void action(), {Duration duration = const Duration(milliseconds: 300)}) → void Function()
Throttles repeated calls to at most once per duration.
tryJsonDecode(String? value) → dynamic
Returns value when it can be JSON-decoded, otherwise null.
tryJsonEncode(dynamic value) String?
Returns a JSON string, or null when value cannot be encoded.
unique<T>(List<T>? q1, [List<T>? q2]) List<T>
unique for int, String, double List