dart_helper_utils library

A library to help with common tasks in Dart.

Classes

Bidi
This provides utility methods for working with bidirectional text. All of the methods are static, and are organized into a class primarily to group them together for documentation and discoverability.
BidiFormatter
Bidi stands for Bi-directional text. According to Wikipedia: Bi-directional text is text containing text in both text directionalities, both right-to-left (RTL) and left-to-right (LTR). It generally involves text containing different types of alphabets, but may also refer to boustrophedon, which is changing text directionality in each row.
BoolOptions
Options that control boolean parsing.
ConversionResult<T>
Represents the outcome of a conversion, capturing either a value or error.
Convert
Backward-compatible static facade that mirrors the original ConvertObject API.
ConvertConfig
A single global instance is used by default. You can:
Converter
Fluent wrapper that offers composable access to conversion helpers.
DateFormat
DateFormat is for formatting and parsing dates in a locale-sensitive manner.
DateOptions
Options that control date/time parsing.
DebouncedCallback
Callable wrapper that exposes debouncing controls.
Debouncer
A versatile debouncer that helps consolidate rapid events by scheduling actions to run after a delay. It features immediate execution, max-wait thresholds, pause/resume support, and reset functionality.
DebouncerState
An immutable snapshot of a debouncer's state.
EnumParsers
Helpers for building resilient enum parsing callbacks.
Intl
The Intl class provides a common entry point for internationalization related tasks. An Intl instance can be created for a particular locale and used to create a date format via anIntl.date(). Static methods on this class are also used in message formatting.
JsonOptions
Options controlling how values are normalized into JSON-safe forms.
NumberFormat
Provides the ability to format a number in a locale-specific way.
NumberOptions
Options that control numeric parsing.
NumbersHelper
A utility class for numerical helper methods.
PausableStream<T>
ThrottledCallback
Callable wrapper that exposes throttling controls.
Throttler
A lightweight throttler for rate-limiting actions over time.
TimeUtils
A utility class that provides helper methods for working with time.
TypeRegistry
Registry of custom parsers used by Convert.toType / Convert.tryToType.
UriOptions
Options that control URI parsing and coercion.

Enums

DateTimeStrategy
Strategy for encoding DateTime values.
DurationStrategy
Strategy for encoding Duration values.
NonFiniteDoubleStrategy
Strategy for non-finite doubles (NaN, Infinity, -Infinity).

Extensions

