Background
I am trying to fetch a booking document from Firestore inside the initState() method of my State.
This is also my first time using flutter/dart, so apologies if I am making a very rookie mistake.
Problem
When I run the get() method, an async function that returns a Future<DocumentSnapshot>, an error is thrown. I am trying to catch and handle this error. The error is an 'insufficient permissions' error which I intend to get.
My code
class _MyHomePageState extends State<MyHomePage> {
final firestoreInstance = Firestore.instance;
Future<DocumentSnapshot> _futureBooking;
@override
void initState() {
super.initState();
try {
_futureBooking = firestoreInstance
.collection('bookings')
.document('1Twgjq5YTe3Oa12wwbs1')
.get();
} catch (err) {
print("error fetching from firestore: $err");
}
}
Results
The catch block is never entered, and the app always crashes when making the get() call.
Any help would be appreciated!
