카테고리 없음

Flutter에 Firebase 추가하기

얼룩와와 2025. 4. 22. 17:22

flutterfire 설치하기

Firebase CLI reference 문서를 참고하였다. firebase cli를 standalone binary로 설치해서 사용하고 싶었지만 계속해서 FlutterFire configure CLI requires the official Firebase CLI 에러가 발생해서 어쩔 수 없이 npm을 통해 설치하는 방법을 따랐다.

 

 

nvm 설치

nvm windown에서 nvm-setup.exe 설치 후 실행npm은 같이 설치된다더니 이상하게 npm install -g firebase-tools 수행하니 npm을 못찾길래 관리자 권한으로 CMD 실행하니 됨. CMD에서 `nvm install 23` 실행 (23은 원하는 npm 버전)

 

 

firebase configure

다운로드 받아두었던 firebase-tool-instant-win.exe를 켜서 프로젝트 폴더로 간 후 `fireflutter configure` 수행하니 이제 잘됨.

 

 

`firebase_options.dart` 파일이 lib 폴더에 생성되지 않는 현상

아래와 같이 없는 firebase 프로젝트를 전부 선택(android, ios, macos, web)하니 파일이 제대로 생성되지 않는 것을 확인할 수 있었다.

> flutterfire configure
i Found 1 Firebase projects.
✔ Select a Firebase project to configure your Flutter application with · babylingual-33707 (babylingual)
✔ Which platforms should your configuration support (use arrow keys & space to select)? · android, ios, macos, web, windows
i Firebase android app com.illegirl.flash_card registered.
i Firebase ios app com.example.flashCard registered.
i Firebase macos app com.example.flashCard registered.
i Firebase web app flash_card (web) registered.
type 'Null' is not a subtype of type 'String' in type cast

 

아래와 같이 android만 선택 후 파일이 제대로 생성된 것을 확인할 수 있었다.

> flutterfire configure
i Found 1 Firebase projects.
✔ Select a Firebase project to configure your Flutter application with · babylingual-33707 (babylingual)
✔ Which platforms should your configuration support (use arrow keys & space to select)? · android
i Firebase android app <appId> registered.

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

Platform  Firebase App Id
android   <appId>

Learn more about using this file and next steps from the documentation:
 > https://firebase.google.com/docs/flutter/setup