31.49 Flutter Package: riverpod ProviderScope

20231027

The concept of a provider is the basis of how state can be managed in flutter. It provides a place to store (an encapsulation of) the current global variable values (called the state).

The basic idea is to wrap the entire app within a ProviderScope(), itself actually also a widget, so that widgets anywhere will be able to access the Providers.

void main() {
  runApp(
      ProviderScope(
          child: MyApp(),
      )
  );
}

The ProviderScope() widget stores the state of all the providers we create. It creates a ProviderContainer() instance. A ProviderContainer() is not often used directly in our code.



Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0