Questions tagged [flutter-state]

369 questions
0
votes
2 answers

How to call a function from another statefull class in flutter?

I am learning flutter, I want to call a function (which is in statefull class) into another statefull class. I searched everywhere but there is no solid solution. Can anyone just suggest or provide me the wright way to call the function?
Rakesh Saini
  • 660
  • 2
  • 7
  • 20
0
votes
1 answer

Whats the best practice for object pool pattern in flutter/dart?

Imagine a very simple application with two pages, PostList and PostDetail. On the former page, we show a list of posts, and on the latter, the details of a single post. Now consider the following scenario. Our user clicks on the first PostItem and…
0
votes
2 answers

Flutter GetX controller getting null instead of data

I have an API (which does work and returns a response, and I even can see the response 1 line above the return statement), but for some reason, when the data should be passed to the variable, I receive null, instead of the returned value. the…
Slava Bugz
  • 318
  • 5
  • 17
0
votes
1 answer

Dart Unhandled Exception: Null check operator used on a null value, stack trace:

Though I have tried applying most of the suggested changes I have seen on SO, nothing has worked so far. I'm getting this common exception here - roleRaw!.map((roleJson) => RoleModel.fromJson(roleJson)).toList(); This is the code class…
ken4ward
  • 2,246
  • 5
  • 49
  • 89
0
votes
0 answers

Question regarding Performance when using ChangeNotifierProvider

i have implemented a Dark/Light-Mode in my app using Streams. My problem is, that the change of the colors is very laggy. Everywhere in my code are snippets like this: Provider.of(context) == ThemeMode.light …
Arveni
  • 68
  • 6
0
votes
2 answers

When I swipe gets this error:-Unhandled Exception: setState() called after dispose()

I am counting a number of swipes by user and it does count as it gets print in the console but after swiping I get this error:- [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: setState() called after dispose():…
GAGAN SINGH
  • 261
  • 2
  • 17
0
votes
2 answers

Flutter ListView: widgets doesn't update

I have a listview that shows some items, inside a StatefulWidget : ListView.separated( shrinkWrap: true, itemBuilder: (context, index) { return RowItem( item: rowsList[index], index: index, …
giozh
  • 9,868
  • 30
  • 102
  • 183
0
votes
2 answers

Passing a variable to another class from the state of another class

I am trying to pass the parameter username which has been received from another class to my HomePage class. I want to pass that parameter from the HomePageState to another class called Profile. I tried using the "widget.username" method to get…
0
votes
1 answer

Error: Could not find the correct Provider above this MyApp Widget

im trying to use StreamProvider with MultiProvider in MaterialApp when I try accessing the provider, I get the following error: Error: Could not find the correct Provider above this MyApp Widget main.dart class MyApp extends StatelessWidget { //…
user15103024
0
votes
2 answers

Flutter - How to change the body widget of parent, while passing a value, from child?

So, I have a "home" page, that has a scaffold, appbar, body, and bottomNavigationBar. Body is loaded as widget, from a list, depending on what's clicked on bottomNavigationBar. I'd like to be able to press something in the child widget currently…
Avanche
  • 1,630
  • 2
  • 13
  • 15
0
votes
1 answer

'Null' is not a subtype of type 'LoginController' in type cast in GETX Flutter

I am using nullsafety and following code produce error . The error is type 'Null' is not a subtype of type 'LoginController' in type cast. home: Obx(() { if (controller.authState == "Authenticated") { return HomeView(); …
Sumit Kumar
  • 678
  • 4
  • 19
0
votes
1 answer

CRUD Methods for single Model (not a list) with Provider

How can I define methods(functions) for a single model that is not a list with Flutter's Provider? For example, I have made 4 functions for a Model that is a list: List _userList = []; List get userList => _userList; //method for getiing…
0
votes
0 answers

Unhandled Exception: setState() called in constructor:

I know that there are a lot of similar questions but none helped me, that's why I'm posting this one, so please bear with me. My screen is: import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import…
0
votes
2 answers

Problem trying to use provider with nested BottomNavigation Bar for my state- Flutter

I'm trying to learn proper state management with provider, I've got an issue that I'm having trouble with here. From what I can tell, I'm doing everything as per instructions in three separate provider tutorials. I'm also using it successfully for…
RobbB
  • 1,214
  • 11
  • 39
0
votes
1 answer

Flutter Widget rebuild after one of the property changed

How to manage to force a Widget to rebuild immediately after one of the property value has changed? Some pseudo code: class Live extends StatefulWidget { String name; Live(this.name); @override _LiveState createState() =>…
Ensei Tankado
  • 270
  • 2
  • 12