In my flutter
app I'm building a scrollable list filled with data from FireBase. So far my code looks as follows:
class FollowersListState extends State<FollowersUsersList> {
@override
Widget build(BuildContext context) {
return StreamBuilder<QuerySnapshot>(
stream: Firestore.instance.collection('user').where("author", isEqualTo: getUserEmail()).snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return CupertinoActivityIndicator();
return _buildList(context, snapshot.data.docs);
},
);
}
In the code above there is this line:
where("author", isEqualTo: getUserEmail())
getUserEmail()
is a method that takes the user's email from local shared preferences:
Future<String> getUserEmail() async {
final prefs = await SharedPreferences.getInstance();
return prefs.getString('loginEmail');
}
but - as you can see - it returns the Future<String>
instead of String
, so I cannot use it in my implementation in the StreamBuilder<QuerySnapshot>
. What is the best way to handle it in that case?
Thanks!