Questions tagged [flutter-provider]

For questions relating to the "Provider" package for the Flutter framework. Use this tag in combination with the general [flutter] tag. If your question applies to Flutter more generally, use the [flutter] tag only.

This tag should be used for any questions regarding the provider package for the framework.

The provider is a wrapper around InheritedWidget to make them easier to use and more reusable.

Provider uses InheritedWidget's to provide dependency injection functionality for state management in Flutter applications.

To get started, one can read through the README on GitHub, i.e. on the official GitHub page for the provider package.

1487 questions
5
votes
1 answer

stateNotifier for multiple states with riverpod

I'm confused about how to use stateNotifier with riverpod. Most of the tutorials out there uses the counter example which is good but still not that clear to me. I'm trying to implement a stateNotifier with 2 states : isDrawerOpen and isDrawerColor…
stalwart1014
  • 451
  • 1
  • 9
  • 29
5
votes
0 answers

Flutter how to access provider.of(context) in FCM backgroundHandler static method?

I have successfully setup background notifications and tested it using postman and all is good. Now I need to access Provider.of(context) in my backgroundHandler which must be a static method where there is no context. All I need to do is to perform…
AhWagih
  • 485
  • 5
  • 14
5
votes
2 answers

Update the Map data of an Array inside Firestore - Flutter

I've been trying to create a demo "Schedule-App" powered by Google's Firebase, but I'm facing some difficulties updating specific values of an Array with Map values on the side of Firestore. As you can see on the following image, what we want to…
5
votes
2 answers

Maintaining same state on different pages in flutter for a particular use case

I know there have been certain questions on state management in flutter, but none of them seemed to solve my use case. Recently I was building an app based on E-commerce and encountered this real need for state management. I had 2 pages, One is the…
5
votes
2 answers

Flutter provider state management, logout concept

I am trying to implement custom logout solution for my application, where no matter where user currently is, once the Logout button is clicked, app will navigate back to Login page. My idea was, that instead of listening on every component for state…
Robert J.
  • 2,631
  • 8
  • 32
  • 59
5
votes
0 answers

Flutter provider notify only selected listeners

I'm fighting with Flutter's provider and can't understand all of it's possibilities. The thing is that for example I have such widgets structure: Widget_A --Widget_B ----Widget_C ----Widget_D --Widget_E --Widget_F Simple example is TODO list.…
Alexander
  • 357
  • 4
  • 20
5
votes
4 answers

What is the use of provider in flutter?

Well, I am sort of new to Flutter, My question is why we use providers in Flutter, I know it is used for state management. But I am looking to know the most common use case of providers.
Hafiz Siddiq
  • 671
  • 3
  • 9
  • 23
5
votes
1 answer

How use provider in onGenerateRoute?

How can i use my UserProvider in onGenerateRoute? I want to check if user is logger using UserProvider.isLogged(), but when i trying to get Userprovider i must to pass context with i dont have in Router. I already trying to change generateRoute to…
Cacus
  • 75
  • 8
5
votes
1 answer

Navigate while Widget state build is being executed

I'm building a simple Flutter app. Its launch screen determines if the user if logged in or not, and depending on that redirects to the login or main/home screen afterwards. My Launch screen is a StatefulWidget, its state is shown below. It uses a…
Husayn Hakeem
  • 4,184
  • 1
  • 16
  • 31
5
votes
2 answers

Provider vs ViewModel

Learning more about the Provider and ChangeNotifier architecture, I find it really similar to the old good MVVM architecture, where a Widget is the View and gets notified for changes by the ViewModel, which is the ChangeNotifier, linked by a…
Michel Feinstein
  • 13,416
  • 16
  • 91
  • 173
4
votes
2 answers

Why use BloC or Provider in Flutter when we already have Flutter's built-in setState?

Maybe I don't understand the purpose of BloC or Provider but I'm confused as to why we would ever want to use them instead of using Flutter's built-in state management using the Stateful widget. I've just finished an app and can't remember a point…
boc
  • 158
  • 3
  • 11
4
votes
1 answer

Why most of the codes use Provider package and don't use GetX/Riverpod/Bloc?

I am learning Flutter. Most of the tutorials use Provider package but some others on Youtube use GetX. I searched about it and found that it seems there are another packages like Bloc, Riverpod, etc. I am confused and don't know which one to use? It…
4
votes
1 answer

Provider: How can I `notifyListener()` within a `StreamBuilder()`? It causes the error `setState() or markNeedsBuild() called during build`

I have a Provider model such as provider_model.dart: import 'package:flutter/material.dart'; class ProviderModel extends ChangeNotifier { final List _myList = []; List get myList => [..._myList]; void addItem(String item) { …
MendelG
  • 14,885
  • 4
  • 25
  • 52
4
votes
1 answer

Flutter Provider - StreamProvider depending on another StreamProvider

TLDR How to use data from one stream provider to call another? Background of the Problem Hello! I have this Firebase Realtime Database Structure Each user's Group IDs are stored here. They can be accessed to then query the following 'Groups' Json…
4
votes
3 answers

Flutter : Hot reload / Hot restart showing white screen with debug banner?

In my flutter app , when I try to hot reload or hot restart , after process complete , the reloaded screen shows for a second and then went whole white only the Debug banner in top right side showing There is no errors in the console. It just says…
RagAnt
  • 1,064
  • 2
  • 17
  • 35