0
StreamBuilder(
                       stream: reffVehicles.child('users').orderByKey().limitToLast(10).onValue,
                         builder: (context, snapshot){
                         final listtiles = <ListTile>[];
                         if(snapshot.hasData){
                           final vehicles = Map<String, dynamic>.from((snapshot.data! as Event).snapshot.value);
                           vehicles.forEach((key, value){
                             final nextVehicle = Map<String, dynamic>.from(value);
                             final vehicletile = ListTile(
                               title: Text(nextVehicle['car_name'].toString())
                             );
                             listtiles.add(vehicletile);
                           });

                         }
                         return ListView(
                           children: listtiles,
                         );
                         }
                     )

I'm expecting to get an array to iterate through and display its values through a streambuilder

MendelG
  • 14,885
  • 4
  • 25
  • 52

1 Answers1

0

It looks like you're working from an outdated code sample, according to the documentation of onSnapshot its type is DatabaseEvent (instead of Event that you have now).

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807