Reputation: 541
Heres when the error acquired, I wanted to change screen if the process is success and stayed if the process failed
Status() {
String rawJson =
LG();
Map<String, dynamic> map = jsonDecode(rawJson);
String status = map["STATUS"];
if (status == "Success") {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (_) => SPAL()),
(Route<dynamic> route) => false,
);
} else {
print("Failed");
}
}
here's where the it is executed
ButtonWidget(
text: 'Submit',
onClicked: () async {
if (_emailing.currentState.validate() &&
_passwd.currentState.validate()) {
Status();
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('email', emailController.text);
}
},
),
Upvotes: 0
Views: 443
Reputation: 742
Don't return Navigator.pushAndRemoveUntil()
and add the build context as param: Status(context)
Upvotes: 1