如何修改 flutter firebase-ui 屏幕中的错误消息?

问题描述 投票:0回答:1

我正在使用这里的官方 firebase-ui 示例: https://github.com/firebase/flutterfire/tree/master/packages/firebase_ui_auth/example

当我的云函数返回错误时,该错误会明确显示在 UI 中:

相反,我想根据收到的错误修改消息以使其更加用户友好。不幸的是,我还没有找到一种方法来做到这一点。有人可以帮忙吗?

flutter firebase firebase-authentication firebaseui
1个回答
0
投票

现在有一种方法可以自定义任何错误消息。

API文档:

示例:

ErrorText.localizeError = (BuildContext context, FirebaseAuthException e) {
  // I'm assuming this should be the code, but it might be different
  if (e.code == -47) return 'Custom message goes here';
  
  final defaultLabels = FirebaseUILocalizations.labelsOf(context);
  return localizedErrorText(e.code, defaultLabels);
}
© www.soinside.com 2019 - 2024. All rights reserved.