Questions tagged [flutter-state]
369 questions
1
vote
1 answer
Flutter: Child Widget's looses state when parent's sate changes
I am learning Flutter and struggling with some state management issue.
I have a HomeScreen widget which contains Scaffold and a BottomNavigationBar. To switch pages based on the selected tab in BottomNavigationBar I am using PageView with…

Dheeraj Pundir
- 13
- 2
1
vote
1 answer
Where should you place the state value in Riverpod?
To access the state of a StateProvider or StateNotifierProvider:
Sometimes in the Riverpod documentation, the state variable is added after the watch function.
int count = watch(counterProvider).state;
However, my code where I am using a…

joe kletz
- 13
- 3
1
vote
2 answers
When I am using the provider package in Flutter to load data from an API into a list it repeatedly calls the API, how do I fix it?
I am trying to lode data from an api call that retrieves a map, I am able to get the map from the api to display how I want it to, however it repeatedly calls the api meaning the list keeps on refreshing. Even though I have tried setting the…

Adarsh Manoj
- 11
- 3
1
vote
2 answers
Flutter base state management
I'm learning flutter by building app. I've implemented BLoC pattern to call rest api and provide data to the widgets. However per my understanding this is some data for the view which needs it. I want to have Settings button on most of the widgets…

Expressingx
- 1,480
- 1
- 14
- 39
1
vote
0 answers
how to persist a change of state in Flutter
Hi I'm developing a rating application with statefulwidget. I don't use any state management libraries. I want each user to be able to do a review on an item. But my problem is that the user can reviews the same item several times, and I would like…

Peter Edimo
- 13
- 3
1
vote
2 answers
How to use provider to create a commit/discard changes pattern?
What would be a best practice for (provider based) state management of modal widgets in flutter, where when user makes an edit changes do not propagate to parent page until user confirms/closes modal widget. Optionally, user has a choice to discard…

zigzag
- 579
- 5
- 17
1
vote
0 answers
How to call a function when AutomaticKeepAliveClientMixin state widget is going off the screen (or should have been disposed or unmounted)?
In the app, I am using PageView as home and 3 pages in it - Profile, Console, Settings with AutomaticKeepAliveClientMixin extension. In it, 2 of the pages(Profile and Console) have a 'Side Menu' screen using PageView again.
The problem is that when…

prakhar tomar
- 933
- 1
- 8
- 10
1
vote
0 answers
what happens to a Riverpod state provider that is watching a future, AFTER the future completes/expires
I'm guessing that the following code will FIRST return an empty list, and then later (when the future completes), it will return the actual data provided by the future.
That's all good ... but I'm wondering if my list-data will be retained and…

Dewey
- 756
- 6
- 17
1
vote
2 answers
How to solve error: 'setState' isn't defined
Can you please help me to solve this problem about setState()
ERROR:
The method 'setState' isn't defined for the type 'MyApp'.
Try correcting the name to the name of an existing method, or defining a method named 'setState'.
CODE:
return…

Abdelilah Ng
- 53
- 5
1
vote
1 answer
Is there a way to save state in Flutter so the App starts off from where we left off?
I want data to be persistence. I want the state to be same from where I left off before closing the app. Is there a way to achieve this in flutter?

Basit
- 33
- 4
1
vote
1 answer
Flutter: access provider from outside the widget tree
In my Flutter app I have to update the state hold by a Provider as soon as a push notification arrives so that the UI can be rebuilt.
The PushNotifications service is a class (not a widget) like that:
class PushNotifications {
...
Future…

Fabio
- 376
- 6
- 19
1
vote
4 answers
Navigate from initState returns 'findAncestorStateOfType' was called on null
I'm listening to database changes (firestore) in the initState. On a specific change I need to route the user to another screen.
My initState function:
@override
void initState() {
super.initState();
FirebaseFirestore.instance
…

genericUser
- 4,417
- 1
- 28
- 73
1
vote
0 answers
Flutter doesn't rebuild if there are animated Widgets
I have encountered a weird problem in Flutter. In my app, I'm showing a splash screen before my models and other things are initialized, then I show a different Widget for the duration of the application.
Things work as expected - unless the first…

Magnus
- 17,157
- 19
- 104
- 189
1
vote
1 answer
How to handle local-state in flutter with provider?
I use the provider package to manage my application state. I have a few questions concerning how to manage the state in the application.
Is it a good practice to create a ChangeNotifier class for each screen in my application to handle the back end…

Omar Alaa
- 141
- 2
- 13
1
vote
0 answers
FlatButton different text color while holding
I'm new in Flutter. I want to make a simple example. I want to change color of the flat button while holding. Essentially I did but I'm not sure it's the right way. Isn't there an easier way? For example, could be a property like…

kursat sonmez
- 818
- 1
- 12
- 22