Macchiato
Macchiato

Reputation: 541

The argument type 'JsObject' can't be assigned to the parameter type 'BuildContext'

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

Answers (1)

krumpli
krumpli

Reputation: 742

Don't return Navigator.pushAndRemoveUntil() and add the build context as param: Status(context)

Upvotes: 1

Related Questions