Questions tagged [flutter-state]
369 questions
1
vote
3 answers
Flutter - how to update screen with latest api response
I want to update the screen whenever I call the API. Right now I have the following
Future getData() async {
var response = await http.get(
Uri.parse('https://www.api_endpoint.com'),
headers: {
'Accept':'application/json'
…

JC23
- 1,248
- 4
- 18
- 28
1
vote
0 answers
Why the Snackbar is re-shown in the below code when I am clearly setting the condition that should show the Snackbar to false in Flutter?
I have created a custom button widget in flutter called BottomButton. Since I feel that the implementation of the custom widget is not necessary for the question, I have simply omitted it.
BottomButton(
text: "Tap to Login",
…

gfit21x
- 141
- 9
1
vote
2 answers
How to avoid streambuilder executes unnecessarytimes
I'm trying to display a list of documents which works, but I read that one good practice is to manage states (which I'm trying currently to understand too). In this case every time I change of screen using the bottomNavigationBar the streamBuilder…

Alexis Chavarría
- 27
- 4
1
vote
3 answers
My stateful widget does not update it's state when setState is called
Background
Inside the state object of my stateful widget, I have the following code.
class _PendingJobsState extends State {
List pendingJobs = []; <------------------- I am trying to change the state of this variable.
…

gfit21x
- 141
- 9
1
vote
1 answer
Is there a way to remove all states in state management in flutter?
So currently i am using flutter providers package for managing state in my app.
Things i am able to do currently:
Maintaining a bool variable and using it to maintain states globally.
Having a string in which there is some text and it changes as…

Lakhan Kumawat
- 21
- 6
1
vote
0 answers
Adding different marker icons to several locations to my google map in flutter does not work
I have added a comment in front of some lines that says 'not needed'. I added this to mark the lines that I think is not related to the question. (The reason I did not remove those lines is, in case that those lines are related to the question,…

NewPythoneer
- 93
- 5
1
vote
1 answer
Flutter function is getting called everytime state is set
I am making a small game where user need to guess answer using the characters provided on screen in a grid view, I made the grid view that contains characters from answer and some random characters, to generate random characters I made a…

Dilpreet
- 13
- 2
1
vote
1 answer
Flutter setState 3 positional argument(s) expected, but 1 found error
on Button click, I trying to call setState but VScode generates a bug like below.
Its Stateful widget and VScode suggested that setState(mounted, setState, fn);
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
…

dokind
- 249
- 3
- 15
1
vote
0 answers
BlocProvider.of() called with a context that does not contain a TodosCubit
I'm just starting a new project, and using the Bloc for the first time. I'm getting this error, and I'm sure it's because I'm a newbie to it. This is my code
This is the main.dart code
void main() {
runApp(Todo( appRouter: AppRouter(),…

ken4ward
- 2,246
- 5
- 49
- 89
1
vote
0 answers
My flutter listview.builder is not rendered full list, its only render top 4 index
I need to animate the container from top to bottom. I try this animation with Listview. builder. ListView.builder renders only the top 4 indexes. I need to animate the full list. I have a bool type list. if the list returns true container will…

Joshua Jenny Sibbu
- 51
- 3
- 11
1
vote
1 answer
Flutter provider and widget lifecycle
I have a simple flow:
a UserModel implementing ChangeProvider which wraps the state of the user (if it is logged in and utilities to log him in/out). In particular logout looks like:
void logout() {
user = null;
notifyListeners();
}
a…

alexlipa
- 1,131
- 2
- 12
- 27
1
vote
4 answers
The argument type 'Function' can't be assigned to the parameter type 'void Function(bool?)?'
I am trying to pass a function using constructor arguments but it shows me the error mentioned in the title.
import 'package:flutter/material.dart';
class TaskTile extends StatefulWidget {
@override
_TaskTileState createState() =>…

vandit vasa
- 413
- 4
- 20
1
vote
1 answer
Flutter bloc state value updated but navigate value empty
I update BLOC state using this context.read().add(SurveyChanged(surveys: data)); in my bloc file updated value is printed but after i navigated to next page value is not updated. that also using same bloc.
bloc file snippet
if (event is…

yathavan
- 11
- 2
1
vote
0 answers
update tabbar widget from appbar textfield in flutter
I need to update tab 1 screen's list view based on textfield value which is placed in TabDemoScreen class's Appbar. while tab1 is selected , textfiled should be editable(able to type). and when i select tab2 textfiled should be act as dropdown list…

IosAdvocate
- 163
- 2
- 14
1
vote
4 answers
Need explanation for setState() function in Flutter
I am confused on why do we have to put a function in setState to update variables. I could instead update the variables and call setState. I modified the code from https://flutter.dev/docs/development/ui/widgets-intro
class _CounterState extends…

Diablo
- 13
- 3