Questions tagged [statelesswidget]
121 questions
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
0 answers
Will stateless widget be rebuilt again?
I am making a list of stateless widget as shown below and passing the id as the parameter to the widgets.
Code for cartPage:-
class Cart extends StatefulWidget {
@override
_CartState createState() => _CartState();
}
class _CartState extends…

Deepak Lohmod
- 2,072
- 2
- 8
- 18
1
vote
1 answer
use AppLifecycleState in StatelessWidget
in StatefulWidget when need to work with AppLifecycleState we work with WidgetsBindingObserver
@override
initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void dispose()…

George Anwer
- 13
- 5
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
2 answers
Fixed height in Container is not working in Flutter
Container height is set to fixed 40 but once I'm using that Widget in AppBar() it takes all the possible height. Here is the code for my custom widget which has Fixed height of Container,
class LPBorderButtonWithIcon extends StatelessWidget {
…

Al Walid Ashik
- 1,545
- 20
- 32
1
vote
1 answer
Error in creating a simple randomizer with stateless widget. The instance member can't be accessed in an initializer
I'm trying to create a very simple generator where either "yes", "no", or "maybe" appears inside this (stateless) crystal ball.
This is my code:
import 'dart:html';
import 'package:flutter/material.dart';
import 'dart:math';
void main() =>…

Pamela
- 425
- 1
- 6
- 17
1
vote
0 answers
What is my mistake with Flutter Provider Architecture, since it keeps rebuilding infinintly?
What am I mistaking with provider architecture?
My EntryPoint:
void main() {
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => AuthProvider()),
…

Fahad Md Kamal
- 243
- 6
- 20
1
vote
0 answers
Flutter statelessWidget init a viewModel
class RegisterPage extends StatelessWidget {
final String code;
RegisterPage(this.code,);
RegisterViewModel _viewModel = RegisterViewModel();
}
//this is RegisterViewModel
class RegisterViewModel extends ViewStateModel {
String…

胥福阳
- 11
- 1
1
vote
2 answers
Can a StatelessWidget contain member variables?
I have a StatelessWidget that uses a ScopedModel to store its data. The widget basically presents a list of checkboxes and some buttons to save the state of the checked boxes.
Now I want to keep track of if the user has altered any of the…

Magnus
- 17,157
- 19
- 104
- 189
1
vote
1 answer
Why does a child state of StatefulWidget doesn't get reset when constructor parameter changes?
I have a custom widget class:
class FancyButton extends StatefulWidget
{
final Function() onTap;
final String text;
final IconData icon;
bool enabled;
FancyButton({this.onTap, this.text, this.icon, this.enabled = true})
@override
…

Gintas_
- 4,940
- 12
- 44
- 87
1
vote
1 answer
Don't we ever need Keys if we only have StatelessWidget in our widget tree?
So I believe Key in Flutter is still something many of us either don't use at all, or use it without knowing what it actually is.
So I was learning some about it and It seems like we don't need / we don't have any use of any key if we have…

erluxman
- 18,155
- 20
- 92
- 126
1
vote
3 answers
Can I use RefreshIndicator in Stateless flutter widget?
I'm fetching some json data from the internet and displaying in a listview builder inside a stateless widget
Now I want to refresh the data using RefreshIndicator.
Do I need a stateful widget for this or can I manage to do this with a stateless…

user730376
- 33
- 4
1
vote
0 answers
Flutter - Sending data & defining additional data between pages
I am running into a problem which I find difficult to describe.
I have a class with two variables. On page 1, I would like to show variable 1. Then, if the user progresses to page 2, I would like to display a widget with variable 1 and 2. I…

Nicolas O
- 143
- 2
- 12
1
vote
2 answers
StatelessWidget to StatefulWidget
I'm adapting a class from Wikipedia Explorer (open source) to browse pre-selected pages. I'm trying to add a page counter that it doesn't update because it is a StatelessWidget. Can someone help me to turn it into StatefulWidget?
class…

Alexandre Marques
- 69
- 15
1
vote
0 answers
Flutter Inhertied widgets in a widget (stateless of statefull)
in Flutter we access an inherited widget fields by using its static of method:
Inhertied_widget.of(context).wanted_field
so, my question is, in a widget (stateless or statefull) when we use something like this:
final ScreenArguments args =…

Jalil.Jarjanazy
- 839
- 1
- 9
- 22