简体   繁体   English

如何处理 Firebase flutter 上的 Auth 异常

[英]How to Handle Firebase Auth exceptions on flutter

Please does anyone know how to catch firebase Auth exceptions on flutter and display them?请有人知道如何在 flutter 上捕获 firebase 身份验证异常并显示它们吗?

Note: I am not interested in the console (catcherror((e) print(e))注意:我对控制台不感兴趣 (catcherror((e) print(e))

I need something that is more effective, eg " user doesn't exist" So that I can then pass it to a string and display it.我需要一些更有效的东西,例如“用户不存在”,这样我就可以将它传递给一个字符串并显示它。

Been dealing with this for months.几个月来一直在处理这个问题。

Thanks in advance.提前致谢。

I have tried replacing print(e) with // errorMessage=e.toString();我尝试用 // errorMessage=e.toString(); 替换 print(e); and then passing it to a function, all efforts have been futile.然后传给一个function,一切努力都是徒劳。

    FirebaseAuth.instance
              .signInWithEmailAndPassword(email: emailController.text, password: passwordController.text)
              .then((FirebaseUser user) {
                _isInAsyncCall=false;
            Navigator.of(context).pushReplacementNamed("/TheNextPage");

          }).catchError((e) {
           // errorMessage=e.toString();
            print(e);
            _showDialog(errorMessage);

            //exceptionNotice();
            //print(e);

I want to be able to extract the exception message and pass the exception message to a dialog that I can then display to the user.我希望能够提取异常消息并将异常消息传递给一个对话框,然后我可以将该对话框显示给用户。

I just coded myself a way to do this without Platform dependent Code:我只是为自己编写了一种无需平台相关代码即可执行此操作的方法:

This is possible since .signInWithEmailAndPassword correctly throws Errors with defined codes, that we can grab to identify the error and handle things in the way the should be handled.这是可能的,因为 .signInWithEmailAndPassword 正确抛出带有定义代码的错误,我们可以抓住这些代码来识别错误并以应该处理的方式处理事情。

The following example creates a new Future.error, if any error happens, and a Bloc is then configured to shovel that data through to the Widget.如果发生任何错误,以下示例将创建一个新的 Future.error,然后配置一个 Bloc 将该数据铲到 Widget。

Future<String> signIn(String email, String password) async {
  FirebaseUser user;
  String errorMessage;

  try {
    AuthResult result = await _firebaseAuth.signInWithEmailAndPassword(email: email, password: password);
    user = result.user;
  } catch (error) {
    switch (error.code) {
      case "ERROR_INVALID_EMAIL":
        errorMessage = "Your email address appears to be malformed.";
        break;
      case "ERROR_WRONG_PASSWORD":
        errorMessage = "Your password is wrong.";
        break;
      case "ERROR_USER_NOT_FOUND":
        errorMessage = "User with this email doesn't exist.";
        break;
      case "ERROR_USER_DISABLED":
        errorMessage = "User with this email has been disabled.";
        break;
      case "ERROR_TOO_MANY_REQUESTS":
        errorMessage = "Too many requests. Try again later.";
        break;
      case "ERROR_OPERATION_NOT_ALLOWED":
        errorMessage = "Signing in with Email and Password is not enabled.";
        break;
      default:
        errorMessage = "An undefined Error happened.";
    }
  }

  if (errorMessage != null) {
    return Future.error(errorMessage);
  }

  return user.uid;
}

NEW ANSWER (18/09/2020)新答案 (18/09/2020)

If you are using firebase_auth: ^0.18.0 , error codes have changed!如果您使用firebase_auth: ^0.18.0 ,错误代码已更改!

For instance: ERROR_USER_NOT_FOUND is now user-not-found例如: ERROR_USER_NOT_FOUND现在是user-not-found

I could not find any documentation about that, so I went into the source code and read comments for every error codes.我找不到任何关于它的文档,所以我进入了源代码并阅读了每个错误代码的注释。 (firebase_auth.dart) (firebase_auth.dart)

I don't use all error codes in my app (eg verification, password reset...) but you will find the most common ones in this code snippet:我不会在我的应用程序中使用所有错误代码(例如验证、密码重置...),但您会在此代码片段中找到最常见的错误代码:

(It handles old and new error codes) (它处理旧的和新的错误代码)

String getMessageFromErrorCode() {
    switch (this.errorCode) {
      case "ERROR_EMAIL_ALREADY_IN_USE":
      case "account-exists-with-different-credential":
      case "email-already-in-use":
        return "Email already used. Go to login page.";
        break;
      case "ERROR_WRONG_PASSWORD":
      case "wrong-password":
        return "Wrong email/password combination.";
        break;
      case "ERROR_USER_NOT_FOUND":
      case "user-not-found":
        return "No user found with this email.";
        break;
      case "ERROR_USER_DISABLED":
      case "user-disabled":
        return "User disabled.";
        break;
      case "ERROR_TOO_MANY_REQUESTS":
      case "operation-not-allowed":
        return "Too many requests to log into this account.";
        break;
      case "ERROR_OPERATION_NOT_ALLOWED":
      case "operation-not-allowed":
        return "Server error, please try again later.";
        break;
      case "ERROR_INVALID_EMAIL":
      case "invalid-email":
        return "Email address is invalid.";
        break;
      default:
        return "Login failed. Please try again.";
        break;
    }
  }

(21/02/20) EDIT: This answer is old and the other answers contains cross platform solutions so you should look at theirs first and treat this as a fallback solution. (21/02/20) 编辑:这个答案很旧,其他答案包含跨平台解决方案,所以你应该先看看他们的解决方案并将其视为后备解决方案。

The firebase auth plugin doesn't really have a proper cross-platform error code system yet so you have to handle errors for android and ios independently. firebase auth 插件还没有真正的跨平台错误代码系统,因此您必须独立处理 android 和 ios 的错误。

I'm currently using the temporary fix from this github issue:#20223我目前正在使用这个 github 问题的临时修复:#20223

Do note since its a temp fix, don't expect it to be fully reliable as a permanent solution.请注意,因为它是临时修复,不要指望它作为永久解决方案是完全可靠的。

enum authProblems { UserNotFound, PasswordNotValid, NetworkError }

try {
  FirebaseUser user = await FirebaseAuth.instance.signInWithEmailAndPassword(
      email: email,
      password: password,
  );
} catch (e) {
  authProblems errorType;
  if (Platform.isAndroid) {
    switch (e.message) {
      case 'There is no user record corresponding to this identifier. The user may have been deleted.':
        errorType = authProblems.UserNotFound;
        break;
      case 'The password is invalid or the user does not have a password.':
        errorType = authProblems.PasswordNotValid;
        break;
      case 'A network error (such as timeout, interrupted connection or unreachable host) has occurred.':
        errorType = authProblems.NetworkError;
        break;
      // ...
      default:
        print('Case ${e.message} is not yet implemented');
    }
  } else if (Platform.isIOS) {
    switch (e.code) {
      case 'Error 17011':
        errorType = authProblems.UserNotFound;
        break;
      case 'Error 17009':
        errorType = authProblems.PasswordNotValid;
        break;
      case 'Error 17020':
        errorType = authProblems.NetworkError;
        break;
      // ...
      default:
        print('Case ${e.message} is not yet implemented');
    }
  }
  print('The error is $errorType');
}

in Auth Class have this function:在 Auth 类中有这个功能:

Future signUpWithEmailAndPassword(String email, String password) async {
    try {
      AuthResult result = await _auth.createUserWithEmailAndPassword(
        email: email,
        password: password,
      );
      FirebaseUser user = result.user;
      return user;
    } catch (e) {
      return e;
    }
  }

The catch error above returns a runTimeType of PlatformException and a PlatformException in flutter has 3 properties check here !上面的 catch 错误返回了 PlatformException 的 runTimeType,flutter 中的 PlatformException 在这里检查3 个属性!


in your Dart file, implement this on button listeners:在您的 Dart 文件中,在按钮侦听器上实现此功能:

String error = "";

dynamic result = await _auth.signUpWithEmailAndPassword(email, password);

if (result.runtimeType == PlatformException) {
    if (result.message != null) {
        setState(() {
            error = result.message;
        });
    } else {
        setState(() {
            error = "Unknown Error";
        });
    }
}

Expanding on the accepted answer I thought it's worth to mention that:扩展已接受的答案,我认为值得一提的是:

  1. The firebase_auth plugin has AuthException .firebase_auth插件有AuthException。
  2. As pointed out in this Github issue post you can have the same error codes for Android and iOS.正如这篇Github 问题帖子中所指出的,您可以在 Android 和 iOS 上使用相同的错误代码。
  3. If you have this code in a non-UI layer you can use rethrow or better throw your own formatted exceptions and catch those at the UI level (where you'll know exactly the kind of error you'll get).如果您在非 UI 层中有此代码,则可以使用rethrow或更好地抛出您自己的格式化异常并在 UI 级别捕获它们(您将确切地知道将得到的错误类型)。

try {
  AuthResult authResult = await FirebaseAuth.instance.signInWithCredential(credential);
  // Your auth logic ...
} on AuthException catch (e) {
  print('''
    caught firebase auth exception\n
    ${e.code}\n
    ${e.message}
  ''');

  var message = 'Oops!'; // Default message
  switch (e.code) {
    case 'ERROR_WRONG_PASSWORD':
      message = 'The password you entered is totally wrong!';
      break;
    // More custom messages ...
  }
  throw Exception(message); // Or extend this with a custom exception class
} catch (e) {
  print('''
    caught exception\n
    $e
  ''');
  rethrow;
}

in Dart you can react to different Exceptions using the on syntax.在 Dart 中,您可以使用on语法对不同的异常做出反应。 Since Firebase uses its own PlatformException you can easily catch them with:由于 Firebase 使用自己的 PlatformException,您可以通过以下方式轻松捕获它们:

  try {
      AuthResult result = await signUp(email, password);
  } on PlatformException catch (e) {
      print(e.message);
  } on Exception catch (e) {
      print(e);
  }

PlatformException brings a code as well as a message which can be displayed in the UI, ie : PlatformException 带来了可以在 UI 中显示的代码和消息,即:

PlatformException(ERROR_EMAIL_ALREADY_IN_USE, The email address is already in use by another account., null)

I was stuck on this for a while too, i created this gist with all the available errors here with an example, covers all the platform exception codes我被困在这一段时间也一样,我创造了这个要点所有可用的错误, 在这里有一个例子,涵盖了所有的平台异常代码

Example for handling sign up exceptions处理注册异常的示例

Future<String> signUp(String email, String password, String firstName) async {
  FirebaseUser user;

  try {
    AuthResult result = await _auth.createUserWithEmailAndPassword(
        email: email, password: password);
    user = result.user;
    name = user.displayName;
    email = user.email;

    Firestore.instance.collection('users').document(user.uid).setData({
      "uid": user.uid,
      "firstName": firstName,
      "email": email,
      "userImage": userImage,
    });
  } catch (error) {
    switch (error.code) {
      case "ERROR_OPERATION_NOT_ALLOWED":
        errorMessage = "Anonymous accounts are not enabled";
        break;
      case "ERROR_WEAK_PASSWORD":
        errorMessage = "Your password is too weak";
        break;
      case "ERROR_INVALID_EMAIL":
        errorMessage = "Your email is invalid";
        break;
      case "ERROR_EMAIL_ALREADY_IN_USE":
        errorMessage = "Email is already in use on different account";
        break;
      case "ERROR_INVALID_CREDENTIAL":
        errorMessage = "Your email is invalid";
        break;

      default:
        errorMessage = "An undefined Error happened.";
    }
  }
  if (errorMessage != null) {
    return Future.error(errorMessage);
  }

  return user.uid;
}

Example for handling sign in exceptions处理登录异常的示例

Future<String> signIn(String email, String password) async {
  FirebaseUser user;
  try {
    AuthResult result = await _auth.signInWithEmailAndPassword(
        email: email, password: password);
    user = result.user;
    name = user.displayName;
    email = user.email;
    userId = user.uid;
  } catch (error) {
    switch (error.code) {
      case "ERROR_INVALID_EMAIL":
        errorMessage = "Your email address appears to be malformed.";
        break;
      case "ERROR_WRONG_PASSWORD":
        errorMessage = "Your password is wrong.";
        break;
      case "ERROR_USER_NOT_FOUND":
        errorMessage = "User with this email doesn't exist.";
        break;
      case "ERROR_USER_DISABLED":
        errorMessage = "User with this email has been disabled.";
        break;
      case "ERROR_TOO_MANY_REQUESTS":
        errorMessage = "Too many requests. Try again later.";
        break;
      case "ERROR_OPERATION_NOT_ALLOWED":
        errorMessage = "Signing in with Email and Password is not enabled.";
        break;
      default:
        errorMessage = "An undefined Error happened.";
    }
  }
  if (errorMessage != null) {
    return Future.error(errorMessage);
  }

  return user.uid;
}

the exceptions can be handled using, FirebaseAuthException class.可以使用 FirebaseAuthException 类处理异常。

Here's the code for login using email and password:这是使用电子邮件和密码登录的代码:

void loginUser(String email, String password) async {
    try {
      await _auth.signInWithEmailAndPassword(email: email, password:password);
    } on FirebaseAuthException catch (e) {
      // Your logic for Firebase related exceptions
    } catch (e) {
    // your logic for other exceptions!
}

You can use your own logic to handle the error, eg show a alert dialog, etc. Same can be done for creating a user.您可以使用自己的逻辑来处理错误,例如显示警报对话框等。创建用户时也可以这样做。

I manage the firebase auth exception with the exceptions codes of the version我使用版本的异常代码管理 firebase 身份验证异常

firebase_auth: ^3.3.6
firebase_core: ^1.12.0

This is the code that work for me:这是对我有用的代码:

Future<void> loginWithEmailAndPassword({
required String email,
required String password,
}) async {
try {
  await _firebaseAuth.signInWithEmailAndPassword(
      email: email, password: password);
} on firebase_auth.FirebaseAuthException catch (e) {
  switch (e.code) {
    case "invalid-email":
      //Thrown if the email address is not valid.
      throw InvalidEmailException();
    case "user-disabled":
      //Thrown if the user corresponding to the given email has been disabled.
      throw UserDisabledException();
    case "user-not-found":
      //Thrown if there is no user corresponding to the given email.
      throw UserNotFoundException();
    case "wrong-password":
      throw PasswordExceptions();
    //Thrown if the password is invalid for the given email, or the account corresponding to the email does not have a password set.
    default:
      throw UncknownAuthException();
  }
 }
}

And I create the exceptions to control the messeges to display in the UI later like this:我创建了异常来控制稍后在 UI 中显示的消息,如下所示:

class AuthenticationException implements Exception {}
class InvalidEmailException extends AuthenticationException {}
class PasswordExceptions extends AuthenticationException {}
class UserNotFoundException extends AuthenticationException {}
class UserDisabledException extends AuthenticationException {}
class UncknownAuthException extends AuthenticationException {}

Hope it help to someone having problems to handle auth exceptions!希望它对处理身份验证异常有问题的人有所帮助!

I prefer to create api layer response and error models and wrap the firebase plugin error and response objects in them.我更喜欢创建 api 层响应和错误模型,并将 firebase 插件错误和响应对象包装在其中。 For sign in with email and password i have this对于使用电子邮件和密码登录,我有这个

@override
  Future<dynamic> loginWithEmailAndPassword(String email, String password) async {
    try {
      await _firebaseAuth.signInWithEmailAndPassword(
          email: email, password: password);
      return FirebaseSignInWithEmailResponse();
    } catch (exception) {
      return _mapLoginWithEmailError(exception);
    }
  }

  ApiError _mapLoginWithEmailError(PlatformException error) {
    final code = error.code;
    if (code == 'ERROR_INVALID_EMAIL') {
      return FirebaseSignInWithEmailError(
          message: 'Your email is not valid. Please enter a valid email',
          type: FirebaseSignInWithEmailErrorType.INVALID_EMAIL);
    } else if (code == 'ERROR_WRONG_PASSWORD') {
      return FirebaseSignInWithEmailError(
          message: 'Your password is incorrect',
          type: FirebaseSignInWithEmailErrorType.WRONG_PASSWORD);
    } else if (code == 'ERROR_USER_NOT_FOUND') {
      return FirebaseSignInWithEmailError(
          message: 'You do not have an account. Please Sign Up to'
              'proceed',
          type: FirebaseSignInWithEmailErrorType.USER_NOT_FOUND);
    } else if (code == 'ERROR_TOO_MANY_REQUESTS') {
      return FirebaseSignInWithEmailError(
          message: 'Did you forget your credentials? Reset your password',
          type: FirebaseSignInWithEmailErrorType.TOO_MANY_REQUESTS);
    } else if (code == 'ERROR_USER_DISABLED') {
      return FirebaseSignInWithEmailError(
          message: 'Your account has been disabled. Please contact support',
          type: FirebaseSignInWithEmailErrorType.USER_DISABLED);
    } else if (code == 'ERROR_OPERATION_NOT_ALLOWED') {
      throw 'Email and Password accounts are disabled. Enable them in the '
          'firebase console?';
    } else {
      return FirebaseSignInWithEmailError(
          message: 'Make sure you have a stable connection and try again'
          type: FirebaseSignInWithEmailErrorType.CONNECTIVITY);
    }
  }

I never return the AuthResult from firebase.我从不从AuthResult返回AuthResult Instead i listen to the onAuthStateChanged stream and react accordingly if there is a change.相反,我会聆听onAuthStateChanged流并在发生变化时做出相应的反应。

I have the same error of "firebse platform exeption:" in flutter using "Firebase auth" and it didn't resolve even using try catch and trim() method in passing arrguments.我在使用“Firebase auth”的颤动中遇到了相同的“firebse platform exeption:”错误,即使在传递参数时使用 try catch 和 trim() 方法也无法解决。

The problem is when you run app using Button "Run" in main.dart it won't callback and catch the error.问题是当您在 main.dart 中使用按钮“运行”运行应用程序时,它不会回调并捕获错误。

Solution: In Vscode terminal type "Flutter run" (for debug mode).解决方案:在 Vscode 终端中输入“Flutter run”(用于调试模式)。 or "Flutter run --release" (for release mode) now you won't face platform exception.或“Flutter run --release”(用于发布模式)现在您不会遇到平台异常。

I had an issue where I didn't want the "com.google.firebase.FirebaseException: An internal error has occurred. [ Unable to resolve host "www.googleapis.com":No address associated with hostname ]" which would indicate to a user that the backend being used is firebase.我有一个问题,我不希望出现“com.google.firebase.FirebaseException:发生内部错误。[无法解析主机“www.googleapis.com”:没有与主机名关联的地址]”,这表明正在使用的后端是 firebase 的用户。 Thus, I just used toString().replaceAll()因此,我只是使用 toString().replaceAll()

  Future<void> signIn() async {
final formState = _formkey.currentState;
var _date = DateTime.now();

if (formState!.validate()) {
  emailFocus!.unfocus();
  passwordFocus!.unfocus();
  formState.save();
  setState(() {
    isloading = true;
    _errorMessage = '';
  });
  try {
    UserCredential user = await _firebaseAuth.signInWithEmailAndPassword(
        email: _email, password: _password!);

    SharedPreferences prefs = await SharedPreferences.getInstance();
    prefs.setString('email', _email);

    await FirebaseFirestore.instance
        .collection('Users Token Data')
        .doc(user.user!.uid)
        .set({'Email': _email, 'Token': _token, 'Date': _date});

    Navigator.pushNamedAndRemoveUntil(
        context, RouteNames.homePage, (e) => false);
  } on FirebaseAuthException catch (e) {
    setState(() {
      isloading = false;
      _errorMessage = e.message.toString().replaceAll(
          'com.google.firebase.FirebaseException: An internal error has' +
              ' occurred. [ Unable to resolve host "www.googleapis.com":' +
              "No address associated with hostname ]",
          "Please Check Network Connection");
    });
    print(e.message);
  }
}

} } } }

Just incase if you don't wanna reveal too much information from the error message.以防万一,如果您不想从错误消息中透露太多信息。

I have also recently faced this error and, I have found out that the .catchError() callback wasn't being called in the debug mode (which is when you click the Run->Start Debugging button in VSCode).我最近也遇到了这个错误,我发现.catchError()回调没有在调试模式下被调用(当你在 VSCode 中点击Run->Start Debugging按钮时)。

However, when you type in flutter run -d , then, the .catchError() method gets called back as it is not in debug mode.但是,当您输入 flutter run -d 时, .catchError()方法会被回调,因为它不在调试模式下。

To get your preferred simulator's code paste this line of code in the terminal:要获得首选模拟器的代码,请在终端中粘贴以下代码行:

instruments -s devices

If that doesn't work, you can also try pasting this:如果这不起作用,您也可以尝试粘贴以下内容:

xcrun simctl list

The ```.catchError()`` method will get called unlike before and the code inside that will get executed as expected! ```.catchError()`` 方法将与之前不同地被调用,并且其中的代码将按预期执行!

Additionally, the app won't crash anymore with a PlatformException() and instead you will get a log like this one:此外,应用程序不会再因PlatformException()而崩溃,而是您将获得如下日志:

[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The getter 'uid' was called on null.
Receiver: null

I have been facing this problem in Google Sign In too, in which the .catchError() was not being called!我在 Google Sign In 中也.catchError()过这个问题,其中.catchError()没有被调用!

In conclusion, if you have some error with handling errors in Firebase Authentication, you should first try to first run in through the terminal.总之,如果您在处理 Firebase 身份验证中的错误时遇到一些错误,您应该首先尝试首先通过终端运行。 Thanks, and I hope this helps!谢谢,我希望这会有所帮助!

So I faced this issue today and instead of hardcoding the error messages to display, I decided to use string manipulations and I managed to get the message.所以我今天遇到了这个问题,而不是硬编码要显示的错误消息,我决定使用字符串操作并设法获取消息。

The goal was to get the message (everything after ] ).目标是获取消息(在]之后的所有内容)。 Example: get this => Password should be at least 6 characters from this => [firebase_auth/weak-password] Password should be at least 6 characters .示例:get this => Password should be at least 6 characters from this => [firebase_auth/weak-password] Password should be at least 6 characters

So using the exception from the try-catch, I converted it to string first, then replaced the first 14 characters (from '[' to '/') with nothing, so I was left with weak-password] Password should be at least 6 characters .因此,使用 try-catch 中的异常,我首先将其转换为字符串,然后将前 14 个字符(从 '[' 到 '/')替换为,所以我留下了弱密码] 密码至少应该是6 个字符

