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

courses/flutter-firebase/topics-screen/ #717

Open
utterances-bot opened this issue Mar 31, 2022 · 5 comments
Open

courses/flutter-firebase/topics-screen/ #717

utterances-bot opened this issue Mar 31, 2022 · 5 comments

Comments

@utterances-bot
Copy link

Topics Grid

Use a GridView to display a Firestore collection query

https://fireship.io/courses/flutter-firebase/firestore-data-model/

Copy link

This video ends with i'm going to create TopicItem but never showed how or at least the code for the file.
Not a big deal because it's on github but a strange ending.
https://github.com/fireship-io/flutter-firebase-quizapp-course/blob/master/lib/topics/topic_item.dart

@OberstVonGatow
Copy link

🙈 should have just watched the next video...

Copy link

Independently of the TopicItem Widget or if you are rendering a Text Widget, you will probably face an issue when mapping the topics variable with the error:

" The method 'map' isn't defined for the type 'Object' "

It means, when setting the var topics, dart could not infer the type of its result. The instructor can correct me, please, that would be much appreciated.

I solved that by force casting the result of the data as the same as the getTopics method as below.

var topics = snapshot.data! as List;

With that you can map topics to the Text or Custom Widget of your preference.

topics.map((topic) => Text(topic.title)).toList()

Copy link

in case of "failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}", go to firestore rules and set "allow read, write: if true;"

@gael1130
Copy link

gael1130 commented Aug 2, 2022

Independently of the TopicItem Widget or if you are rendering a Text Widget, you will probably face an issue when mapping the topics variable with the error:

" The method 'map' isn't defined for the type 'Object' "

It means, when setting the var topics, dart could not infer the type of its result. The instructor can correct me, please, that would be much appreciated.

I solved that by force casting the result of the data as the same as the getTopics method as below.

var topics = snapshot.data! as List;

With that you can map topics to the Text or Custom Widget of your preference.

topics.map((topic) => Text(topic.title)).toList()

@tappella I had the same issue, then saw the quick fix (ctrl + ;): add the models file.

import '../services/models.dart';

Once that file is imported, it will recognize that you defined the result of Topic in models.dart.
I hope that helps

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

5 participants