I have this method:
Future<AppUser> _getUser(String documentId) async {
var document = await firestore.collection('customers').doc(documentId);
document.get().then((DocumentSnapshot documentSnapshot) {
print(documentSnapshot.data());
});
AppUser bruceUser = AppUser(userId: 'user006',);
return bruceUser;
}
And below it, I have a variable that uses this method:
AppUser _user = await _getUser(document.id);
However, this returns the following error:
Error: 'await' can only be used in 'async' or 'async*' methods.
What am I doing wrong here? I don't want to change _user to Future, because it will complicate the code further, so why doesn't the await work?