Helpers class

General utility helpers

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 Methods

chunk<T>(List<T> list, int size) List<List<T>>
Chunks a list into smaller lists of specified size
clamp<T extends Comparable<T>>(T value, T min, T max) → T
Clamps a value between min and max
delay(Duration duration) Future<void>
Delays execution by the specified duration
delayMs(int milliseconds) Future<void>
Delays execution by milliseconds
equals<T>(T? a, T? b) bool
Checks if two values are equal (handles null)
ifNotNull<T>(T? value, void action(T)) → void
Executes a function if value is not null
ifTrue<T>(bool condition, T value()) → T?
Returns a value if condition is true, otherwise returns null
invertMap<K, V>(Map<K, V> map) Map<V, K>
Inverts a map (swaps keys and values)
isBlank(String? value) bool
Checks if a string is blank (empty or only whitespace)
isNotBlank(String? value) bool
Checks if a string is not blank
orElse<T>(T? value, T defaultValue) → T
Returns the value if not null, otherwise returns default
parallel<T>(List<Future<T>> futures) Future<List<T>>
Executes multiple futures in parallel and returns results
randomDouble(double min, double max) double
Generates a random double between min and max
randomInt(int min, int max) int
Generates a random integer between min and max (inclusive)
randomString(int length, {String chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'}) String
Generates a random string of specified length
retry<T>(Future<T> action(), {int maxAttempts = 3, Duration delay = const Duration(seconds: 1), bool onError(Object)?}) Future<T>
Retries a function with exponential backoff
safeCast<T>(dynamic value) → T?
Safely casts a value to a type, returns null if cast fails
sequential<T>(List<Future<T> Function()> futures) Future<List<T>>
Executes futures sequentially
shuffle<T>(List<T> list) List<T>
Shuffles a list and returns a new list
uuid() String
Generates a random UUID-like string