我是flutter的新手,我只是按照firebase登录flutter-bloc教程为我的应用程序做同样的操作,
一切顺利,除了第一个屏幕加载。
home: BlocBuilder<AuthBloc, AuthState>(
builder: (context, state) {
if (state is Uninitialized) { <=== return regardless of the state
return WelcomeScreen();
} else if (state is Unauthenticated) { <=== return regardless of the state
return LoginScreen(userRepository: _userRepository);
} else if (state is Authenticated) {
return HomeScreen( <=== return regardless of the state
user: state.user,
homeRepository: _homeRepository,
userRepository: _userRepository,
);
}
return WelcomeScreen();
},
if 条件返回每个屏幕而不考虑状态,如果满足状态条件,它应该打破条件并只返回一个小部件。但这里不是这样,它返回的每个屏幕都很奇怪。
谢谢