我正在使用以下代码:
Widget build(BuildContext context) {
AuthNotifier authNotifier =
Provider.of<AuthNotifier>(context, listen: true);
final firestoreService = FirestoreService();
return MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => ProductProvider(),
),
StreamProvider(
create: (context) =>
firestoreService.getProducts(authNotifier.user.uid),
catchError: (context, error) {
print(
'mensagem no stream provider catch error : ${error.toString()}');
},
),
],
child: MaterialApp(
home: Products(),
),
);
}
}
我不确定是否可以执行以下操作:
StreamProvider(
create: (context) =>
firestoreService.getProducts(authNotifier.user.uid),
由于userUid为null,我收到了错误消息。