76 questions
0
votes
1
answer
40
views
Flutter: Await future from the past
If have a variable:
Future<CarList?> carList;
I set this variable every couple of seconds via a backend call. In UI, I use FutureBuilder to show carList, which works OK. But outside UI, how can ...
1
vote
1
answer
50
views
How do pass data from a http get to a widget on another file flutter
Hello i have a flutter program structured like so: In this code i have a Navigation Bar with 3 pages, To make the code cleaner, i decided to write the code of the 3 pages in each of their own separate ...
0
votes
1
answer
53
views
Flutter Async Method in initState Not Executing Beyond First Await Call
I'm encountering an issue where a specific line in my asynchronous method isn't executing when called from initState. Here's the method in question:
Future<void> loadNetworkImages() async {
...
0
votes
1
answer
147
views
My UI freezes when I run two functions in the initState, How can I reduce time of getting data from backend and how can I save it locally?
How can I stop freezing my UI when I run two functions in the init state? Those two functions are the APIs which are getting me data from backend and I want it to display on screen.
Also I want to ...
0
votes
1
answer
188
views
Flutter won't return boolean in async await method
I need to check my file reading was successful and return true or false. I need to use async and await function because it needs to return true otherwise no point continuing.
I get a run time error ...
0
votes
0
answers
31
views
Why snapshot.connectionState in FutureBuilder is directly going to ConnectionState.done in the Below code
ResultAPI resultsAPI = ResultAPI();
@override
Widget build(BuildContext context) {
return Material(
child: FutureBuilder(
future: resultsAPI.getResult(2081951044),
...
0
votes
1
answer
241
views
Is there a way to change the written date using Cupertino date picker?
The current date is already written in the text button. When you press it, a CupertinoDatePicker pops up, but I want to change the written date instantly when I change the date in CupertinoDatePicker. ...
0
votes
0
answers
141
views
Future.catchError doesn't catch error thrown by camera plugin's CameraController.initialize
I'm trying to understand why my code doesn't work. I'm using the Flutter camera plugin, and want to handle cases when camera permissions are denied. In such cases CameraController.initialize should ...
0
votes
1
answer
934
views
Future.delayed method not working in Flutter
I want to perform a method after a delay in flutter, and I came across Future.delayed method, but the method was being called immediately without a delay.
I tried the following:
Future.delayed(const ...
1
vote
1
answer
955
views
Can I make Image.network() to a Future?
I have two process which both come with a loading time and therefore with separate LoadingIndicator Widgets:
Future getImageURL(String? pictureUrl) async {
if (pictureUrl == null) throw ...
0
votes
2
answers
74
views
Flutter: _TypeError
I'm trying to get datas from api and add them a list. But at this moment, I see datas i got but I can't get it out of the function. What should i do?
function
List<dynamic> xxx = [];
@...
0
votes
0
answers
35
views
How to use my ImagePaths function into my file so I have access to the index and .length of my list?
my ImagePaths function is supposed to return a list and I want to access that list in my Carousel but I can't seem to figure out how to do so.. The ".lenght" and the [index] are not working ...
0
votes
1
answer
277
views
getting the return value of Future Function in Flutter without Stateless/Stateful Widget
I just want to return the value of each condition and use it as the value of the function.
Here is my code for it.
var getStuff = chechIfExisting();
chechIfExisting() async {
var isExisting = await ...
1
vote
1
answer
121
views
Future Builder not rendering data table
in want create table from api response.i created data table using future builder. The future builder fires api twice not not return any data
class HomeScreen extends StatefulWidget {
const HomeScreen(...
0
votes
0
answers
76
views
Keep reviving a null value after calling a future function, but the data is clearly there
I am trying to use a geolocator and then put the values from the data received from a plug in into a list so I can then sort it. The problem is that when I try to add said data to the list, I get an ...
0
votes
1
answer
75
views
How to use function to call it inside the button?
Currently, I use Navigation to bring up Dialog. But of course, the page will be changed, and the screen will only display the Dialog. Like I've shown below.
I want to fix it, so that when the Dialog ...
1
vote
1
answer
248
views
How to cancel the then function in a future if catcherror is executed in flutter app
I'm trying to login in users using a third party api. But the problem is whenever an error occurs and the catch error is executed the "then" function that holds the navigation to the ...
3
votes
1
answer
2k
views
Flutter Riverpod Future provider - requires async and await?
I've been reviewing the RiverPod 2 tutorial at https://codewithandrea.com/articles/flutter-state-management-riverpod/
In the section dealing with Future providers there is a code snippet as shown ...
0
votes
1
answer
822
views
How to use a async function inside a ListView.builder?
Is there anyway to get a future when displaying a list?
I have list with two user id's ( one of them is the userlogged in, the other one is the user to chat with ).
my goal is to get and display the ...
1
vote
1
answer
781
views
Error :The method 'update' isn't defined for the type 'DatabaseException'. Error: The method 'delete' isn't defined for the type 'DatabaseException'
With null safety enabled, I'm using the new dart version <2.18.1>.
this is my code
import 'dart:async';
import 'dart:io';
import 'package:path/path.dart';
import 'package:path_provider/...
0
votes
0
answers
59
views
How can I build a widget conditionally, based on various different futures that could be called from a few buttons?
I have created a reusable CircleAvatar widget which builds itself based on it's parameters. The parameters are using .watch() from riverpod & so update automatically. This translates to, in rough ...
-2
votes
2
answers
1k
views
What should I do when I have to use "void function() async" as a last resort in Flutter?
My function is as follows:
void function() async {
…
}
I used the above function in Widget build(BuildContext context).
Actually, I want it to be Future<void> function() async instead of void ...
0
votes
1
answer
79
views
Pass token between future classes in flutter
I been reading multiple threads about passing data between futures, but for some reason I can get this to work.:(
I have two futures, where the first future is doing post request to retrieve a token
...
1
vote
1
answer
287
views
FutureBuilder snapshot is empty but Future has correct data AND FutureBuilder constantly refreshing - Flutter
I have screens in a TabBarView that share data so I decided to wrap the TabBarView in a FutureBuilder and pass the data from that into both screens. The Future is called fetchUsersAndPosts() and it is ...
0
votes
0
answers
82
views
Future<List<List>> returns empty - Flutter
I have a Future where users and posts are fetched from Firebase, turned into objects, added to either postsList or the usersList, and finally, the return is [usersList, postsList]. For so reason, ...
1
vote
1
answer
643
views
Correct way to load ListView data source initially
I have a stateful widget whose state builds a ListView. The ListView gets its data from an http API. I am using a Future<void> method called getData to retrieve this data and populate a List<&...
0
votes
1
answer
3k
views
Flutter How to reach into Future<DocumentSnapshot<Map<String, dynamic>>> inner map
I need help with my flutter code which involves firebasefirestore.
This is my code. I'd like to retrieve from the database the image_url from the map.
final userData = FirebaseFirestore.instance
...
0
votes
1
answer
53
views
The method '[]' was called on null, but it's not null
That title error is pointed on this line:
Text('${intData['summary']['intrested']}')
I want to display here data from backend, but I don't know how to accomplish that I am getting this error, but ...
0
votes
1
answer
720
views
Flutter FutureBuilder called twice
I have a page with a FutureBuilder and a custom widget with multiple FutureBuilders. My goal is to get Future after opening this page, but my FutureBuilders keep calling the Future twice.
This is my ...
1
vote
0
answers
234
views
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(
...
0
votes
1
answer
157
views
Flutter: Cannot retrieve data from a Future function on FutureBuilder
I'm building a receipt scanner using the Flutter OCR plugin provided by Veryfi.
Here's a Stream function that reads an image and returns a dynamic array containing the necessary values.
Note the ...
3
votes
3
answers
4k
views
Invalid argument(s) (onError): The error handler of Future.catchError must return a value of the future's type [duplicate]
I am trying to write a dart code program which can register users and sign in users, upon error print its description which i will eventually use in a Toast but it given an error on catchError
Future&...
1
vote
0
answers
1k
views
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 ...
0
votes
1
answer
3k
views
How can I use a Variable of JSON data in Flutter (not a listview)
I'm asking after looking into a lot of examples and similar questions, but I can't get my head around.
I just want to get certain data from an id in a json map into Flutter.
What I receive via php is ...
1
vote
1
answer
2k
views
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 ...
2
votes
2
answers
973
views
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 ...
1
vote
1
answer
595
views
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 ...
2
votes
1
answer
1k
views
Futurebuilder snapshot has no data
CollectionReference users = FirebaseFirestore.instance.collection('Users');
FirebaseAuth auth = FirebaseAuth.instance;
String uid = FirebaseAuth.instance.currentUser!.uid.toString();
var ...
1
vote
1
answer
621
views
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 ...
0
votes
1
answer
1k
views
Flutter/Dart FutureBuilder - How to store a snapshot.data in a variable and pass the value to other widget?
I'm new to Flutter, and I can't achieve display the snapshot.data value in a widget outside from futureBuilder scope, It's possible to do this? if not, what is the better way to do this?
//...
var ...
1
vote
0
answers
451
views
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(...
1
vote
2
answers
2k
views
How to listen for state changes inside a FutureBuilder widget and reflect the state change?
to demonstrate the problem, let me write down some code for a FutureBuilder.
FutureBuilder(future: _myFuture, builder: (context, snapshot) {
if(snapshot.hasData) {
// !!!! IMPORTANT !!!
...
0
votes
1
answer
537
views
How to add a marker to a google map upon tapping button on the parent widget in flutter
I have the following class for a google map in Flutter.
class ExchangeHousesMap extends StatefulWidget {
final List<Marker> markers;
final double initialLatitude;
final double ...
1
vote
0
answers
126
views
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<void> _getExchangeHousesList() async {
const url = ...
2
votes
0
answers
532
views
Correct use of Future.delayed to highlight text while playing audio flutter
In my flutter application, I'm trying to change the background color of text in list items for an audio playing. So each list item has one audio file. I have to detect when the audio ends and then ...
0
votes
2
answers
259
views
A value of type 'Future<AppDatabase>' can't be assigned to a variable of type 'AppDatabase'
I am trying to create a persistent interface which forks db calls to floor or another self made web db static store.
Anyway...
The interface part is looking like this:
peristent_interface.dart
import '...
0
votes
0
answers
496
views
How to deal with Future wait list when using progress bar in Flutter
As I read Future cant be cancelled in flutter. I am downloading multiple files and showing the progress with LinearProgressIndicator. When user press back button and then come to loading screen again ...
0
votes
1
answer
114
views
My stateful widget does not update the ui, even though I am calling setState and passing the correct value to the widget class
I ran into a bit of a problem in flutter that I could not figure out myself.
So I have the following code (only the important parts of the code are pasted),
class _PrimaryDetailsEditState extends ...
0
votes
3
answers
5k
views
The getter 'length' isn't defined for the type 'Future<List<Item>>'
I'm writing a kind of todo list in Flutter, with null safety enabled.
I'm storing the list of todo on a sqlite db using sqflite.
The Item class is the following:
class Item {
int? _id;
String? ...
1
vote
3
answers
2k
views
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<PendingJobs> {
List<String> pendingJobs = []; <---------...