skip to Main Content

Flutter – Exception handling inside FutureBuilder

import 'package:flutter/material.dart'; void main() { runApp(const MainApp()); } class MainApp extends StatelessWidget { const MainApp({super.key}); Future<void> _initialize() async { await Future.delayed(const Duration(seconds: 2)); try { throw Exception("Error"); } catch (e) {} } @override Widget build(BuildContext context) { return MaterialApp( home:…

VIEW QUESTION

Future API Call Flutter

Im trying to create an simple Network class on dart, to centralize all my calls to an specific API. So i create an Service class, and create an mock and a get function using Dio. import 'package:dio/dio.dart'; import 'package:flutter/services.dart'; import…

VIEW QUESTION

how to execute two asynchronous functions with flutter?

I have two functions in flutter. the first one is belManager.writeCharacteristic and the second one is belManager.disonnect I want to execute belManager.disonnect() after belManager.writeCharacteristic is completed. However for some reason bleManager.disonenct() is called before belManager.writeCharacteristic is completed. this is the…

VIEW QUESTION

setState not updating my star color because the FutureBuilder keeps rebuilding whenever I call setState – Flutter

Positioned( top: 12, right: 12, child: SizedBox( height: 25, width: 25, child: CircleAvatar( backgroundColor: isGolden? Colors.amber :Colors.black87, child: IconButton( padding: EdgeInsets.zero, icon: Icon(Icons.star,), color: Color(0xFFFFFFD5), onPressed: (){ futureMessage = PostStoryFavoriteCreateDelete(snapshot.data!.data![index].id.toString()); ScaffoldMessenger.of(context).showSnackBar(SnackBar(elevation: 20,content: FutureBuilder( future: futureMessage, builder: (context, snapshot){ if (snapshot.hasData)…

VIEW QUESTION
Back To Top
Search