1. firestore 버전 업 (pubspec.yaml)
# Add the dependency for the Firebase Core Flutter SDK
firebase_core: ^1.2.1
cloud_firestore: ^2.2.1
2. main.dart 에서
Firebase.initializeApp();
import 'package:flutter/material.dart';
import 'package:flutter_netflix_clone/screen/home_screen.dart';
import 'package:flutter_netflix_clone/screen/more_screen.dart';
import 'package:flutter_netflix_clone/widget/bottom_bar.dart';
import 'package:firebase_core/firebase_core.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late TabController controller;
@override
Widget build(BuildContext context) {
Firebase.initializeApp();
3. home screnn에서
class _HomeScreenState extends State<HomeScreen> {
FirebaseFirestore firestore = FirebaseFirestore.instance;
4. model_movie.dart 에서
class Movie {
final String title;
final String keyword;
final String poster;
final bool like;
final DocumentReference reference;
Movie.fromMap(Map<String, dynamic> map, {required this.reference})
: title = map['title'],
keyword = map['keyword'],
poster = map['poster'],
like = map['like'];
Movie.fromSnapShot(DocumentSnapshot snapshot)
: this.fromMap(snapshot.data() as Map<String, dynamic>, reference: snapshot.reference);
5. build.gradle 설정
build.gradle은 아래 링크참고
https://duzi077.tistory.com/198
답글
안녕하세요 혹시 이런 에러는 안생기셨나요???
기능동작은 정상적인데 디버그 콘솔에는 에러가 계속 뜨네요..
답글