I want to get the current uid of user with flutter.
I have tried following but returns an error
final FirebaseAuth auth = FirebaseAuth.instance;
void inputData() {
final User user = auth.currentUser;
final uid = user.uid;
print(uid);
// here you write the codes to input the data into firestore
}
Error:
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
[core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()
Firebase has now been updated and requires you to initialize Firebase before using any firebase products. Also make sure your pubspec.yaml file has firebase_core:
dependencies:
flutter:
sdk: flutter
firebase_core : ^0.5.0
And mainly initialize Firebase in your main function of main.dart
Firebase.initializeApp();