找不到用户时显示snackBar

时间:2019-05-29 08:03:39

标签: firebase flutter dart firebase-authentication

当用户尝试登录而不使用Firebase在Flutter中创建帐户时显示小吃栏,我尝试了此操作并收到错误“ 未处理的异常 Scaffold.of()调用了上下文不包含脚手架。”

 logIn() async {
    if (formkey.currentState.validate()) {
      formkey.currentState.save();
      try {
        await _auth.signInWithEmailAndPassword(
            email: email, password: password);
        Navigator.push(
            context, MaterialPageRoute(builder: (context) => Home()));
      } catch (e) {
        if (e.code == "ERROR_USER_NOT_FOUND") {
          Scaffold.of(context).showSnackBar(new SnackBar(content: new Text("user not found create new account")));
        }
      }
    }
  }

0 个答案:

没有答案