Search⌘ K
AI Features

Introduction to StateNotifierProvider

Explore the role of StateNotifierProvider in Flutter's Riverpod library and how it manages mutable state differently from ChangeNotifierProvider. Learn how it helps reduce unnecessary widget rebuilds by providing state effectively to the relevant widgets, improving app efficiency and performance.

What is the StateNotifier?

StateNotifierProvider is just another Provider variant in Riverpod to manage state in Flutter. However, there is a remarkable difference with ChangeNotifierProvider.

What is the StateNotifierProvider?

The StateNotifierProvider does not use notifyListener() anymore as it does not extend the data model with ChangeNotifier. However, it depends on StateNotifier, a Flutter independent mutable state change mechanism that has similarities with ChangeNotifier or ValueNotifier.

We’ll come to that point and discuss the core concepts in detail in the latter part of this lesson.

An old example

Our example Flutter application from the ChangeNotifierProvider lesson shows how ChangeNotifierProvider extends ...