dartool library

Classes

AsyncMemoizer<T>
A one-shot async computation that caches its future value. All callers receive the same Future the function is called at most once, no matter how many times call is invoked concurrently.
Base64Util
BenchmarkStats
Min / max / average timings produced by PerfUtil.benchmark.
BiMap<K, V>
Bidirectional map every value has a unique key too.
CollectionUtil
Collection (List / Set / Iterable) utilities.
ColorUtil
Color conversion utilities: hex <-> RGB <-> ARGB, palette helpers.
ConvertUtil
Safe type-conversion utilities with graceful fallbacks never throws.
CryptoUtil
Cryptographic utilities: Base64 / Hex encoding, MD5 / SHA hashing, HMAC and simple XOR obfuscation.
CsvUtil
Minimal RFC 4180 CSV parser / encoder.
DateUtil
Utilities for parsing / formatting dates with zero third-party dependencies. Supports yyyy MM dd HH mm ss SSS tokens.
Debouncer
Debounce a function: only the last call within duration fires.
EnumUtil
Enum utilities.
EventBus
Tiny synchronous event bus pub/sub with strong typing.
ExceptionUtil
Safe error / exception inspection helpers. Designed so you can feed literally Object? (as you get from catch blocks) and always get a readable string without crashing.
ExpiringMemoizer<T>
Like AsyncMemoizer but the cached value expires after ttl. Once the TTL has elapsed the next call triggers a fresh invocation.
HexUtil
IdUtil
ID generation utilities: UUID v4, short random IDs and Snowflake IDs, all with zero third-party dependencies.
IoUtil
Web stub for the file I/O utilities.
JsonUtil
JSON encode / decode utilities with safe fallbacks and pretty printing.
LazyFuture<T>
Kicks off an async computation in the background and returns a "lazy" Future that only starts when first awaited. This is a thin wrapper that makes Future-returning closures composable.
ListUtil
List-specific helpers. For general Iterable and Map helpers see CollectionUtil and MapUtil.
LogUtil
LruCache<K, V>
Simple in-memory LRU cache with optional time-to-live.
MapUtil
Map utilities higher-level helpers than the core library provides.
Money
Money helpers fixed-precision arithmetic that avoids double rounding.
Mutex
Dart async primitives Semaphore and Mutex.
NumExt
Private re-export from NumUtil to avoid a cross-extension file.
NumUtil
Number utilities clamp, rounding, formatting, safe parsing.
Optional<T>
Null-safe value container, similar to Java's Optional.
PathUtil
PerfUtil
PlatformUtil
RandomUtil
Random value generators strings, ints, doubles, UUID-style IDs, weighted pickers, shuffles, etc.
RateLimiter
Token-bucket rate limiter smooths bursts while enforcing an average rate.
RegexUtil
Common pre-built regex patterns (email, phone, URL, ID card, IP, etc.) plus match / extraction helpers.
Result<T>
Result container that wraps "value + error" into explicit success / failure semantics. Prevents using exceptions for expected failure branches.
RetryUtil
Semaphore
SetUtil
Set algebra helpers ?union / intersection / difference / symmetric difference ?plus a few convenient constructors that preserve order via LinkedHashSet.
SnowflakeIdGenerator
Snowflake ID generator.
StrUtil
String utilities.
Throttler
Throttle a function: at most one call per duration window.
TimerUtil
UrlUtil
URL encoding / decoding and query-string helpers.
ValidateUtil
Data validation utilities: null / blank checks, email / phone / URL / ID card format checks, range / length checks, and mandatory require assertions.

Extensions

DartoolDateTime on DateTime
Extension APIs mirroring DateUtil.
DartoolDuration on Duration
Compact duration formatting helpers.
DartoolInt on int
DartoolIterable on Iterable<T>
Extension APIs mirroring CollectionUtil for Iterable.
DartoolList on List<T>
List-only helpers (chunk / windowed).
DartoolMap on Map<K, V>
Map helpers that complement the static MapUtil-style API.
DartoolNullableIterable on Iterable<T?>
DartoolNullableString on String?
Null-aware convenience on nullable strings.
DartoolNum on num
Extension APIs mirroring NumUtil.
DartoolNumIterable on Iterable<T>
Iterable of num helpers.
DartoolString on String
Extension APIs mirroring StrUtil.
ListX on List<T>

Functions

debounce(Duration duration, void fn()) → Timer
One-shot convenience function: run fn after duration elapses.
throttle(Duration duration, void fn()) → bool
Leading-edge throttle: execute fn immediately and return true at most once per duration window for the same callback instance; calls inside the window are swallowed and return false.
waitFailFast<T>(Iterable<Future<T>> futures) → Future<List<T>>
Like Future.wait but short-circuits as soon as any future fails cancels the rest and propagates the error.
withTimeout<T>(Future<T> fn(), Duration timeout, {T? onTimeout()?}) → Future<T?>
Run fn and return its Future. If it completes before timeout elapses the result is returned; otherwise onTimeout is called (defaults to returning null) and the original Future is dropped (still runs in the background).

Typedefs

LogFormatter = String Function(LogLevel level, String tag, String message, Object? error, StackTrace? st)