BoolParsingX on Object?
Adds boolean parsing helpers to dynamic values.
ConvertObjectExtension on Object?
Adds a convert getter that exposes the fluent Converter API.
DateParsingTextX on String
Extension methods for parsing String values into DateTime instances.
DHUArchiveMimeChecksExtensions on String?
DHUArchiveMimeChecksExtensions
DHUAudioMimeChecksExtensions on String?
DHUAudioMimeChecksExtensions
DHUBidiStringExtensions on String
Provides extensions for String to support bidirectional text handling and manipulation.
DHUBidiTDExtensions on TextDirection?
Provides extensions for TextDirection to support bidirectional text formatting.
DHUBoolEx on bool
A set of extensions on the bool type to provide more functionality.
DHUBoolNullableEx on bool?
A set of extensions on the nullable bool type to provide more functionality.
DHUCaseConversionExtensions on String
String case conversion helpers.
DHUCollectionsExtensions on Iterable<E>
Utility extensions for non-nullable iterables.
DHUCollectionsExtensionsNS on Iterable<E>?
Utility extensions for nullable iterables.
DHUContactMimeChecksExtensions on String?
DHUContactMimeChecksExtensions
DHUDateExtensions on DateTime
DHUDateExtensions
DHUDateFormatExtension on DateTime
extension DHUDateFormatExtension on DateTime
DHUDateFormatNStringExtension on String?
extension DHUDateFormatNStringExtension on String?
DHUDocumentMimeChecksExtensions on String?
DHUDocumentMimeChecksExtensions
DHUDoubleExtensions on double
DHUDoubleExtensions
DHUDurationExt on Duration
Extensions for Duration formatting and scheduling helpers.
DHUFontMimeChecksExtensions on String?
DHUFontMimeChecksExtensions
DHUFutureCallbackExtensions on Future<T> Function()
Extensions for Future factories/callbacks.
DHUFutureExtensions on Future<T>
Extensions for Future to add functionality like timeouts and minimum waits.
DHUFutureIterableExtension on Iterable<Future<T> Function()>
Extensions for Iterable of Futures.
DHUHttpEx on num?
DHUHttpEx
DHUImageMimeChecksExtensions on String?
DHUImageMimeChecksExtensions
DHUIntExtensions on int
DHUIntExtensions
DHUIntlExtensions on String
DHUIntlNumExtensions
DHUIntlNumExtensions on num
on
DHUIterableDoubleExtensionsNS on Iterable<double?>?
Extension on nullable Iterable<double?> providing a total sum calculation.
DHUIterableIntExtensionsNS on Iterable<int?>?
Extension on nullable Iterable<int?> providing a total sum calculation.
DHUIterableNumExtensionsNS on Iterable<num?>?
Extension on nullable Iterable<num?> providing a total sum calculation.
DHUListDoubleStats on Iterable<double>
Extension on Iterable<double> providing statistical operations.
DHUListIntStats on Iterable<int>
Extension on Iterable<int> providing statistical operations.
DHUListNumStats on Iterable<num>
Extension on Iterable<num> providing statistical operations.
DHUMapExt on Map<K, V>
DHUMapExt
DHUMapExtension on Map<K, V>
DHUMapExtension
DHUMapNullableExtension on Map<K, V>?
DHUMapNullableExtension
DHUMimeChecksExtensions on String?
DHUMimeChecksExtensions
DHUNDateFormatExtension on DateTime?
extension DHUNDateFormatExtension on DateTime?
DHUNullableDateExtensions on DateTime?
DHUNullableDateExtensions
DHUNullableListExtensions on List<E>?
Enhanced documentation for nullable List extensions.
DHUNullableSetExtensions on Set<E>?
Extension methods for nullable Set collections.
DHUNullSafeCaseConversionExtensions on String?
Nullable String casing helpers.
DHUNullSafeNumExtensions on num?
DHUNullSafeNumExtensions
DHUNullSafeStringExtensions on String?
Extensions for nullable String helpers.
DHUNumberFormatExtensions on num
Extension methods for the num type to format numbers using the intl package.
DHUNumberFormatNullableStringExtensions on String?
This file contains extensions for the NumberFormat class from the intl package.
DHUNumberFormatStringExtensions on String
Extension methods for the String type to format numbers using the intl package.
DHUNumExtensions on num
DHUNumExtensions
DHUObjectNullableExtensions on Object?
Extensions for nullable objects and primitive checks.
DHUProgrammingMimeChecksExtensions on String?
DHUProgrammingMimeChecksExtensions
DHUStringExtensions on String
Extensions for common String helpers.
DHUUriEx on Uri
Extensions for Uri utils and manipulation.
DHUVideoMimeChecksExtensions on String?
DHUVideoMimeChecksExtensions
EnumValuesParsing on List<T>
Convenience accessors for creating enum parsing callbacks from a list.
IntlMapExtension on Map<Object, T>
Provides extensions for Map<Object, T> to support internationalization (i18n) message formatting. IntlMapExtension
IntlMapStringExtension on Map<Object, String>
Provides extensions for Map<Object, String> to support internationalization (i18n) message formatting. IntlMapStringExtension
IterableConversionX on Iterable<E>
Conversion helpers for non-null Iterable collections.
JsonAnyX on Object?
JsonIterableX on Iterable<T>
JsonMapX on Map<K, V>
LetExtension on T
Kotlin-style let helper for non-nullable types.
LetExtensionNullable on T?
Kotlin-style let helpers for nullable types.
MapConversionX on Map<K, V>
Conversion helpers for non-nullable maps.
NullableIterableConversionX on Iterable<E>?
Conversion helpers for nullable Iterable collections.
NullableMapConversionX on Map<K, V>?
Conversion helpers for nullable maps.
NumberToDateUtils on num
NumberToDateUtils
NumParsingTextX on String
Extension methods for parsing numeric strings with lenient formatting.
RomanNumeralIntX on num
Roman numeral helpers for integers.
RomanNumeralNullableStringX on String?
Roman numeral helpers for nullable strings.
RomanNumeralStringX on String
Roman numeral helpers for strings.
SetConvertToX on Set<E>?
Converts nullable sets into a Set of a different type.
StreamControllerSafeExtensions on StreamController<T>
StreamErrorRecovery on Stream<T>
StreamTransformations on Stream<T>
Additional stream transformations not covered by the official Dart RateLimit extension.
TextJsonX on String
Adds JSON decoding helpers to String.
UriParsingX on String
Extension methods for validating and converting URI-like strings.

Constants

