강의

멘토링

커뮤니티

Inflearn Community Q&A

kimjin51732173's profile image
kimjin51732173

asked

Coding Netflix UI Clone with Flutter + Firebase [Just Flutter]

Connecting Flutter and Firebase - 2) Writing Flutter Code

snapshot.data 오류

Written on

·

2.5K

1

error: The argument type 'Map<String, dynamic> Function()' can't be assigned to the parameter type 'Map<String, dynamic>'. (argument_type_not_assignable at [netflix_clone_test] lib/model/model_movie.dart:17)

snapshot.data 자체에 오류가 발생하는데 원인 파악을 못하겠습니다..ㅜㅠ

Flutterfirebase클론코딩

Answer 6

6

import 'package:cloud_firestore/cloud_firestore.dart';

class Movie {
final String title;
final String keyword;
final String poster;
final bool like;
final DocumentReference? reference;

Movie.fromMap(Map<String, dynamic> map, {this.reference})
: title = map['title'],
keyword = map['keyword'],
poster = map['poster'],
like = map['like'];

Movie.fromSnapshow(DocumentSnapshot snapshot)
: this.fromMap(snapshot.data() as Map<String, dynamic>,
reference: snapshot.reference);

@override
String toString() => 'Movice<$title:$keyword>';
}

찾았네요 ~휴~

0

yaml 파일에서 cloud_firestore: 0.13.7 로 맞추시고 하시면 됩니다. ( 맨위 이주석님 말씀대로 버전문제같아서 버전을 구버전으로 설정했습니다.)  

0

이주석님의 방식으로 바꿨더니 저는 해결되었습니다~

0

이주석님 그거로 해결이 되었나요 ?ㅜ

0

snapshot.data()   이렇게 해도 되네요 ㅎㅎ

0

snapshot.data 자체 오류 저도 걸리는데. 그게 pubspec.yaml 에서 cloud_firestore 버전 문제일겁니다. 버전 업데이트 되면서 Firestore -> FirebaseFireStore 로 바뀌고 여러가지가 바뀌었더라구요. stackoverflow 참고해서 진행하셔야할듯 합니다. 

kimjin51732173's profile image
kimjin51732173

asked

Ask a question