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