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
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
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With