cssColorNamesToArgb → const Map<String, int>
A map of CSS color names to their corresponding ARGB values. Usage could be like with Color class: Color(cssColorNamesToArgb['red'])
fullMonthsNames → const Map<int, String>
A map of integers to full month names.
fullWeekdays → const Map<int, String>
A map of integers to full weekday names.
greekNumberSuffixes → const List<String>
A list of Greek number suffixes used for large numbers representation.
millisecondsPerDay → const int
Number of milliseconds in one day.
millisecondsPerHour → const int
Number of milliseconds in one hour.
millisecondsPerMinute → const int
Number of milliseconds in one minute.
millisecondsPerSecond → const int
Milliseconds constants for different time units. Number of milliseconds in one second.
oneDay → const Duration
Duration representing one day.
oneHour → const Duration
Duration representing one hour.
oneMinute → const Duration
Duration representing one minute.
oneSecond → const Duration
Duration representing one second.
regexAlphabet → const String
Matches ASCII letters only.
regexAlphanumeric → const String
Common regex patterns used for validation and parsing. Matches ASCII letters and digits only.
regexComponentSeparator → const String
A regular expression pattern that matches whitespace-flexible comma separators. This pattern is designed to handle the standard format of CSS color functions like rgb(), rgba(), hsl(), etc.
regexContainsDigits → const String
Matches strings containing at least one digit.
regexHasCapitalLetter → const String
Matches uppercase ASCII letters.
regexNumeric → const String
Matches ASCII digits only.
regexSpecialChars → const String
Matches any character that is not ASCII letter, digit, or space.
regexStartsWithNumber → const String
Matches strings that start with a digit.
regexValidCurrency → const String
Matches common currency strings with optional symbols and grouping.
regexValidEmail → const String
Matches email addresses in a typical local@domain format.
regexValidHexColor → const String
Validates hex color strings in various formats (CSS-style or 0x prefixed).
regexValidHslColor → const String
Legacy hsl()/hsla() regex - updated to handle all valid space combinations and Allow zero or more spaces before and after the comma.
regexValidIp4 → const String
Matches IPv4 addresses.
regexValidModernColorFunc → const String
Modern color function regex – it now outright disallows any commas inside the parentheses.
regexValidPhoneNumber → const String
Matches common phone number formats with optional country codes and extensions.
regexValidRgbColor → const String
Legacy rgb()/rgba() regex. (Note that if the function name is exactly "rgb(" then an alpha value is not allowed.)
regexValidUrl → const String
Matches http/https URLs and common URL patterns.
regexValidUsername → const String
Matches usernames starting and ending with an alphanumeric character.
romanNumerals → const Map<int, String>
A map of integers to Roman numeral representations.
smallMonthsNames → const Map<int, String>
A map of integers to abbreviated month names.
smallWeekdays → const Map<int, String>
A map of integers to abbreviated weekday names.
textDirectionLTR → const TextDirection
Left-to-right text direction constant.
textDirectionRTL → const TextDirection
Right-to-left text direction constant.
textDirectionUNKNOWN → const TextDirection
Unknown text direction constant.

Properties

currentMillisecondsSinceEpoch int
Returns the current time in milliseconds since the Unix epoch.
no setter
httpStatusDevMessage Map<int, String>
A map of HTTP status codes to detailed technical messages.
no setter
httpStatusMessages Map<int, String>
A map of HTTP status codes to their corresponding messages.
no setter
httpStatusUserMessage Map<int, String>
A map of HTTP status codes to user-friendly messages.
no setter
now DateTime
Returns the current time.
no setter

Functions

