error_notifier_for_provider 1.0.0 copy "error_notifier_for_provider: ^1.0.0" to clipboard
error_notifier_for_provider: ^1.0.0 copied to clipboard

A trick to notify errors in ChangeNotifier/ValueNotifier/StateNotifier.

error_notifier_for_provider #

A trick to notify errors in ChangeNotifier/ValueNotifier/StateNotifier. No more GlobalKey<Scaffold>!

Provider(
  create (_) => YourObjectWithErrorNotifierMixin(),
  child: Scaffold(
    body: ErrorListener(
      onNotify: (context, message) => Scaffold.of(context).showSnackbar(
        Snackbar(content: Text(message))
      )
      child: YourContent(),
    ),
  ),
);

Pros #

  • Easy to use
  • You can use it with ChangeNotifier/ValueNotifier/StateNotifier and any other provided objects.

Motivation #

ChangeNotifier/ValueNotifier/StateNotifier can notify and reflect its state to other object. But it's for UI, not the one shot notification like an error notification.

error_notifier_for_provider provides another path to notify something.

5
likes
130
pub points
64%
popularity

Publisher

unverified uploader

A trick to notify errors in ChangeNotifier/ValueNotifier/StateNotifier.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, provider

More

Packages that depend on error_notifier_for_provider