Skip to content

Error in db.dart for Collection.streamDataΒ #11

@FireJuun

Description

@FireJuun

db.dart provides an excellent, abstract means to connect Firestore documents and collections to Flutter without all the boilerplate. However, I noticed a bug when working with streams in db.dart. When creating a stream collection, such as by calling:
StreamProvider<List<Example>>.value(value: Global.exampleRef.streamData())

...inside of a MultiProvider widget, you will get the following error message:

An exception was thrown by _MapStrean<QuerySnapshot, List> listened by StreamProvider<List>, but no 'catchError was provided.

Exception: type 'MappedListIterable<DocumentSnapshot, Example>' is not a subtype of type 'List'

In db.dart, Line 47 is missing a .toList() at the end:
Stream<List<T>> streamData() { return ref.snapshots().map((list) => list.documents.map((doc) => Global.models[T](doc.data) as T).toList()); }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions