Skip to content
pubscout

safe_change_notifier

0.4.0+1, released a year ago by canonical.com

A drop-in replacement for Flutter's ChangeNotifier where notifyListeners() is a safe no-op after disposal.

WASM-ready
$ flutter pub add safe_change_notifier
Source repository

What it does

It provides safe drop-in replacements for Flutter's ChangeNotifier and ValueNotifier, ensuring that calling notifyListeners() after disposal becomes a safe no-op instead of throwing an error. It also includes SafeStateNotifier and SafeNotifierMixin.

AI-written summary of version 0.4.0+1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want to prevent errors caused by calling notifyListeners() on disposed ChangeNotifiers.
  • You need a drop-in replacement for standard Flutter ChangeNotifier or ValueNotifier.

Skip it when

  • You are using a state management approach that does not rely on ChangeNotifier or ValueNotifier.

Strengths

  • Prevents disposal-related crashes during asynchronous operations updating notifiers.
  • Acts as a drop-in replacement for standard Flutter classes.

Weaknesses

  • Doesn't fundamentally change state management architecture beyond avoiding disposal errors.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1

Alternatives

Packages that do the same job and could replace safe_change_notifier.

Works with

Packages commonly used together with safe_change_notifier: ones it builds on, ones built on it, and its own family.