Questions tagged [statefulwidget]

339 questions
2
votes
0 answers

What's the use of Stateless Widget if one can directly return a widget

This might be an odd question but I'm wondering what's the actual use of stateless widget if one can simply return a widget? Stateful widgets on the other hand are useful for handling states because of setState method. Are stateless widget only…
cattarantadoughan
  • 509
  • 1
  • 6
  • 15
2
votes
1 answer

How to call method of StatefulWidget from onPressed which is in Stateless class?

I´m learning flutter and as a first app I chose to make a calculator. I have got the layout set and now I need to do some work with data. The core of the problem is that I would like to change output (which is StatefullWidget) every time I press a…
bumara
  • 23
  • 4
2
votes
1 answer

Flutter StatelessWidget and Provider not updating or calling build unnecessarily

I'm trying to use Provider with a Stateless widget page to update a countdown UI. When I run all the below, I get both print messages in the console on each 1 second tick of the stopwatch: e.g. flutter: build() flutter: _buildCountDown() Also, the…
Dave
  • 5,283
  • 7
  • 44
  • 66
2
votes
3 answers

Removing item from ListView.Builder always removes the last item in Flutter

When I tried to remove an item, every time the last item get removed. After searching for solutions, I found out it works this way with stateful widgets, and the solution is to add keys in the widgets. So I added keys but the problem isn't gone. The…
motasimfuad
  • 530
  • 4
  • 12
2
votes
1 answer

Is it possible to use "formKey.currentState" inside a stateless widget with GetX?

I am trying to convert a code that uses provider package and stateful widget to use GetX package and stateless widget. One problem I do have is that I have a form that changes(from login to signup and vice versa) using animation, but when I check…
Hasani
  • 3,543
  • 14
  • 65
  • 125
2
votes
1 answer

What is the alternative for "initState()` while we using "GetX" and "statelessWidget"?

I have the following code that is inside a statefullWidget, and I want to change the statefullWidget to a statelessWidget and use GetXCintroller instead. AnimationController? _controller; Animation? _slideAnimation; Animation?…
Hasani
  • 3,543
  • 14
  • 65
  • 125
2
votes
1 answer

Creating a guitar tuner using Flutter and 'flutter_fft' plugin, struggling to include BottomNavigationBar with the Tuner's Stateful Widget

As the title mentions, I'm currently creating a guitar application that is to include some information on basic notes and chords, a chord generator, and of course a guitar tuner. I've decided to start with what I believe is the hardest part and…
Luke Browne
  • 131
  • 1
  • 7
2
votes
1 answer

ChangeNotifier wrap class around each instance of a model

I have an application where I display a list of cards that represent a model (Let's say a Person). These are stateless widgets as they cannot be changed directly. These instances are obtained from an API and, since the amount of items is large, I am…
2
votes
1 answer

Error Missing concrete implementation of 'StatefulWidget.createState'. Try implementing the missing method, or make the class abstract

import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatefulWidget { Widget build(BuildContext context) { return Scaffold( body: Center( child: Container( …
Erano-
  • 29
  • 2
2
votes
0 answers

How to update the index of Bottom Navigation Bar ? - Flutter

I want to update the current index of the BottomNavigation Bar by ValueNotifier or anything instead of . and I don't need to wrap the bottom bar by Scaffold , because when I did it , the home screen didn't load . And I jsut updated the current index…
2
votes
2 answers

How to setState widget by other widget Flutter ,simplecode below

right widget has gesterdetector that adds a String ("ZzZ") to List; left widget shows all String there in String list by List view Buildder, right widget adds "ZzZ" to list after pressing the button successfully but it dosent sets ui state... in…
2
votes
3 answers

Why I'm getting the error, Invalid constant value in flutter statfulwidget flutter

In the below code widget.hintText is giving the error, I am trying to make the datepicker as the seperate component and dynamically pass the hinttext value whenever calling it from the other file. import 'package:date_field/date_field.dart'; import…
ibex
  • 103
  • 1
  • 6
2
votes
1 answer

Flutter/Dart - How can I change the State of a StatefulWidget from another StatefulWidget in a different file?

Background: I have a StatefulWidget for a navbar that displays the icon of the current page as active. It already updates correctly if the user clicks in different icons from the navbar. But I also need it to update the active icon if the user…
2
votes
2 answers

One big StatefulWidget or multiple small StatefulWidgets

I have a UI that has 20+ small widgets that need to update simultaneously, while some widgets remain Stateless. I was wondering if it is more efficient to have the whole UI updated rather than having each one updated individually. In a broader…
hman_codes
  • 794
  • 9
  • 24
2
votes
1 answer

what does Inflating StatefullWidget mean in Flutter?

State objects are created by the framework by calling the StatefulWidget.createState method when inflating a StatefulWidget to insert it into the tree. Here What does inflating StatefulWidget mean?