Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading firebase #21

Open
jrheisler opened this issue Jan 26, 2021 · 2 comments
Open

Upgrading firebase #21

jrheisler opened this issue Jan 26, 2021 · 2 comments

Comments

@jrheisler
Copy link

jrheisler commented Jan 26, 2021

Lots to do to upgrade to the latest firebase. This one has me stumped. The Collection method:

Stream<List> streamData() {
return ref.snapshots().map((list) => list.documents.map((doc) => Global.modelsT as T) );
}
gives:
Expected a value of type 'Map<dynamic, dynamic>', but got one of type '() => Map<String, dynamic>'

@jrheisler
Copy link
Author

As always, the second you give you, you find your problem. It's in the fromMap(data) end. Data is now a method, so it gets read:

name: data()['name'] ?? '',

@T3Drones
Copy link

T3Drones commented May 2, 2021

Hello, so for this project specifically.....if you are trying to update to the current version of firebase it is important to place the parenthesis for data method in your Globals.dart

OLD

  // Data Models
  static final Map models = {
    Topic: (data) => Topic.fromMap(data),
    Quiz: (data) => Quiz.fromMap(data),
    Report: (data) => Report.fromMap(data)
  };

NEW

  // Data Models
  static final Map models = {
    Topic: (data) => Topic.fromMap(data()),
    Quiz: (data) => Quiz.fromMap(data()),
    Report: (data) => Report.fromMap(data())
  };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants