Reputation: 33
I got the error after follow the tutorial of Firebase for Flutter: https://codelabs.developers.google.com/codelabs/flutter-firebase/#4.
I'm using Andriod Studio 4.0.1.
dev_dependencies:
flutter_test:
sdk: flutter
cloud_firestore: ^0.14.0+2
Error:
lib/main.dart:84:31: Error: The argument type 'Map<String, dynamic> Function()' can't be assigned to the parameter type 'Map<String, dynamic>'.
- 'Map' is from 'dart:core'.
: this.fromMap(snapshot.data, reference: snapshot.reference);
^
Solution from @Peter Haddad:
this.fromMap(snapshot.data(), reference: snapshot.reference);
Another Error:
The following FirebaseException was thrown building MyHomePage(dirty, state: _MyHomePageState#257aa):
[core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()
The relevant error-causing widget was:
MyHomePage file:///D:/Private/Project/workspace_flutter/baby_names/lib/main.dart:12:13
When the exception was thrown, this was the stack:
#0 MethodChannelFirebase.app (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:118:5)
#1 Firebase.app (package:firebase_core/src/firebase.dart:52:41)
#2 FirebaseFirestore.instance (package:cloud_firestore/src/firestore.dart:43:21)
#3 Firestore.instance (package:cloud_firestore/src/firestore.dart:246:30)
#4 _MyHomePageState._buildBody (package:baby_names/main.dart:35:25)
Upvotes: 0
Views: 491
Reputation: 80904
You are using a new version of cloud firestore. Therefore you have to do the following now:
this.fromMap(snapshot.data(), reference: snapshot.reference);
Upvotes: 1