I'm using flutter and I am trying to get a value from shared_preferences for firebase.
i checked my cord doesn't work and uid was " Instance of 'Future' ".
the solution i found was using setState but i can't use that because it's not in Widget build.
in this situation, how can i get value(uid) instead of Instance of 'Future'
class MyItemProvider with ChangeNotifier {
String uid = '';
Future<void> getUid() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
uid = await prefs.getString('uid')!;
}
late CollectionReference itemsReference;
List<Item> items = [];
List<Item> find_result = [];
MyItemProvider({reference}) {
getUid();
itemsReference = reference ?? FirebaseFirestore.instance.collection(uid);
}
...
...
...
i try to use setState i checked 'print(uid);' was Instance of 'Future'