Questions tagged [statefulwidget]
339 questions
5
votes
2 answers
Do all widgets in Flutter have the "bool this.mounted" property?
Peace be upon you
I am researching Flutter's widget lifecycle and stopped at a point which is the this.mounted boolean variable, it does exist directly in the State class, which can only be connected with a StatefulWidget as a subclass and never…

Salah Rashad
- 408
- 8
- 18
5
votes
2 answers
When is the State object destroyed in a StatefulWidget?
One of Flutter's mantras is that widgets are immutable and liable to be rebuilt at a moment's notice. One reason for the StatefulWidget is the accompanying State object, which 'hangs around' beyond any individual build() method call. This way text…

larryq
- 15,713
- 38
- 121
- 190
5
votes
2 answers
Accessing a function of stateful widget in its state class? flutter
I am trying to call _signOut function after the onPressed method for logout button. However it doesnt (recognize the function or let me call it) I can however make a call widget.Onsignedout, a callback to it parent and everything works as intended.…

Tegster007
- 91
- 2
- 8
5
votes
4 answers
Understanding the use of StatefulWidget in Flutter
I'm just starting to fiddle with Flutter and I can't understand the point of StatefulWidget. All those widgets do anywhere I've seen in tutorials etc. is instantiate a State and let it do all the work.
For example, from this (official)…

Neo
- 3,534
- 2
- 20
- 32
4
votes
3 answers
How to manage a custom widget state in SingleChildScrollView Widget
I'm trying to design this view.
I already have the basic design of the cards, but i would like to know how to change the card's background color, the card's border color and add the little green square according to the width size of the current…
4
votes
1 answer
How to recreate a single widget in flutter and make it lose the state?
I have a widget that I want to recreate the state for what can I do to achieve this? I heard there is a way by UniqueKeys but I have no idea about them well because I'm a beginner (don't worry I have searched)
What I tried so far was to pop the…

Hussein Al-mosawi
- 91
- 1
- 5
4
votes
1 answer
how to setState inside streambuilder
I have a streamBuilder inside a stateful widget that gets data asynchronously from the server. Additionally, I have a list that collects those data.
StreamBuilder(
stream: myStream.stream,
initialData: initData,
builder: (BuildContext…

MoneyBall
- 2,343
- 5
- 26
- 59
4
votes
2 answers
Is it possible to extend a StatefulWidget that provides an extra parameter on its build method?
I would like to create a BaseScreen Widget like this to reuse in my app:
class BaseScreen extends StatelessWidget {
final Widget child;
BaseScreen({this.child});
@override
Widget build(BuildContext context) {
var safePadding =…

Jan
- 2,462
- 3
- 31
- 56
4
votes
1 answer
How do I access a method of the state objects for a list of stateful widgets? (Flutter)
class Astate extends State
{
List b=new List();
@override
Widget build(BuildContext context){
b.add(B());
//how do I access theMethod() for the state object for b[0]?
}
}
class B extends StatefulWidget
{
…

Nand gopal
- 346
- 3
- 17
4
votes
1 answer
SetState() called in constructor
I've build a Custemized List. Now I include a Checkbox and if I would checked or unchecked , the following error was thrown: 'setState() called in constructor'
class Lists extends StatefulWidget{
@override
_List createState() =>…

Julia
- 55
- 1
- 1
- 6
4
votes
1 answer
Flutter: Change the parameter passed to a "StatefulWidget"
I have a StatefulWidget named BounceContainer. This class contains a parameter child like a typical Flutter widget. Basically, it bounces the child whenever the user taps on it. The way I pass the child parameter as of now is as follow:
class…

Melvin Abraham
- 2,870
- 5
- 19
- 33
4
votes
3 answers
Flutter - Stateful Widget Doesn't Save Counter State When Switching Tabs
I am learning flutter and I am working with tabBars and I am having an issue with saving the state. I have put a small working example of my issue below. Basically, there is a button and a stateful counter. When I click the button, I see the text…

casmang
- 375
- 1
- 6
- 17
3
votes
2 answers
Are Statefull widget deleted and replaced when being rebuild using setState()?
As per my inforamtion,
flutter has a widget tree and an element tree.
For every stateful widget in the widget tree an element in the element tree is created with state object attached to it, that is pointing at the widget and which rebuilds the…

Ekjyot Sandhu
- 43
- 1
- 5
3
votes
0 answers
How to make Flutter rebuild nested Stateful Widgets?
I've been banging my head against this for several days now, so I really hope somebody can shed some light.
I need a custom button that looks a certain way and runs simple animations on itself (really simple, like cross-fading to a different color…

Lev Tyrnov
- 31
- 3
3
votes
4 answers
How to force initState every time the page is rendered in flutter?
I am adding some data into the SharedPreferenceson page2 of my app and I am trying to retrieve the data on the homepage. I have used an init function on page 1 as follows:
@override
void initState() {
super.initState();
…

ag2byte
- 191
- 3
- 11