'How get list data from specific node firebase realtime db in flutter
This is my sample code for other data
DatabaseReference rideRef = FirebaseDatabase.instance.reference().child('rideRequest/$rideID');
rideRef.once().then((DataSnapshot snapshot){
Navigator.pop(context);
if(snapshot.value != null){
print(snapshot.value);
double pickupLat = double.parse(snapshot.value['pickup_location']['latitude'].toString());
double pickupLng = double.parse(snapshot.value['pickup_location']['longitude'].toString());
String pickupAddress = snapshot.value['pickup_address'].toString();
How do to get that destination list data.Thanks you.
Solution 1:[1]
I have solved my question like that.
List<DestLocation> destLocation = [];
List<dynamic> result;
result = snapshot.value['destination'];
result.forEach((value) {
if (value != null) {
DestLocation _a = DestLocation(
placeName: value["destination_address"].toString(),
latitude: double.parse(value["latitude"]),
longitude: double.parse(value["longitude"])
);
destLocation.add(_a);
}
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | H Zan |