Questions tagged [flutter-future]

71 questions
1
vote
0 answers

Flutter: Convert future to stream to get realtime updates from API and rebuild widget

I'm learning flutter by building an app. I have a like button where I'm displaying the count of likes using a FutureBuilder like this : FutureBuilder( future: likeNotifier.getLikesCount( postId: widget.postId, ), builder:…
1
vote
0 answers

Flutter, provider and a Future async function (http post request)

i am trying to call an (Future) http post request in a ChangeNotifier class. That means, after the Future is completed, the notifyListeners() should be called (see example below). No matter, what I tried, in the ChangeNotifier - App_State_Controller…
Uwe.Schneider
  • 1,112
  • 1
  • 15
  • 28
1
vote
1 answer

Flutter progress indicator with slow async method

when i try to use CircularProgressIndicator with slow async method, indicator is not shown. When i replace slow custom method with Timer.pereodic() that works fine. I am new in Flutter and do not understand what i am doing wrong class…
1
vote
2 answers

How can I update the data fetched from a future bilder in Flutter?

In my app I have a screen which contains 3 different future builders, I would like to update the data recovered from a future builder. I tried the setState () method but this updates all 3 future builders on the page, I only need to update one. How…
1
vote
1 answer

In Flutter, I am trying to make a dependent dropdown with the following json

In Flutter, I am trying to make a dependent dropdown with the following json. I Want the Dropdown to be in this format First, Independent Dropdown dataNames Second, Dependent Dropdown indexes of the dataSets' children Third, Dependent…
Joel Lee
  • 21
  • 3
1
vote
1 answer

Flutter Unhandled Exception: LateInitializationError: Local 'name' has not been initialized

I have a flutter app which tries to compare two sets of app version numbers, the first version number is stored locally using hive and the second version number is from firestore. I can fetch the data from firestore but I cannot get to compare both…
Kevnlan
  • 487
  • 2
  • 10
  • 31
1
vote
0 answers

How do I get Future to wait for my transactions in Flutter

I have this Future and my code template like this: Future getDevices() async { stream.listen(); Timer.periodic(Duration(seconds:5), (timer) { POST TO SERVER.then((value){ return Future.value(value); }); }); } I'm Listening to a Stream to…
1
vote
0 answers

Can not get data from a network request in a method that uses Scaffold.of(context)

I have two class methods inside my Stateful widget. As you can see one method is called inside the other one. 1st class method Future _getExchangeHousesList() async { const url = ApiEndpoints.getExchangeHouses; Map
1
vote
3 answers

My stateful widget does not update it's state when setState is called

Background Inside the state object of my stateful widget, I have the following code. class _PendingJobsState extends State { List pendingJobs = []; <------------------- I am trying to change the state of this variable. …
1
vote
0 answers

Adding different marker icons to several locations to my google map in flutter does not work

I have added a comment in front of some lines that says 'not needed'. I added this to mark the lines that I think is not related to the question. (The reason I did not remove those lines is, in case that those lines are related to the question,…
1
vote
0 answers

Fetching more data from Realtimedatabase

I am trying to get additional data from Firebase Realtime Database, based on the data returned by the StreamBuilder. Widget build(BuildContext context) { var authBloc = Provider.of(context); return Scaffold( body: SafeArea( bottom:…
Saad Bashir
  • 4,341
  • 8
  • 30
  • 60
1
vote
0 answers

Unhandled Exception: Invalid argument: Instance of 'Future'

When i run this it gives an error saying Unhandled Exception: Invalid argument: Instance of 'Future' String username = FirebaseAuth.instance.currentUser!.displayName.toString(); void _uploadImage() async { setState(() { _isUploading =…
1
vote
2 answers

Does a function without a return statement always return null in Flutter?

The return type of the following function is Future and yet the compiler does not complain that there is no return value if the picker did not return a picture. static Future takeImage() async { PickedFile? pickedFile = await…
Joel Broström
  • 3,530
  • 1
  • 34
  • 61
1
vote
2 answers

Flutter future Boolean function always return default value

I have a Future boolean function in that function I checked some data using the map function. if and else both conditions set the boolean variable is true. but it always returns the default false value. below code is my function. Future
1
vote
0 answers

Why is Future.delayed(Duration(microseconds:n(ps:n<1000)),fun) faster than Future(fun)?

This is my code.I looked at the source code of Future.delayed & Future. Future & Future.delayed both execute Time.run. Future Duration is Duration.zero,But Future.delayed(Duration(microseconds:n(ps:n<1000)),fun) is faster, And what's interesting…
VillainLin
  • 251
  • 1
  • 2
  • 7