I'm trying to use a StreamBuilder in conjunction with a ListView.builder to display data stored in an array on firebase.
I've tried using the code below to access the array but I really don't know what I'm doing wrong.
class Home extends StatelessWidget {
#override
Widget build(BuildContext context) {
return StreamBuilder<List<Beacon>>(
stream: DatabaseService().beacons,
builder: (context, snapshot) {
return BeaconList(),
}
);
}
}
class BeaconList extends StatefulWidget {
#override
_BeaconListState createState() => _BeaconListState();
}
class _BeaconListState extends State<BeaconList> {
#override
Widget build(BuildContext context) {
final beacons = Provider.of<List<Beacon>>(context) ?? [];
return ListView.builder(
itemCount: beacons.length,
itemBuilder: (context, index) {
return BeaconTile(beacon: beacons[index]);
},
);
}
}
class BeaconTile extends StatefulWidget {
final Beacon beacon;
BeaconTile({this.beacon});
#override
_BeaconTileState createState() => _BeaconTileState();
}
class _BeaconTileState extends State<BeaconTile> {
#override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.only(top: 8),
child: Card(
margin: EdgeInsets.fromLTRB(20, 6, 20, 0),
child: ListTile(
leading: CircleAvatar(
radius: 25,
backgroundColor: widget.beacon.bid Colors.green[400],
),
title: Text("Connection made"),
subtitle: Text("ID: ${widget.beacon.bid}"),
),
),
);
}
}
class Beacon {
String bid;
Beacon({this.bid});
}
final DocumentReference beaconCollection = Firestore.instance.collection("LocationData").document("BeaconData");
List<Beacon> _beaconListFromSnapshot(DocumentSnapshot snapshot) {
List<Beacon> beaconList = [];
for (int i = 0; i < snapshot.data.length; i++) {
print(i);
beaconList.add(Beacon(bid: snapshot.data[i]));
}
return beaconList;
}
Stream<List<Beacon>> get beacons {
return beaconCollection.get()
.then((snapshot) {
try {
return _beaconListFromSnapshot(snapshot);
} catch(e) {
print(e.toString());
return null;
}
}).asStream();
}
Running the above code I get the error:
I/flutter (30206): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (30206): The following ProviderNotFoundException was thrown building BeaconList(dirty, state:
I/flutter (30206): _BeaconListState#6361b):
I/flutter (30206): Error: Could not find the correct Provider<List<Beacon>> above this BeaconList Widget
I/flutter (30206):
I/flutter (30206): This likely happens because you used a `BuildContext` that does not include the provider
I/flutter (30206): of your choice. There are a few common scenarios:
I/flutter (30206):
I/flutter (30206): - The provider you are trying to read is in a different route.
I/flutter (30206):
I/flutter (30206): Providers are "scoped". So if you insert of provider inside a route, then
I/flutter (30206): other routes will not be able to access that provider.
I/flutter (30206):
I/flutter (30206): - You used a `BuildContext` that is an ancestor of the provider you are trying to read.
I/flutter (30206):
I/flutter (30206): Make sure that BeaconList is under your MultiProvider/Provider<List<Beacon>>.
I/flutter (30206): This usually happen when you are creating a provider and trying to read it immediately.
I/flutter (30206):
I/flutter (30206): For example, instead of:
I/flutter (30206):
I/flutter (30206): ```
I/flutter (30206): Widget build(BuildContext context) {
I/flutter (30206): return Provider<Example>(
I/flutter (30206): create: (_) => Example(),
I/flutter (30206): // Will throw a ProviderNotFoundError, because `context` is associated
I/flutter (30206): // to the widget that is the parent of `Provider<Example>`
I/flutter (30206): child: Text(context.watch<Example>()),
I/flutter (30206): ),
I/flutter (30206): }
I/flutter (30206): ```
I/flutter (30206):
I/flutter (30206): consider using `builder` like so:
I/flutter (30206):
I/flutter (30206): ```
I/flutter (30206): Widget build(BuildContext context) {
I/flutter (30206): return Provider<Example>(
I/flutter (30206): create: (_) => Example(),
I/flutter (30206): // we use `builder` to obtain a new `BuildContext` that has access to the provider
I/flutter (30206): builder: (context) {
I/flutter (30206): // No longer throws
I/flutter (30206): return Text(context.watch<Example>()),
I/flutter (30206): }
I/flutter (30206): ),
I/flutter (30206): }
I/flutter (30206): ```
I/flutter (30206):
I/flutter (30206): If none of these solutions work, consider asking for help on StackOverflow:
I/flutter (30206): https://stackoverflow.com/questions/tagged/flutter
I/flutter (30206):
I/flutter (30206): The relevant error-causing widget was:
I/flutter (30206): BeaconList file:///F:/apps/rivi_mvp/lib/screens/home/home.dart:43:19
I/flutter (30206):
I've tried a lot of different things but I don't think I understand StreamBuilders and Providers and streams enough to find a solution. Any Solutions or insights would be greatly appreciated.
So after messing about with this for 2 days I have found a solution that works for me.
By replacing the StreamBuilder with a StreamProvider<List<Beacon>>.value this allowed me to access the data appropriately from the BeaconList widget tree using
final beacons = Provider.of<List<Beacon>>(context) ?? [];.
In terms of the actual stream - I had data in the Firestore that in code was written as
{Beacons: [{bid: "1234",}, {bid: "2345",}, {bid: "3456",}]}.
So for the code for the stream, to format this data I used
List<Beacon> _beaconListFromSnapshot(QuerySnapshot snapshot) {
List<Beacon> x = [];
return snapshot.documents.map((doc) {
for (Map data in doc.data["Beacons"]) {
x.add(Beacon(bid: data["bid"],));
}
return x;
}).toList()[0];
}
Stream<List<Beacon>> get brews {
return beaconCollection.snapshots().map(_beaconListFromSnapshot);
}
If anyone can come up with a more efficient or more eloquent solution or pointers towards one then I would be very grateful.
Related
I'm trying to display all object list from cloud storage with Flutter + Firebase.
I created the function for getting Future of all list of object URL in the bucket like this.
Future<List> _video_list() async {
List video_list = ['!!For Debug!!'];
firebase_storage.ListResult result = await firebase_storage
.FirebaseStorage.instance
.ref().child('test_videos').listAll();
Future.forEach(result.items,(firebase_storage.Reference ref) {
firebase_storage.FirebaseStorage.instance
.ref(ref.fullPath)
.getDownloadURL()
.then((v) {
video_list.add(v);
print('-------------------------');
print(video_list);
});
});
return video_list;
}
And the code for display is this.
class _VideoInList extends StatefulWidget {
#override
_VideoInListState createState() => _VideoInListState();
}
class _VideoInListState extends State<_VideoInList> {
#override
Widget build(BuildContext context) {
List video_list = [];
return FutureBuilder(
future: _video_list(),
builder: (context, snapshot) {
print('***************************');
List vl = snapshot.data as List;
num vll = vl.length;
print(vl);
print(vll);
print('***************************');
return ListView(
children: <Widget>[
for (int i = 0; i < vll; i++)
new GestureDetector(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) {
return VideoPlayPage();
}));
},
child:
Card(
child: Column(children: <Widget>[
Column(
children: <Widget>[
ListTile(
leading: Icon(Icons.cake),
title: Text(vl[i]),
),
Stack(
alignment: FractionalOffset.bottomRight +
const FractionalOffset(-0.1, -0.1),
children: <Widget>[
Text(
'Place : \n Date Time : \n Club : \n Video Length : \n'),
]),
],
),
])),
),
],
);
},
);
}
The console log is below. (URL is masked)
I/flutter (30430): ***************************
I/flutter (30430): [!!For Debug!!]
I/flutter (30430): 1
I/flutter (30430): ***************************
I/flutter (30430): -------------------------
I/flutter (30430): [!!For Debug!!, <Object URL1>]
I/flutter (30430): -------------------------
I/flutter (30430): [!!For Debug!!, <Object URL1>, <Object URL2>]
I/flutter (30430): -------------------------
I/flutter (30430): [!!For Debug!!, <Object URL1>, <Object URL2>, <Object URL3>]
I/flutter (30430): -------------------------
I/flutter (30430): [!!For Debug!!, <Object URL1>, <Object URL2>, <Object URL3>, <Object URL4>]
It looks the object is added to list but return run before async process is completed.
How Can I return the fully list of objects.
Thank you for your help.
Try to use map
code
Future<List> _video_list() async {
List video_list = ['!!For Debug!!'];
firebase_storage.ListResult result = await firebase_storage
.FirebaseStorage.instance
.ref().child('test_videos').listAll();
await result.items.map((firebase_storage.Reference ref) {
firebase_storage.FirebaseStorage.instance
.ref(ref.fullPath)
.getDownloadURL()
.then((v) {
video_list.add(v);
print('-------------------------');
print(video_list);
});
});
return video_list;
}
Log
====================================================================================================
I/flutter (30430): ***************************
I/flutter (30430): [!!For Debug!!]
I/flutter (30430): 1
I/flutter (30430): ***************************
as #helloWorld mentioned you are not using await on forEach snippet.
Future<List> _video_list() async {
List video_list = ['!!For Debug!!'];
firebase_storage.ListResult result = await firebase_storage
.FirebaseStorage.instance
.ref()
.child('test_videos')
.listAll();
Future.forEach(result.items, (firebase_storage.Reference ref) async {
video_list.add(
await firebase_storage.FirebaseStorage.instance
.ref(ref.fullPath)
.getDownloadURL()
);
});
});
return video_list;
}
Either way you should avoid using forEach.. as dart recommendations: https://dart-lang.github.io/linter/lints/avoid_function_literals_in_foreach_calls.html
//you should avoid using forEach
Future<List> _video_list() async {
List video_list = ['!!For Debug!!'];
firebase_storage.ListResult results = await firebase_storage
.FirebaseStorage.instance
.ref()
.child('test_videos')
.listAll();
//dart supports for loops with async
for(final result in results){
video_list.add(
await firebase_storage.FirebaseStorage.instance
.ref(result.fullPath)
.getDownloadURL()
);
}
return video_list;
}
I am trying get User Name through a document stored in users collection in cloud firestore but my build method runs before the data is received.
The initState(){} method does not wait for uidDetails() to complete and therefore null values are passed in DoctorListStream(currentUserName) . Since the initState(){}` method cannot be made async I want to know what can be done to fix this. I have also tried to implement both StreamBuilder and FutureBuilder but failed.
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import '../components/doc_list_retriever.dart';
class ListOfDoctors extends StatefulWidget {
#override
_ListOfDoctorsState createState() => _ListOfDoctorsState();
}
class _ListOfDoctorsState extends State<ListOfDoctors> {
final _auth = FirebaseAuth.instance;
final _fStore = Firestore.instance;
String currentUserUid;
String currentUserName;
#override
void initState() {
// TODO: implement initState
super.initState();
uidDetails();
}
void uidDetails() async {
final FirebaseUser user = await _auth.currentUser();
currentUserUid = user.uid;
print(currentUserUid + 'from user details');
await Firestore.instance
.collection('users')
.document(currentUserUid)
.get()
.then((DocumentSnapshot) {
currentUserName = DocumentSnapshot.data['name'].toString();
});
print(currentUserName + ' from uid Details');
}
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFF1D1E33),
body: SafeArea(
child: Column(
children: <Widget>[
Text(
'Doctors:',
textAlign: TextAlign.left,
style: TextStyle(fontSize: 40, color: Colors.white70),
),
DoctorListStream(currentUserName),
],
),
),
);
}
}
CONSOLE :
Performing hot restart...
Syncing files to device AOSP on IA Emulator...
Restarted application in 848ms.
I/BiChannelGoogleApi(27263): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq#95a83d7
D/FirebaseAuth(27263): Notifying id token listeners about user ( 5TlH5zoCqfWDNDlAgvIsc5yAHPA3 ).
I/flutter (27263): 5TlH5zoCqfWDNDlAgvIsc5yAHPA3from user details
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following NoSuchMethodError was thrown building StreamBuilder<QuerySnapshot>(dirty, state: _StreamBuilderBaseState<QuerySnapshot, AsyncSnapshot<QuerySnapshot>>#044e7):
The method '+' was called on null.
Receiver: null
Tried calling: +(" from doctor list stream")
The relevant error-causing widget was:
StreamBuilder<QuerySnapshot> file:///D:/projects/clinic/lib/components/doc_list_retriever.dart:14:12
When the exception was thrown, this was the stack:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 DoctorListStream.build.<anonymous closure> (package:clinic/components/doc_list_retriever.dart:26:27)
#2 StreamBuilder.build (package:flutter/src/widgets/async.dart:509:81)
#3 _StreamBuilderBaseState.build (package:flutter/src/widgets/async.dart:127:48)
#4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4623:28)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (27263): Dhruv from uid Details
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
A RenderFlex overflowed by 99670 pixels on the bottom.
The relevant error-causing widget was:
Column file:///D:/projects/clinic/lib/screens/list_of_doctors.dart:43:16
════════════════════════════════════════════════════════════════════════════════════════════════════
I would opt to using a stream builder to get the user data. sample implementation
String username;
body: StreamBuilder(
stream: Firestore.instance
.collection('users')
.document(userid)
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return SpinKitDoubleBounce(
color: Colors.blue,
);
}
var userDoc = snapshot.data;
userName = userDoc["name"];
return .... //your other widgets
I have a test code bellow:
class SplashPageState extends State<SplashPage> {
Future<void> dummy() async {
print('Async function1');
Future.delayed(Duration.zero, () => print('Async function2'));
print('Async function3');
await Future.delayed(Duration.zero, () => print('Async function4'));
print('Async function5');
}
#override
void initState() {
print('initState 1');
super.initState();
print('initState 2');
Future.sync(() {
print('Future sync');
});
print('initState 3');
Future.delayed(Duration.zero, () {
print('Future value');
});
print('initState 4');
dummy();
print('initState 5');
}
#override
Widget build(BuildContext context) {
print('build');
return Scaffold(
appBar: AppBar(
title: Text('1'),
),
body: Text('2'),
);
}
}
Result:
I/flutter (16218): initState 1
I/flutter (16218): initState 2
I/flutter (16218): Future sync
I/flutter (16218): initState 3
I/flutter (16218): initState 4
I/flutter (16218): Async function1
I/flutter (16218): Async function3
I/flutter (16218): initState 5
I/flutter (16218): build
I/flutter (16218): Future value
I/flutter (16218): Async function2
I/flutter (16218): Async function4
I/flutter (16218): Async function5
I tested it 100 times and the order alway be the same with every build. Because of async programming, I wonder that "Is this order always keep every run?"
Flutter or should I say Dart is single Threaded programming and it works in the event loop mechanism.
So every time dart sees async function without await keyword it just goes and puts it in an event loop and after all current process finishes it comes back and revives that async function. If there is await keyword as you have before in print('Async function5'); it checks for event loop and revives previous stacks of events in sequence they were added with respect to delay.
Check for more details
There you can find all the details of how it works. also, don't forget to check out this videos
Flutter dev video
and how Isolates introduced
I am getting this error while trying to fetch user data from the cloud_firestore but it's only getting me this error when for the first time, users login to the app and navigate to the profile screen. if I hot restart or rerun the app, while in login state error goes away.
flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══
flutter: The following NoSuchMethodError was thrown building StreamBuilder<DocumentSnapshot>(dirty, state:
flutter: _StreamBuilderBaseState<DocumentSnapshot, AsyncSnapshot<DocumentSnapshot>>#f33a1):
flutter: The method '[]' was called on null.
flutter: Receiver: null
flutter: Tried calling: []("name")
flutter:
flutter: User-created ancestor of the error-causing widget was:
flutter: SliverFillRemaining
flutter: file:///Users/ishangavidusha/Development/MUD/mud_mobile_app/lib/screens/profile_screen.dart:102:13
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
flutter: #1 new User.from (package:mud_mobile_app/models/user_model.dart:23:22)
flutter: #2 _ProfileScreenState.build.<anonymous closure> (package:mud_mobile_app/screens/profile_screen.dart:107:38)
flutter: #3 StreamBuilder.build (package:flutter/src/widgets/async.dart:425:74)
flutter: #4 _StreamBuilderBaseState.build (package:flutter/src/widgets/async.dart:125:48)
flutter: #5 StatefulElement.build (package:flutter/src/widgets/framework.dart:4047:27)
flutter: #6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3941:15)
flutter: #7 Element.rebuild (package:flutter/src/widgets/framework.dart:3738:5)
flutter: #8 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2348:33)
flutter: #9 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:760:20)
flutter: #10 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:280:5)
flutter: #11 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1033:15)
flutter: #12 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:975:9)
flutter: #13 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:891:5)
flutter: #17 _invoke (dart:ui/hooks.dart:249:10)
flutter: #18 _drawFrame (dart:ui/hooks.dart:207:3)
flutter: (elided 3 frames from package dart:async)
Emulator Screenshot
And this is the user model I use >
class User {
final String id;
final String name;
final String profileImageUrl;
final String email;
User({this.id, this.name, this.profileImageUrl, this.email});
factory User.fromDoc(DocumentSnapshot doc) {
return User(
id: doc.documentID,
name: doc['name'],
profileImageUrl: doc['profileImageUrl'],
email: doc['email'],
);
}
}
FutureBuilder >
SliverFillRemaining(
child: FutureBuilder(
future: _getUserData(widget.userId),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (!snapshot.hasData) {
return Padding(
padding: const EdgeInsets.all(50.0),
child: Center(
child: CircularProgressIndicator(),
),
);
}
User user = User.fromDoc(snapshot.data);
return Column(
children: <Widget>[
Padding(...),
Container(...),
Container(...),
],
);
}
)
)
And the Funtion DocumentSnapshot return >
Future<DocumentSnapshot> _getUserData(userId) async {
return Firestore.instance.collection('users').document(userId).get();
}
"StreamBuilder dirty state" warnings are usually shown if the snapshot data doesn't have a safety check. This ensures that the snapshot contains data. However, it seems if (!snapshot.hasData) is set as a safety check on the snippet you've provided.
From the details you've given, the error seems to only occur during first user login, but the error goes away on hot restart or app restart. I suggest checking if the method _getUserData(String userId) is able to receive the userId upon the first user login where the error usually occurs. Null seems to be passed on where the error occurs based from the logs you've provided.
flutter: The method '[]' was called on null.
flutter: Receiver: null
flutter: Tried calling: []("name")
FutureBuilder<DocumentSnapshot>(
future: users.doc(documentId).get(),
builder:
(BuildContext context, AsyncSnapshot<DocumentSnapshot> snapshot) {
if (snapshot.hasError) {
return Text("Something went wrong");
}
if (snapshot.hasData && !snapshot.data!.exists) {
return Text("Document does not exist");
}
if (snapshot.connectionState == ConnectionState.done) {
Map<String, dynamic> data = snapshot.data!.data() as Map<String, dynamic>;
return Text("Full Name: ${data['full_name']} ${data['last_name']}");
}
return Text("loading");
If you are using above similar type code and then get same error , check the firebase documentId in collection name and snapshot
I have made a simple baby names project using firebase on flutter,
after successfully going throught the tutorial, the app gives this error : " package:firebase_demo/main.dart': Failed assertion: line 86 pos 16: 'map['votes] ! = null': is not true. "
Help for the same.
MY CODE -:
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
final dummySnapshot = [
{"name": "Filip", "votes": 15},
{"name": "Abraham", "votes": 14},
{"name": "Richard", "votes": 11},
{"name": "Ike", "votes": 10},
{"name": "Justin", "votes": 1},
];
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Baby Names',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
#override
_MyHomePageState createState() {
return _MyHomePageState();
}
}
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Baby Name Votes')),
body: _buildBody(context),
);
}
Widget _buildBody(BuildContext context) {
return StreamBuilder<QuerySnapshot>(
stream: Firestore.instance.collection('baby').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return LinearProgressIndicator();
return _buildList(context, snapshot.data.documents);
},
);
}
Widget _buildList(BuildContext context, List<DocumentSnapshot> snapshot) {
return ListView(
padding: const EdgeInsets.only(top: 20.0),
children: snapshot.map((data) => _buildListItem(context, data)).toList(),
);
}
Widget _buildListItem(BuildContext context, DocumentSnapshot data) {
final record = Record.fromSnapshot(data);
return Padding(
key: ValueKey(record.name),
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.circular(5.0),
),
child: ListTile(
title: Text(record.name),
trailing: Text(record.votes.toString()),
onTap: () => print(record),
),
),
);
}
}
class Record {
final String name;
final int votes;
final DocumentReference reference;
Record.fromMap(Map<String, dynamic> map, {this.reference})
: assert(map['name'] != null),
assert(map['votes'] != null),
name = map['name'],
votes = map['votes'];
Record.fromSnapshot(DocumentSnapshot snapshot)
: this.fromMap(snapshot.data, reference: snapshot.reference);
#override
String toString() => "Record<$name:$votes>";
}
Output :
Performing hot restart...
Syncing files to device Redmi Note 4...
Restarted application in 1,994ms.
I/flutter ( 2257): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 2257): The following assertion was thrown building StreamBuilder(dirty, state:
I/flutter ( 2257): _StreamBuilderBaseState>#94c3a):
I/flutter ( 2257): 'package:firebase_demo/main.dart': Failed assertion: line 86 pos 16: 'map['votes'] != null': is not
I/flutter ( 2257): true.
I/flutter ( 2257):
I/flutter ( 2257): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter ( 2257): more information in this error message to help you determine and fix the underlying cause.
I/flutter ( 2257): In either case, please report this assertion by filing a bug on GitHub:
I/flutter ( 2257): https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter ( 2257):
I/flutter ( 2257): When the exception was thrown, this was the stack:
I/flutter ( 2257): #2 new Record.fromMap (package:firebase_demo/main.dart:86:16)
I/flutter ( 2257): #3 new Record.fromSnapshot (package:firebase_demo/main.dart:91:14)
I/flutter ( 2257): #4 _MyHomePageState._buildListItem (package:firebase_demo/main.dart:59:27)
I/flutter ( 2257): #5 _MyHomePageState._buildList. (package:firebase_demo/main.dart:54:40)
I/flutter ( 2257): #6 MappedListIterable.elementAt (dart:_internal/iterable.dart:414:29)
I/flutter ( 2257): #7 ListIterable.toList (dart:_internal/iterable.dart:219:19)
I/flutter ( 2257): #8 _MyHomePageState._buildList (package:firebase_demo/main.dart:54:71)
I/flutter ( 2257): #9 _MyHomePageState._buildBody. (package:firebase_demo/main.dart:46:16)
I/flutter ( 2257): #10 StreamBuilder.build (package:flutter/src/widgets/async.dart:423:74)
I/flutter ( 2257): #11 _StreamBuilderBaseState.build (package:flutter/src/widgets/async.dart:125:48)
I/flutter ( 2257): #12 StatefulElement.build (package:flutter/src/widgets/framework.dart:3809:27)
I/flutter ( 2257): #13 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3721:15)
I/flutter ( 2257): #14 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 2257): #15 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2286:33)
I/flutter ( 2257): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:676:20)
I/flutter ( 2257): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter ( 2257): #18 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter ( 2257): #19 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter ( 2257): #20 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter ( 2257): #21 _invoke (dart:ui/hooks.dart:154:13)
I/flutter ( 2257): #22 _drawFrame (dart:ui/hooks.dart:143:3)
I/flutter ( 2257): (elided 2 frames from class _AssertionError)
I/flutter ( 2257): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/1.gpu ( 2257): type=1400 audit(0.0:191179): avc: denied { ioctl } for path="/dev/kgsl-3d0" dev="tmpfs" ino=15394 ioctlcmd=945 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1
I/1.gpu ( 2257): type=1400 audit(0.0:191180): avc: denied { read write } for path="/dev/kgsl-3d0" dev="tmpfs" ino=15394 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1
I/an.firebasedem( 2257): Waiting for a blocking GC ProfileSaver
I/an.firebasedem( 2257): WaitForGcToComplete blocked ProfileSaver on ProfileSaver for 30.771ms
Maybe you can check your collection name in the firebase first.
stream: Firestore.instance.collection('your_collection_name_here').snapshots(),
Make sure your fields in the Firebase match with the proprieties of Record.
e.g:
name matches name field from the database
votes matches votes field from the database