【发布时间】:2021-05-31 07:54:02
【问题描述】:
我正在开发一个 Flutter 应用程序,我是新手,但我正在取得进展。但是,我遇到以下错误:
错误:不能将参数类型“Stream”分配给参数类型“Stream”。 “流”来自“飞镖:异步”。 “用户”来自“包:firebase_auth/firebase_auth.dart” 值:AuthServices().user,
下面是我的 main.dart 代码
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return StreamProvider<UserModel>.value(
value: AuthServices().user,
child: MaterialApp(
home: WelcomeScreen(),
routes: {
WelcomeScreen.id: (context) => WelcomeScreen(),
LoginScreen.id: (context) => LoginScreen(),
RegistrationScreen.id: (context) => RegistrationScreen(),
ModuleScreen.id: (context) => ModuleScreen(),
LectureListScreen.id: (context) => LectureListScreen(),
SettingsScreen.id: (context) => SettingsScreen(),
ResetPasswordScreen.id: (context) => ResetPasswordScreen(),
ChangePasswordScreen.id: (context) => ChangePasswordScreen(),
ChangeEmailScreen.id: (context) => ChangeEmailScreen(),
PracticalListScreen.id: (context) => PracticalListScreen(),
TestingListScreen.id: (context) => TestingListScreen(),
TestScreen.id: (context) => TestScreen(),
},
));
}
}
这是我的 UserModel.dart 代码
class UserModel {
final String uid;
final bool isAnonymous;
UserModel({this.uid, this.isAnonymous});
}
class UserData {
final String uid;
final String email;
final String firstName;
final String patronymic;
final String lastName;
final String studentID;
UserData(
{this.uid,
this.email,
this.firstName,
this.patronymic,
this.lastName,
this.studentID});
}
我已经尝试了所有可能的方法,也上网查看了但找不到问题所在。但是,我认为这与我在调用 Authservices 或解析它以便它可以接受参数时无法获得正确的“上下文”有关。
在这种情况下,通过指出我做错了什么以及我需要做些什么来解决这个问题,我们将不胜感激。
谢谢你的期待
【问题讨论】:
-
AuthServices().user的类型是什么?是User,对吧?我想说错误信息很清楚。
标签: firebase flutter dart firebase-authentication