简体   繁体   中英

Flutter Firebase Realtime Database MissingPluginException

I'm trying to add user data to my Realtime Database like this:

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);
    }
  }

Adding the data to Firestore and Firebase Auth works perfectly but I get this error on the Realtime Database step: MissingPluginException(No implementation found for method DatabaseReference#set on channel plugins.flutter.io/firebase_database)

I tried all the usual stuff like flutter pub get and flutter clean but nothing seems to work.

Posting above comment in the answer section,

Can you please try to upgrade flutter with link and try again also you can refer the stackoverflow URL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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