mz_core 1.3.2
mz_core: ^1.3.2 copied to clipboard
Flutter utilities for state management, logging, collections, and rate limiting with auto-disposal and extensions.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.3.2 - 2026-02-06 #
Fixed in 1.3.2 #
- Fix
LogFormatter.detectTerminalWidth()andLogFormatter.detectColorSupport()to catchUnsupportedErroron web platforms by usingon Object catchinstead ofon Exception catch
1.3.1 - 2026-02-05 #
Fixed in 1.3.1 #
- Export
event_manager.dartwhich was missing from the public API
1.3.0 - 2026-01-14 #
Added in 1.3.0 #
EventManager - High-Performance Event Queue System
A comprehensive event queue system for Flutter applications that combines features typically requiring 5-6 separate packages into a unified solution.
Core Features:
EventManager<T>- type-safe event queue with configurable execution modesEvent<T>- base class for defining events with optional timeout, retry, and progress supportUndoableEvent<T>- events with automatic undo/redo capabilityBatchEvent<T>- process multiple events as a single unit
Execution Modes:
ExecutionMode.sequential- process events one at a time (default)ExecutionMode.concurrent(maxConcurrency)- parallel processing with concurrency limitExecutionMode.rateLimited(limit, window)- rate-limited processing
Event Lifecycle:
EventPending→EventRunning→EventComplete/EventError/EventCancel- Automatic retry with configurable backoff strategies (exponential, linear, constant)
- Token-based cancellation for groups of related events
- Real-time progress reporting during execution
Backpressure Control:
- Configurable
maxQueueSizeto prevent memory issues OverflowPolicy.dropNewest- reject new events when queue is fullOverflowPolicy.dropOldest- remove oldest events to make roomOverflowPolicy.error- throw exception when queue is full
Undo/Redo Support:
- Full undo/redo stack with
undo()andredo()methods - Event merging for combining related operations
canUndoandcanRedogetters for UI state
Logging Integration:
- Built-in
EventLoggerwith colored output - Configurable log levels (none, error, warning, info, debug)
- Full event lifecycle logging for debugging
Example:
final manager = EventManager<String>();
// Define an event
class FetchUserEvent extends Event<String> {
final String userId;
FetchUserEvent(this.userId);
@override
Future<String> execute(EventContext context) async {
final user = await api.fetchUser(userId);
return user.name;
}
}
// Listen to events
manager.stream.listen((state) {
switch (state) {
case EventComplete(:final data): print('Got: $data');
case EventError(:final error): print('Error: $error');
case EventCancel(:final reason): print('Cancelled: $reason');
}
});
// Add events
manager.add(FetchUserEvent('123'));
1.2.0 - 2026-01-09 #
Added in 1.2.0 #
Memoization Utilities
Memoizerstatic class for tag-based caching of async results (consistent withDebouncerAPI)Memoizer.run(tag, computation)- cache async results by tagMemoizer.getValue(tag)/hasValue(tag)/isPending(tag)- check cache stateMemoizer.clear(tag)/clearAll()- invalidate cache- TTL (time-to-live) support for automatic cache expiration
- In-flight request deduplication using
Completer(concurrent calls share the same computation) forceRefreshparameter to bypass cache- Dynamic tags for key-based caching:
Memoizer.run('product-$id', ...)
Debouncer Async API
Debouncer.debounceAsync<S, T>()for typed async debouncing with return valuesDebouncer.fireAsync<S, T>()for immediate execution of async debounced functions- Merged functionality from AdvanceDebouncer into Debouncer
Controller Lookup Enhancements
listenparameter added toController.ofType()andController.maybeOfType()listen: true(default) - widget rebuilds when controller is replacedlisten: false- use in callbacks (onPressed,onTap) to avoid unnecessary rebuilds- Follows the same pattern as
Provider.of(context, listen: false)
Removed in 1.2.0 #
- AdvanceDebouncer class removed - use
Debouncer.debounceAsync()instead batch()method removed from Controller - batch updates feature removed
Changed in 1.2.0 #
Debouncer.cancel(),cancelAll(),count(),isActive()now handle both sync and async operations- Renamed
simple_logger.darttologger.dartfor better naming consistency - Renamed
controller_watcher.darttowatcher.dartfor brevity
1.1.0 - 2026-01-06 #
Added #
Controller Extensions
derive()method onControllerfor creating derivedValueControllerinstances- Automatically updates when source controller changes
distinctparameter to control notification behavior (default: true)autoDisposeparameter for automatic cleanup when listeners are removed (default: true)- Safe to use with
ValueListenableBuilder- auto-cleans up on widget unmount
ListenableNum Improvements
ListenableNumclass for observable numeric values with arithmetic operations- Arithmetic operators (
+,-,*,/,~/,%, unary-) now return the computed valueTfor easier chaining
Changed #
Controller Extension Renaming
- Renamed
ControllerWatchSimpleExtensiontoControllerMZXfor consistency - Improved documentation for
watch(),select(), andderive()methods with{@tool snippet}directives
Listenables
- Renamed
listenable_iterables.darttolistenables.dartfor better naming - Enhanced
ValueControllerdocumentation with Flutter SDK standard patterns
1.0.0 - 2026-01-06 #
Changed in 1.0.0 #
BREAKING CHANGE: Renamed EasyDebounce to Debouncer
EasyDebounceclass renamed toDebouncerfor better naming consistency withAdvanceDebouncerandThrottlerEasyDebouncerCallbacktypedef renamed toDebouncerCallback- All documentation and examples updated to use new naming
Migration Guide
Replace all occurrences of EasyDebounce with Debouncer in your code:
// Before (v0.0.1)
EasyDebounce.debounce('tag', duration, callback);
EasyDebounce.cancel('tag');
EasyDebounce.cancelAll();
// After (v1.0.0)
Debouncer.debounce('tag', duration, callback);
Debouncer.cancel('tag');
Debouncer.cancelAll();
0.0.1 - 2025-01-05 #
Added in 0.0.1 #
State Management
Controllermixin for type-safe state management with automatic lifecycle handlingControllerBuilderwidget for reactive UI updatesControllerProviderwidget for dependency injection.watch()extension onControllerfor simplified widget rebuilds- Key-based selective notifications for granular UI updates
- Priority listeners for ordered notification execution
- Predicate-based filtering for conditional notifications
Auto-Disposal
AutoDisposemixin for automatic resource cleanup- LIFO (last-in-first-out) cleanup order
- Support for Stream, Timer, and custom resource disposal
Observable Collections
ListenableList<T>- observable list with fullListAPIListenableSet<T>- observable set with fullSetAPI- Automatic listener notification on collection modifications
- Direct replacement for standard Dart collections
Structured Logging
SimpleLoggerwith six severity levels (trace, debug, info, warning, error, fatal)- Log groups for organizing related entries
- Multiple output formats: Console, File, JSON, Rotating files
- Customizable log formatting with color support
- Sampling and filtering capabilities
- Minimum level controls for production filtering
Rate Limiting
Debouncerfor simple debouncing (search-as-you-type)Throttlerfor limiting execution frequency (scroll events, button presses)AdvanceDebouncerfor type-safe async debouncing with cancellation- Configurable durations and immediate execution options
Extension Methods
IterableMZX:toMap(),toIndexedMap(),firstWhereWithIndexOrNull(), and moreListMZX:removeFirstWhere(),removeLastWhere(),swap()SetMZX:toggle(),replaceAll()StringMZX:toCapitalizedWords(),toCamelCase(),toSnakeCase(),isValidEmail()IntMZX:isEven,isOdd,isBetween()NumMZX:clampToInt(),roundToPlaces()WidgetMZX:padding(),center(),expanded(),visible()
Documentation
- Comprehensive README with quick start guide
- Getting Started guide with step-by-step integration
- Core Concepts documentation explaining architecture
- Troubleshooting guide for common issues
- Full API documentation with examples
- Contributing guidelines
Example App
- Interactive demos for all features
- State management examples with multiple controllers
- Logging system with multiple output formats
- Rate limiting demonstrations
- Observable collections examples
- Extension method showcases
Infrastructure #
- 100% test coverage with unit and widget tests
- Very Good Analysis lint rules compliance
- BSD-3-Clause License
- GitHub repository and issue tracker
- pub.dev integration