无法将参数类型“JsObject”分配给参数类型“BuildContext”

时间:2021-06-04 07:08:28

标签: flutter dart

这里出现错误时,如果进程成功,我想改变屏幕,如果进程失败,我想停留

    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");
  }
}

这里是执行它的地方

ButtonWidget(
                text: 'Submit',
                onClicked: () async {
                  if (_emailing.currentState.validate() &&
                      _passwd.currentState.validate()) {
                    Status();
                    SharedPreferences prefs = await SharedPreferences.getInstance();
                    prefs.setString('email', emailController.text);
                  }
                },
              ),

1 个答案:

答案 0 :(得分:1)

不要返回 Navigator.pushAndRemoveUntil() 并将构建上下文添加为参数:Status(context)