请帮帮我我不知道这段代码有什么问题:试图让用户密码存储在首选项,但geting errot这是我尝试的代码
'package:shared_preferences/shared_preferences.dart';
class AuthenticationPinBloc extends Bloc<AuthenticationPinEvent, AuthenticationPinState> {
final PINRepository pinRepository;
isUserloggedIn() async {
// Obtain shared preferences.
final prefs = await SharedPreferences.getInstance();
var passcode = prefs.getString('status');
}
AuthenticationPinBloc({required this.pinRepository}) : super(const AuthenticationPinState(pinStatus: AuthenticationPINStatus.enterPIN)) {
on<AuthenticationPinAddEvent>((event, emit) async {
String pin = "${state.pin}${event.pinNum}";
if(pin.length < 6){
emit(AuthenticationPinState(pin: pin, pinStatus: AuthenticationPINStatus.enterPIN));
}
// match pin with store data from SharedPreferences
else if (pin == passcode){
print(passcode);
emit(AuthenticationPinState(pin: pin, pinStatus: AuthenticationPINStatus.equals));
In the line (pin == passcode) I get an error:
print passcode also has error am new to Flutter
will be very glad to get help
1条答案
按热度按时间bqf10yzr1#
密码可能为null,对吧?我想你可以空头支票。
就像遵循的代码。
我不确定这个解决方案。另外,需要您的错误信息。