Questions tagged [statefulwidget]
339 questions
1
vote
1 answer
What is the correct order of calling superclass methods in initState, didUpdateWidget, dispose and other build methods? Why?
In the Android development world there is a set order of Fragment/Activity lifecycle superclass method calls. I refer to the answer.
Now, regarding Flutter, if I type an empty StatefulWidget in IDE (both Visual Code and Android Studio)…

PrzemekTom
- 1,328
- 1
- 13
- 34
1
vote
1 answer
How can I change ID from JSON automatically in setState?
How can I change "1" in busData['data'][1]['directions'] to id passed from another class? I want to make this dynamic. I have 3 cities in previous view and I want to pass it's number automatically depending on which city I choose.
`
class Bus…

kropekHuncho
- 13
- 2
1
vote
0 answers
Animation: How to make a stateful widget depends on the widget parameter?
The SoC parameter of the widget is not available from the start.
So, I'd like my animation tween to actually takes the SoC when it is no longer null.
But because I construct my animation within the initState() I don't get a chance to do so.
What…

Stéphane de Luca
- 12,745
- 9
- 57
- 95
1
vote
1 answer
My screen doesn't reflect the changes in my app though the setState method works well
I'm trying to call a StatefulWidget(i.e FirstPage()) within a MaterialApp. I'm pretty much new to flutter and I don't know where I went wrong. According to my knownledge I've used StatefulWidget to tell flutter my screen on that page is going to…

Evo_star
- 38
- 6
1
vote
1 answer
Call method from onPressed of an IconButton
I have an IconButton and in the onPressed() method I want to call a void method that receives an incremental number as a parameter when the Button is clicked, then when obtaining this value it must call another void which calculates the days of…

Daniel Asmat
- 11
- 2
1
vote
1 answer
How to Maintain State of Drawer's Child Widget
I have a stateful widget, Counter, with a button and a counter that keeps track of how many times the button was pressed. This widget is in the drawer. When I close and open the drawer again, the counter is reset. How do I make it so that the…

Joel Castro
- 485
- 6
- 20
1
vote
2 answers
TextField value is not getting updated in Flutter
class UserInputArea extends StatefulWidget {
@override
State createState() => _UserInputAreaState();
}
class _UserInputAreaState extends State {
@override
Widget build(BuildContext context) {
String…

Noorus Khan
- 1,342
- 3
- 15
- 33
1
vote
1 answer
Why Doesn't Flutter give Widgets a key by default?
Since the element tree maps its elements to widgets in the widget tree by type, if a new widget replaces an old widget, and that new widget is of the same type as the old widget, the element in the element tree that corresponded to the old widget…

Joel Castro
- 485
- 6
- 20
1
vote
1 answer
How to interact with a child Stateful Widget from a parent Stateless Widget?
Context :
Say I have a custom DisplayElapsedTime Widget which is Stateful and holds a Text Widget. With a Timer, every 1sec, the text value is updated with the current elapsed time given by a Stopwatch.
And now, say I have a page which is Stateless…

Myrmillion
- 78
- 6
1
vote
1 answer
Why is context safe to be used inside didChangeDependencies() method but not inside the initState() method?
Both the initState() method and didChangeDependencies() are executed before the build() method of a state object, so why is the context not available inside initState() but available inside didChangeDependencies()?
According to the official docs,…

Nehal Choudhury
- 21
- 4
1
vote
1 answer
await http.get(url) does not work even in StatefulWidget
2 days ago, I asked the solution of my problem in this post and got answer to make another statefulwidget and use http codes. So my code became :
class _post_openState extends State {
void initState() {
super.initState();
//…

MooNChilD Song
- 225
- 1
- 9
1
vote
3 answers
Text widget font not appearing correctly
I've created a separate page with a StatefulWidget inside my Flutter app, and it has a Text widget inside of it.
However, when testing my app, the text does not render as intended - instead it shows up in a weird font with yellow underlining.
Here's…

DanDudeDev
- 23
- 2
1
vote
4 answers
type 'Null' is not a subtype of type 'DatabaseNotes' in type cast
The problem lies in the FutureBuilder widget section. I am trying to get the data from a snapshot in a FutureBuilder, but I get an error as 'type 'Null' is not a subtype of type 'DatabaseNotes' in type cast'. I tried declaring the _note field as…

Ozone317
- 39
- 6
1
vote
1 answer
Get the value of an integer from a stateful widget from another class in flutter
Learning Flutter and I am building a counter that I would like to use for a cart. I have a problem retrieving the integer value of the counter stateful widget I created and i'd like a Text to update itself with the value of the Counter.
Here is the…

thearach
- 27
- 4
1
vote
2 answers
Flutter - Hot reload - Change the value from outside of the State.build function
For managability purpose, I've built the app with the values including texts, dimensions, colors, paths, and etc, all been put into different files other than the StatefulWidget class files. I never looking for the solution for this problem before…

stackunderflow
- 1,492
- 1
- 23
- 53