I have a question about using Shared_Preferences in Flutter.
My problem is that Shared_Preferences works fine in the Emulator,
but I don't even get a Shared_Preferences object when I actually connect my phone to the next line.
void initState() {
// TODO: implement initState
(() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
bool res = prefs.getBool('autoLoginKey');
String id = prefs.getString('autoLoginId');
String pw = prefs.getString('autoLoginPw');
Navigator.push(
context, // ?? ????, SecondRoute? ??
MaterialPageRoute(
builder: (context) =>
MainPage()) // SecondRoute? ???? ??
);
}
}
else {
Timer(Duration(seconds: 1), () {
Navigator.pushReplacement(context, MaterialPageRoute(
builder: (context) => LoginMainScreen()
)
);
});
}
})();
super.initState();
}
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/nZZSC.png
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…