ive been having probem with pulling data out from firebase, currently it keeps returning me Instance of 'Future<String?>' instead of a String of "Patient" or "Physiotherapist", may i know what's the issue?
class Wrapper extends StatefulWidget {
@override
_WrapperState createState() => _WrapperState();
}
class _WrapperState extends State<Wrapper> {
Future<String?> getUserType(String uid) async {
try {
DocumentSnapshot _docSnapShot = await FirebaseFirestore.instance.collection('users').doc(uid).get();
var userType = await ( _docSnapShot.data() as dynamic)['userType'];
print(userType);
return await userType;
} catch (e) {
print(e);
}
}
@override
Widget build(BuildContext context) {
final user = Provider.of<CustomUser?>(context);
//return either Home or Authenticate widget
if ( user == null) {
print("this");
return Authenticate();
} else if (getUserType(user.uid) == "Patient") {
print('this happens');
return PatientHome();
} else {
print(getUserType(user.uid).toString() + "this thing");
return PhysioHome();
}
}
}