Then the split function with ']' pattern to search the remaining string for the ']' symbol and split the whole string into two with the index of the ']' symbol as the pivot.然后使用 ']' 模式的 split 函数在剩余的字符串中搜索 ']' 符号,并将整个字符串分成两部分,以 ']' 符号的索引为支点。 This returns a list with two Strings;这将返回一个包含两个字符串的列表; 'weak-password' and 'Password should be at least 6 characters' . 'weak-password''Password should be at least 6 characters' Use the index 1 to get the second string which is the error message.使用索引 1 获取作为错误消息的第二个字符串。

e.toString().replaceRange(0, 14, '').split(']')[1]

try this , i had the same proplem and this code worked with me试试这个,我有同样的问题,这段代码对我有用

catch (e) {
                        ScaffoldMessenger.of(context)
                            .showSnackBar(SnackBar(content: Text('Wrong UserName or Password')));
                      }

Firebase-Auth Latest version provides a simple way to get error code and error Messages using the following try catch statements: Firebase-Auth 最新版本提供了一种使用以下 try catch 语句获取错误代码和错误消息的简单方法:

try {
  await FirebaseAuth.instance.signInWithEmailAndPassword(
    email: "name@example.com",
    password: "SuperSecretPassword!"
  );
} on FirebaseAuthException catch  (e) {
  print('Failed with error code: ${e.code}');
  print(e.message);
}

Source: Firebase Documentation资料来源: Firebase 文档

This code will show a red snack bar that contains the exception cause like "User already in use by other account".此代码将显示一个红色小吃店,其中包含“用户已被其他帐户使用”之类的异常原因。

auth.createUserWithEmailAndPassword(
   email: email,
   password: password,
).onError((error,stackTrace){
   if(error.runtimeType == FirebaseAuthException) {
    ScaffoldMessenger.of(context).showSnackBar(
     SnackBar(
      content: Text(error.toString().replaceRange(0, 14, '').split(']')[1]),
      backgroundColor: Theme.of(context).colorScheme.error,
     ),
   );
  }
}
   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: <Widget>[
          FlatButton(
            child: new Text("OK"),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
        ],
      );
    },
  );
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM