How to Handle Firebase Auth exceptions on flutter

前端 未结 12 1091
走了就别回头了
走了就别回头了 2020-11-30 07:56

Please does anyone know how to catch firebase Auth exceptions on flutter and display them?

Note: I am not interested in the console (catcherror((e) print(e))

12条回答
  •  执念已碎
    2020-11-30 08:32

       try {
      final newuser = await _auth.createUserWithEmailAndPassword(
          email: emailController.text, password: passwordController.text);
      // print("Done");
    } catch (e) {
      print(e);
      showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: new Text(e.message),
            actions: [
              FlatButton(
                child: new Text("OK"),
                onPressed: () {
                  Navigator.of(context).pop();
                },
              ),
            ],
          );
        },
      );
    }
    

提交回复
热议问题