Questions tagged [flutter-state]

369 questions
179
votes
12 answers

Do not use BuildContexts across async gaps

I have noticed a new lint issue in my project. Long story short: I need to use BuildContext in my custom classes flutter lint tool is not happy when this being used with aysnc method. Example: MyCustomClass{ final buildContext context; …
32
votes
6 answers

How to use data from Provider during initState in Flutter application

I am refactoring my Flutter application code by adding Provider as a state management. Desired behavior: When Home screen opens, app should check if users email verified, if it's not then should show dialog popup. Problem: It worked fine when I…
10
votes
1 answer

Stateful widget inside a Stateless widget and vice versa

How does Flutter rebuild/repaint work in case of: Creating a Stateless widget inside a Stateful widget. Creating a Stateful widget inside a Stateless widget. Does a Stateless widget inside a Stateful widget render each time the Stateful widget…
genericUser
  • 4,417
  • 1
  • 28
  • 73
10
votes
1 answer

When does route.didPop(result) is equal to false in Flutter Navigator 2.0

One of the main mecanism of Flutter Navigator 2.0 it the function onPopPage inside RouterDelegate > build > Navigator. However, I do not understand when route.didPop(result) returns false. We can use the John Ryan's famous example to show my…
Dimitri Leurs
  • 590
  • 5
  • 19
8
votes
2 answers

The superclass 'Bloc' doesn't have a zero argument constructor in dart

I am a beginner in Dart language development. I try to create a sample flutter application BLOC pattern inspired by this GitHub repo, but I got some error message related to the class inheritance. I am already familiar with the inheritance and…
Ragesh P Raju
  • 3,879
  • 14
  • 101
  • 136
6
votes
1 answer

Can i call cubit from another cubit?

i'm working on an application that uses cubits, to manage the state. Very often when i need to make an api request i need to get my current localization (handle possible exceptions) and then send it to backend. So i guess i should use cubit for the…
5
votes
0 answers

Flutter Navigator 2.0: access RouterDelegate state from outside

I am using Navigator 2.0 and I have my state stored inside the RouterDelegate so that I can have the currentConfiguration react to state changes. This is like all examples I saw. For example: BookRoutePath get currentConfiguration { return…
alexlipa
  • 1,131
  • 2
  • 12
  • 27
5
votes
3 answers

PageView homepage sometimes does not load on startup in release mode

I encountered a rather strange bug when my app is launching in release mode: I had followed this answer to preserve my pages for my BottomNavigationBar using PageView and AutomaticKeepAliveClientMixin. In debug mode, this bug does not…
iamhx
  • 472
  • 6
  • 24
5
votes
2 answers

Flutter What is difference between valueNotifier,changeNotifier,stateNotifier?

What is difference between valueNotifier,changeNotifier,stateNotifier?
5
votes
3 answers

How to manage multiple state on same screen using flutter bloc

i have a screen with three widget [widgetA, widgetB, widgetC] and i have a bloc[BlocA] which is responsible for the data fetching and displaying on this screen i have three event [eventA, eventB, eventC] which render the widget [widgetA, widgetB,…
avinash
  • 501
  • 2
  • 8
  • 16
5
votes
4 answers

How to call a function in cubit class in initState?

So, I have made a function in Cubit Class it is to get data from API. For now I just can get the data if I pressed a button. I wanna make the function automatically called when the page/screen is open. For your information, this page is the first…
5
votes
2 answers

Riverpod: List provider is not rebuilding

Flutter riverpod is not notifying the Consumer on the state change when the StateNotifier's type is List, while the same implementation works just fine for other types. here, I provided a minimal reproducable example: import 'dart:math'; import…
Adnan
  • 906
  • 13
  • 30
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
3 answers

Dispose method not called in flutter

I am facing an issue in which dispose method is not called after changing screen in flutter .First of all here is the source code. class Game extends StatefulWidget { Game({Key key, this.title}) : super(key: key); final String title; …
Vipin Dubey
  • 379
  • 2
  • 11
  • 21
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
1
2 3
24 25