코딩/Flutter
Flutter : Firebase(파이어베이스) 연동하기
americanoallday
2025. 7. 18. 18:32
파이어베이스 들어가서 프로젝트 새로 만들고 플러터 아이콘 클릭해서 Firebase CLI 설치 및 로그인 진행
(설치 경로 메모 :-- Setting permissions on binary... /usr/local/bin/firebase)
FlutterFire CLI 설치하고, IDE에서 플러터 프로젝트 열고 터미널에 2번에 뜨는 명령어 연동 필요
3번은 나는 지피티가 알려준거 main.dart에 추가함.
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart'; // flutterfire configure가 만든 파일
void main() async {
WidgetsFlutterBinding.ensureInitialized(); // Flutter 준비 대기
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Firebase 연동 앱',
home: Scaffold(
appBar: AppBar(title: Text('Firebase 연결 성공')),
body: Center(child: Text('Hello Firebase!')),
),
);
}
}