0
Hello!
I’m trying to return location values with StreamBuilder
, but I’m not succeeding.
In debug, it doesn’t even run Builder. I can’t find the problem.
Here I create the Streambuilder, to bring the location
_newMoveToApoio(String uidProp) {
StreamBuilder(
stream: Firestore.instance
.collection('tracker')
.document(uidProp)
.snapshots(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return new Center(
child: CircularProgressIndicator(),
);
} else {
var trackerDocument = snapshot.data;
double latitude = trackerDocument['latitude'];
double longitude = trackerDocument['longitude'];
_controller.animateCamera(CameraUpdate.newCameraPosition(
CameraPosition(
target: LatLng(latitude, longitude), zoom: 18.0)));
setState(() {
_markers.add(
Marker(
draggable: false,
markerId: MarkerId("1"),
position: LatLng(latitude, longitude),
infoWindow: InfoWindow(
title: "João Marcelo", snippet: "Sua Localização Atual"),
icon: _markerIconApoio,
),
);
});
}
});
}
Here I make the call on a bottomsheet, passing the 'uid'
onTap: () => _newMoveToApoio(snapshot.data[index].data['uidProp']),
Its function
_newMoveToApoio
doesn’t return anything? Is that right? Only runs the Streambuilder constructor and does not use this object for anything? Also, what would you like to be done with this onTap? Just calling this function so will not do anything at all. I couldn’t understand your intention.– Naslausky
@Naslausky I was not using the Streambuilder in the correct way. On another channel of doubts, one managed to point out to me the correct way. I will put the answer here to help others with the same difficulty.
– JohnSan