Skip to main content

mu_state 3.0.0+1 copy "mu_state: ^3.0.0+1" to clipboard
mu_state: ^3.0.0+1 copied to clipboard

Minimal Cubit-inspired state management using Flutter's built-in primitives. No external dependencies.

3.0.0+1 #

  • README: installation section, 2.x upgrade note, clarified how equality controls notifications, and noted that widgets accept any ValueListenable

3.0.0 #

Breaking Changes #

  • MuProvider ownership is now explicit. The value: constructor is replaced by:
    • MuProvider(create: (context) => ..., dispose: ...): creates the value once (survives parent rebuilds and hot reload) and disposes it on unmount. dispose is optional; by default ChangeNotifiers (every MuLogic) are disposed.
    • MuProvider.value(value: ...): exposes an existing instance and never disposes it.
  • MuMultiProvider takes a named providers: list instead of a positional one.
  • MuMultiProvider and MuMultiListener nesting order: the first entry is now the outermost widget (previously the last). This lets a provider's create read providers listed before it.
  • context.logic / context.maybeLogic no longer register a dependency (like context.read). Use MuProvider.of<T>(context) if you need to rebuild when a MuProvider.value instance changes.
  • Removed lazy from MuListener / MuConsumer (deprecated in 2.0.1). Use fireImmediately.

Improvements #

  • MuComparable.== reads props once per object instead of on every access, avoiding a new list allocation per comparison step
  • Example app: AuthRepository is now provided with create/dispose, and logics read it in their create, so state survives rebuilds and hot reload
  • README: documents create vs .value ownership and MuMultiProvider ordering

Migration from 2.x #

  1. Providers that create their value: MuProvider<T>(value: T(), child: ...) → MuProvider<T>(create: (context) => T(), child: ...)
  2. Providers that pass an existing instance (e.g. to a new route): MuProvider<T>(value: existing, ...) → MuProvider<T>.value(value: existing, ...)
  3. MuMultiProvider([...], child: ...) → MuMultiProvider(providers: [...], child: ...)
  4. If a provider in MuMultiProvider depended on one listed after it, reverse their order.
  5. lazy: false → fireImmediately: true; drop lazy: true.

2.0.1 #

Fixes #

  • MuListener / MuConsumer now resubscribe when the parent passes a different logic instance (previously the old notifier leaked a listener and the new one was never listened to)
  • MuListener / MuConsumer skip the initial listener call if the widget was unmounted before the first frame
  • MuConsumer.buildWhen is now honoured when the widget rebuilds for other reasons (e.g. parent rebuild); builder receives the last accepted state
  • context.read / context.maybeRead no longer register a dependency, so they work in initState and callbacks
  • MuProvider.of error message now names MuProvider<T>
  • MuMultiBuilder no longer re-merges its listenables on every rebuild
  • Docs: replaced non-existent emit(...) with value = ...; fixed copyWith examples that could never clear error

Improvements #

  • Added fireImmediately to MuListener / MuConsumer; lazy is deprecated (lazy: false == fireImmediately: true)
  • MuListener, MuConsumer and MuMultiBuilder accept any ValueListenable, not just MuLogic
  • MuProvider.of / maybeOf take an optional listen flag
  • MuComparable is annotated @immutable; docs clarify that any == implementation (Equatable, freezed, records) works

2.0.0+5 #

  • Document MuComparable shallow equality and copy-on-write pattern for collections

2.0.0+4 #

  • Add screenshots

2.0.0+1 #

  • Improved documentation and examples

2.0.0 #

New Features #

  • Added MuListener<S> - Perform side effects in response to state changes (navigation, dialogs, etc.)
  • Added MuMultiListener - Listen to multiple state changes with a single widget
  • Added MuConsumer<S> - Combines MuBuilder and MuListener functionality
  • Enhanced MuProvider<T> - Now fully generic, works with any type (not just logic classes)
  • Improved documentation - Comprehensive README with better examples and usage patterns

Breaking Changes #

  • MuProvider<T> is now generic for any type instead of MuProvider<L, S>
  • Constructor parameter renamed from logic to value to reflect generic nature

Improvements #

  • Auto-disposal - MuProvider automatically disposes ChangeNotifier instances

Architecture #

This release represents the mature, stable API for mu_state. The complete widget set now provides:

  • State management with MuLogic<S> and MuBuilder<S>
  • Side effects with MuListener<S> and MuConsumer<S>
  • Dependency injection with generic MuProvider<T>
  • Multi-state handling with MuMultiBuilder and MuMultiListener

1.1.0 #

  • Added MuMultiProvider - Clean nesting of multiple providers
  • Enhanced example - Login feature with MuMultiProvider and repository pattern
  • Documentation improvements - Better README structure

1.0.0 #

New Features #

  • MuLogic<T> - Renamed from MuState for clarity (still an alias for ValueNotifier)
  • MuProvider<L, S> - Provides logic instances to widget tree using InheritedWidget
  • context.logic<T>() extension - Easy access to logic from context
  • MuComparable mixin - Lightweight alternative to Equatable for state equality

Breaking Changes #

  • RENAMED: MuState → MuLogic<T> for better clarity
  • REMOVED: Pre-defined state classes (MuEvent, MuLoading, MuError, MuData)
  • Users now define their own immutable state classes with MuComparable

Architecture #

  • Encouraging Cubit-style pattern: one logic class per page/feature
  • Custom state classes instead of pre-defined ones

Unchanged #

  • MuBuilder<T> - Still an alias for ValueListenableBuilder
  • MuMultiBuilder - Listen to multiple ValueNotifier objects

Migration Guide #

  1. Replace MuState with MuLogic<T>
  2. Replace MuEvent<T> usage with custom state classes
  3. Use MuProvider and context.logic<T>() for dependency injection
  4. Add MuComparable mixin to state classes for equality comparison

0.5.0 #

  • let's keep the old names to avoid breaking changes (except for events!)
  • note MuState is just an alias for ValueNotifier and can take any type
  • note MuBuilder is just an alias for ValueListenableBuilder
  • note MuEvent is optional

0.4.0 #

  • renamed MuState to MuLogic !BREAKING!
  • renamed MuEvent to MuState !BREAKING!
  • MuLogic is now just an alias for ValueNotifier and can take any type (MuState is optional)
  • MuBuilder is now just an alias for ValueListenableBuilder

0.3.0 #

  • use explicit type for MuEvent

0.2.0 #

  • replace complex mu_event type with 4 sealed types (BREAKING)
  • use switch expression / patterns to handle mu_event types
  • bump sdk version to 3.0.0

0.1.1 #

  • update CHANGELOG

0.1.0 #

  • user super in constructors
  • update lints -> 3.0.1
  • sdk env 2.18.0 < 4.0.0
  • add vscode example launcher

0.0.4 #

  • replace AnimatedBuilder -> ListenableBuilder
  • Set min SDK version to 3.0.0 and Flutter to 3.10.0

0.0.3+1 #

  • Add widget tests and improve unit tests
  • Improve example in README

0.0.3 #

  • Remove duplicate MuBuilder declaration

0.0.2 #

  • Split classes into separate files under lib/src

0.0.1 #

  • Initial release
2
likes
160
points
132
downloads

Documentation

API reference

Publisher

verified publisherapptakk.com

Weekly Downloads

Minimal Cubit-inspired state management using Flutter's built-in primitives. No external dependencies.

Repository (GitHub)
View/report issues

Topics

#state-management #cubit #state #valuenotifier #minimal

License

MIT (license)

Dependencies

flutter

More

Packages that depend on mu_state