본문 바로가기

[flutter, firebase] 핵심만 콕콕!! 플러터와 파이어베이스 세팅하기 with Firebase CLI 사용

ironwhale 2022. 3. 21.

Firebase CLI를 사용하면 쉽게 플러터 앱과 파이어 베이스를 연결 할 수 있습니다. 

기존 여러 강의에서는 수동으로 설정하는 방법은 많이 소개하는데 Firebase CLI를 이용하여 연결하는 방법을 별로 없더군요. 사실 공식 문서를 보면 쉽게 할수 있지만 복습하는 의미에서 한번 써보도록 하겠습니다. 

 


참조한 사이트를 Firebase CLI 사이트: https://firebase.google.com/docs/cli

 

Firebase CLI 참조  |  Firebase Documentation

Firebase.Installations

firebase.google.com

플러터와 파이어베이스에 관한 사이트     : https://firebase.flutter.dev/docs/overview/

 

FlutterFire Overview | FlutterFire

<img

firebase.flutter.dev

 

 


1. 필요한 패키지 설치   : 파이어 베이스 코어 설치  firebase_core: ^1.13.1

2. Firebase CLI 설치하고  파이어 베이스 프로젝트 만들기

3.  터미널을 통해 프로젝트 폴더를 들어간뒤 flutterfire configure를 입력합니다.

      이러면 터미널에 나오는 안내가 나오는데  모든 절차를 진행하면 쉽게 파이어 베이스와 프로젝트가 연결이 됩니다. 

4.  아마도 아래와 같은 화면이 나올 것입니다. 

flutterfire configure
i Found 6 Firebase projects.
✔ Select a Firebase project to configure your Flutter application with · abc-project (abc-project) 
✔ Which platforms should your configuration support (use arrow keys & space to select)? · android, ios 
i Firebase android app com.abc.abc.acb is not registered on Firebase project abc-project.
i Registered a new Firebase android app on Firebase project abc-project.
✔ Which ios bundle id do you want to use for this configuration, e.g. 'com.example.app'? · com.abc.abc 
i Firebase ios app com.abc.abc is not registered on Firebase project abc-project.
i Registered a new Firebase ios app on Firebase project abc-project.

Firebase configuration file lib/firebase_options.dart generated successfully with the following Firebase apps:

5.   위에  절차가 끝나고 나면 lib/firebase_options.dart 파일 생성되고 드디어 파이어베이스를 사용할 첫단계가 시작됩니다. 

6. 그리고 나면 아래 코드로  초기화를 진행합니다. 

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
  runApp(MyApp());
}

이제 파이어스토어, Authentication 등 각종 파이어베이스 서비스를 이용할 준비가 끝났습니다. 

 

 

마지막으로 제가 만든 주식 물타기 계산기 앱 홍보입니다. 

https://play.google.com/store/apps/details?id=com.honey.bitcoin_calc 

 

My Stock Average Calculator - Google Play 앱

내 주식 평균 계산기는 주식의 평균 가격을 계산합니다

play.google.com

 

댓글