【问题标题】:Flutter Firebase reload - No implementation for method User#reloadFlutter Firebase 重新加载 - 方法 User#reload 没有实现
【发布时间】:2021-11-03 15:16:45
【问题描述】:

我的应用可与 Firebase 和 Flutter 搭配使用。启动 reload() 时,出现此错误:

“在通道 plugins.flutter.io/firebase_auth 上找不到方法 User#reload 的实现”

所有其他 firebase 功能都有效,multidexEnabled 为 true

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(MyApp());
} 

方法:

  Future<bool> reloadFirebase({required BuildContext context}) async {
    bool _isUserStillConnected = true;
    try {
      await _firebaseAuth.currentUser?.reload();
      User? _user = currentUser;
      if(_user == null) {
        _isUserStillConnected = false;
        showDisconnectedDialog(context: context);
      }
    } on FirebaseAuthException catch(e) {
      _isUserStillConnected = false;
      showDisconnectedDialog(context: context);
    }
    return _isUserStillConnected;
  }

打电话:

ListTile(
  onTap: () async {
    bool _isUserStillConnected = await AuthenticationProvider().reloadFirebase(context: context);
    if(_isUserStillConnected) {
      Navigator.of(context).pushNamed(
        PAGE_ROOM,
        arguments: _roomModels[index],
      );
    }
  },

【问题讨论】:

    标签: firebase flutter dart firebase-authentication


    【解决方案1】:

    该错误表明身份验证出现问题,因此请尝试以下可能的解决方案:

    • 确保您已在 Firebase 控制台的身份验证选项卡中正确设置了注册方法
    • 根据您在 yaml 文件中的 FB 版本,确保导入 firebase_core
    • 检查插件冲突/尝试使用来自 pub.dev 的最新版本
    • 如果它必须与 reload() 函数做某事,也许从这里尝试解决方案,因为它可能更适合您的情况:https://stackoverflow.com/a/64899979/15117201

    【讨论】:

      猜你喜欢
      • 2018-12-27
      • 2014-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-21
      • 2011-04-14
      • 2021-08-21
      • 2014-12-08
      相关资源
      最近更新 更多