본문 바로가기
Development Solutions/Flutter & Dart

[flutter] How to get information of current user stored in firebase (firebase에 저장된 현재 유저의 정보를 얻는 방법)

by studio ODOC 2021. 11. 26.
반응형

 

문제 상황 (problem situation)

 

firebase_auth 버전에 따라 current user 정보를 가져오는 과정이 다릅니다.

(The process of getting current user information differs depending on the firebase_auth version.)

 

 

 

 

해결 방법 (Resolution)

 

> firebase_auth v0.18.0 이후 (Since firebase_auth v0.18.0)

final FirebaseAuth auth = FirebaseAuth.instance;

void inputData() {
  final User user = auth.currentUser;
  final uid = user.uid;
  // here you write the codes to input the data into firestore
}

 

 

> firebase_auth v0.18.0 이전 (before firebase_auth v0.18.0)

final FirebaseAuth auth = FirebaseAuth.instance;

Future<void> inputData() async {
  final FirebaseUser user = await auth.currentUser();
  final uid = user.uid;
  // here you write the codes to input the data into firestore
}

 

 

 

 

관련 검색 결과 (Related Search Results)

https://www.google.com/search?q=flutter+firebase+currentUser&rlz=1C1IBEF_koKR957KR957&oq=flutter+firebase+currentUser&aqs=chrome..69i57.2631j0j7&sourceid=chrome&ie=UTF-8 

 

flutter firebase currentUser - Google 검색

2021. 11. 6. · Flutter plugin for Firebase Auth, enabling Android and iOS authentication ... BREAKING: Accessing the current user via currentUser() is now ...

www.google.com

 

반응형