Firebase로 회원을 생성하고 로그인 하고, 다른 페이지에 currentUser로 해당 사용자의 정보를 쓸수 있다.
최소한의 예제이니 그냥 main함수에 때려넣음;;;
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
final _authentification = FirebaseAuth.instance;
String userEmail = "test@email.com";
String userPassword = "12345678";
// 새로운 사용자 생성
//final UserCredential newUser = await _authentification.createUserWithEmailAndPassword(email: userEmail, password: userPassword);
//로그인
final UserCredential user = await _authentification.signInWithEmailAndPassword(email: userEmail, password: userPassword);
// 현재 사용자
print(_authentification.currentUser);
}
파이어베이스 콘솔에서 확인하자.
'flutter > 기타' 카테고리의 다른 글
Getx - Reactive State manager 방식들 (0) | 2023.09.04 |
---|---|
Flutter를 Chrome에서 실행할 때 생기는 Cors문제 회피 (0) | 2023.08.13 |
infinite scroll 구현 - 패키지 예제 단순화 함 (0) | 2023.08.13 |
RenderBox was not laid out: RenderRepaintBoundary 에러 (2) | 2022.05.19 |