convertToBigInt(dynamic object, {Object? mapKey, int? listIndex, BigInt? defaultValue, BigInt converter(Object?)?}) BigInt
Top-level convenience alias for Convert.toBigInt.
convertToBool(dynamic object, {Object? mapKey, int? listIndex, bool? defaultValue, bool converter(Object?)?}) bool
Top-level convenience alias for Convert.toBool.
convertToDateTime(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, bool autoDetectFormat = false, bool useCurrentLocale = false, bool utc = false, DateTime? defaultValue, DateTime converter(Object?)?}) DateTime
Top-level convenience alias for Convert.toDateTime.
convertToDouble(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, double? defaultValue, double converter(Object?)?}) double
Top-level convenience alias for Convert.toDouble.
convertToInt(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, int? defaultValue, int converter(Object?)?}) int
Top-level convenience alias for Convert.toInt.
convertToList<T>(dynamic object, {Object? mapKey, int? listIndex, List<T>? defaultValue, T elementConverter(Object?)?}) List<T>
Top-level convenience alias for Convert.toList.
convertToMap<K, V>(dynamic object, {Object? mapKey, int? listIndex, Map<K, V>? defaultValue, K keyConverter(Object?)?, V valueConverter(Object?)?}) Map<K, V>
Top-level convenience alias for Convert.toMap.
convertToNum(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, num? defaultValue, num converter(Object?)?}) num
Top-level convenience alias for Convert.toNum.
convertToSet<T>(dynamic object, {Object? mapKey, int? listIndex, Set<T>? defaultValue, T elementConverter(Object?)?}) Set<T>
Top-level convenience alias for Convert.toSet.
convertToString(dynamic object, {Object? mapKey, int? listIndex, String? defaultValue, String converter(Object?)?}) String
Top-level convenience alias for Convert.string.
convertToType<T>(dynamic object) → T
Top-level convenience alias for Convert.toType.
convertToUri(dynamic object, {Object? mapKey, int? listIndex, Uri? defaultValue, Uri converter(Object?)?}) Uri
Top-level convenience alias for Convert.toUri.
intToRomanNumeral(int value) String
Converts an integer into a Roman numeral string.
isEqual(dynamic a, dynamic b) bool
Returns true when a and b are deeply equal.
isTypePrimitive<T>() bool
Returns true when the static type T is a primitive type.
isValuePrimitive(dynamic value) bool
Returns true when value is a primitive value or a collection of primitives.
jsonSafe(dynamic value, {JsonOptions options = const JsonOptions(), Object? toEncodable(dynamic object)?}) → dynamic
Returns a JSON-encodable form of value, honoring options.
randomBool([int? seed]) bool
Returns a random boolean value.
randomDouble([int? seed]) double
Returns a random double in the range 0.0 <= value < 1.0.
randomInRange(num min, num max, [int? seed]) int
Generates a random integer within the specified range.
randomInt(int max, [int? seed]) int
Returns a random integer in the range 0 <= value < max.
romanNumeralToInt(String romanNumeral) int
Converts a Roman numeral string into an integer.
tryConvertToBigInt(dynamic object, {Object? mapKey, int? listIndex, BigInt? defaultValue, BigInt converter(Object?)?}) BigInt?
Top-level convenience alias for Convert.tryToBigInt.
tryConvertToBool(dynamic object, {Object? mapKey, int? listIndex, bool? defaultValue, bool converter(Object?)?}) bool?
Top-level convenience alias for Convert.tryToBool.
tryConvertToDateTime(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, bool autoDetectFormat = false, bool useCurrentLocale = false, bool utc = false, DateTime? defaultValue, DateTime converter(Object?)?}) DateTime?
Top-level convenience alias for Convert.tryToDateTime.
tryConvertToDouble(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, double? defaultValue, double converter(Object?)?}) double?
Top-level convenience alias for Convert.tryToDouble.
tryConvertToInt(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, int? defaultValue, int converter(Object?)?}) int?
Top-level convenience alias for Convert.tryToInt.
tryConvertToList<T>(dynamic object, {Object? mapKey, int? listIndex, List<T>? defaultValue, T elementConverter(Object?)?}) List<T>?
Top-level convenience alias for Convert.tryToList.
tryConvertToMap<K, V>(dynamic object, {Object? mapKey, int? listIndex, Map<K, V>? defaultValue, K keyConverter(Object?)?, V valueConverter(Object?)?}) Map<K, V>?
Top-level convenience alias for Convert.tryToMap.
tryConvertToNum(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, num? defaultValue, num converter(Object?)?}) num?
Top-level convenience alias for Convert.tryToNum.
tryConvertToSet<T>(dynamic object, {Object? mapKey, int? listIndex, Set<T>? defaultValue, T elementConverter(Object?)?}) Set<T>?
Top-level convenience alias for Convert.tryToSet.
tryConvertToString(dynamic object, {Object? mapKey, int? listIndex, String? defaultValue, String converter(Object?)?}) String?
Top-level convenience alias for Convert.tryToString.
tryConvertToType<T>(dynamic object) → T?
Top-level convenience alias for Convert.tryToType.
tryConvertToUri(dynamic object, {Object? mapKey, int? listIndex, Uri? defaultValue, Uri converter(Object?)?}) Uri?
Top-level convenience alias for Convert.tryToUri.

Typedefs

AsyncAction = FutureOr<void> Function()
A function signature for asynchronous actions.
DynamicConverter<T> = T Function(Object? value)
Signature for lazily transforming a stored value before conversion.
ElementConverter<T> = T Function(Object? element)
Signature for transforming a single element while converting collections.
LoggerFunction = void Function(String message)
A function signature for logging messages.
Predicate<T> = bool Function(T)
A type alias representing a predicate function that takes a value of type T and returns a boolean value.
ThrottlerAction = FutureOr<void> Function()
A function signature for throttled actions.
ThrottlerErrorHandler = void Function(Object error, StackTrace stack)
A function signature for throttler error handling.
TimerFactory = Timer Function(Duration duration, void callback())
A function signature for creating timers. timerFactory allows customizing timer creation, useful for testing or specialized timing behavior. Defaults to standard Timer.new.

Exceptions / Errors

ConversionException
Exception thrown when a conversion fails.
RException
Represents a range exception.