Closed murtaza-bhaisaheb closed 2 years ago
@murtaza-bhaisaheb The code sample you shared contains third party plugin and custom code, but in order to narrow down the issue to framework, please provide complete minimal reproducible code sample without any third party plugin that triggers the assertion you are reporting.
Thanks.
// A function to fetch the list:
Future<List
httpErrorHandle(
response: res,
context: context,
onSuccess: () {
for (int i = 0; i < jsonDecode(res.body).length; i++) {
productList.add(
Product.fromJson(
jsonEncode(
jsonDecode(res.body)[i],
),
),
);
}
showSnackBar(context, 'Product added successively');
Navigator.of(context).pop();
});
} catch (e) {
showSnackBar(context, e.toString());
}
return Future.value(productList);
}
// In the UI:
Future<List
// And in build method:
FutureBuilder( future: fetchAllProducts(), builder: (BuildContext context, AsyncSnapshot snapshot) { switch (snapshot.connectionState) { case ConnectionState.waiting: return const Text('Loading....'); default: if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } else { return const Scaffold( body: Text('Loaded'), ); } }
Loading appears for 1 second and then black screen appears
The updated code you shared still contains third party plugin provider
, so I suggest you to ask this question on support channels like StackOverflow.
Closing from here for now.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v
and a minimal reproduction of the issue.