I'm writing data to Firestore Using this function - which works perfectly
Future<void> validateForm() async {
try {
await FirebaseFirestore.instance.collection('collectionPath').add({
'full_name': 'John Doe',
'company': 'Stokes and Sons',
'age': '42',
});
ScaffoldMessenger.of(context).showSnackBar(successSnackBar);
} catch (e) {
print(e.toString());
ScaffoldMessenger.of(context).showSnackBar(errorSnackBar);
}
}
but I'm trying to display a SnackBar when data can't be written to FireStore
- currently if I switch my simulator to Airplane Mode the
successSnackBardoes not show - which is what I want
But I would also like the errorSnackBar to pop-up too which does not happen