How can I handle the errors and show the loading progress of the data upload. I am new on flutter.
floatingActionButton: FloatingActionButton(
onPressed: () async {
newHome = Home(
urlPhotohome: urlPhotohome,
urlPhotoStreet: urlPhotoStreet,
dateTime: DateTime.now(),
isFavorite: false);
await FirebaseFirestore.instance
.collection('city')
.doc(userId)
.collection('home')
.add(newHome.toMap());
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Home save"),
duration: Duration(milliseconds: 900),
),
);
},
backgroundColor: Colors.blueGrey,
child: const Icon(Icons.save),
),