Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I/flutter (22027): MissingPluginException(No implementation found for method DocumentReference#setData on channel plugins.flutter.io/cloud_firestore)

Future<void> _getUserData() async {
  final database = Firestore.instance;
  try {
    FirebaseUser _currentUser = await FirebaseAuth.instance.currentUser();
    String authid =_currentUser.uid;
    String email = _currentUser.email;
    Map<String, String> userData = {
      'AuthUserId':'$authid',
      'Email':'$email',
      'FullName': '',
      'MobileNum': '',
      'Address': '',
      'City/Village': '',
      'District': '',
      'State': '',
      'PinCode': '',
    };
   database.collection('UserData').add(userData).catchError((e) {
     print(e);
    });
 } catch (e) {
    print(e);
 }
}
@override
void initState() {
    super.initState();
    _getUserData();
  }

"I am trying to insert the data into the cloud firestore and i have called this function in initState() but i ham getting error as i have mentioned above

like image 994
Divyanshu Bhaskar Avatar asked Jan 25 '20 20:01

Divyanshu Bhaskar


2 Answers

for my case, I performed steps as below:

flutter clean
flutter packages get

uninstall app

update: /android/app/build.gradle

defaultConfig {
    ...
    multiDexEnabled true
}

run again.

hope this helps

like image 54
Mr Special Avatar answered Oct 05 '22 22:10

Mr Special


Make sure you are using the latest cloud_firestore version. Then execute:

flutter clean
flutter packages get

Update, Starting since cloud_firestore version 0.14.0:

setData() was replaced with set(). Other useful link:

The getter 'instance' isn't defined for the type 'Firestore'

like image 34
Peter Haddad Avatar answered Oct 05 '22 22:10

Peter Haddad