【问题标题】:Flutter Firebase Realtime Database MissingPluginExceptionFlutter Firebase 实时数据库 MissingPluginException
【发布时间】:2022-08-05 21:05:01
【问题描述】:

我正在尝试将用户数据添加到我的实时数据库中,如下所示:

submitForm(String username, String email, String password) async {
    final auth = FirebaseAuth.instance;
    UserCredential userCredential;
    try {
      if (_isLoginPage) {
        userCredential = await auth.signInWithEmailAndPassword(
            email: email, password: password);
      } else {
        userCredential = await auth.createUserWithEmailAndPassword(
            email: email, password: password);
        String uid = userCredential.user.uid;
        await FirebaseFirestore.instance.collection(\'users\').doc(uid).set({
          \'username\': username,
          \'email\': email,
        });
        DatabaseReference ref = FirebaseDatabase.instance.ref(\'users\');
        await ref.push().set({
          \'username\': username,
          \'email\': email,
        }).asStream();
      }
    } catch (err) {
      print(\'zort\');
      print(err);
    }
  }

将数据添加到 Firestore 和 Firebase Auth 效果很好,但我在实时数据库步骤中收到此错误: MissingPluginException(No implementation found for method DatabaseReference#set on channel plugins.flutter.io/firebase_database)

我尝试了所有常见的东西,例如flutter pub getflutter clean,但似乎没有任何效果。

标签: android flutter firebase dart google-cloud-firestore


【解决方案1】:

在答案部分发表上述评论,

您能否尝试使用link 升级flutter,然后再试一次,您也可以参考stackoverflow URL

【讨论】:

    猜你喜欢
    • 2021-04-22
    • 2020-09-13
    • 2021-07-01
    • 2021-04-09
    • 2021-10-19
    • 2021-03-04
    • 2020-08-13
    • 2021-02-06
    • 2022-01-21
    相关资源
    最近更新 更多