I have a function for picking map using the place picker dependency in flutter. In my code what I am looking for is to return a value from this place picker dependency and transfer it to controller in order to store it in firebase.
Here is my code for the picker function
Future<LocationResult> showPlacePicker() async {
LocationResult result = await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
PlacePicker("MAPS API KEY HERE"),
),
);
return result;
}
Value passing to controller code:
Container(
width: 270,
child: TextFormField(
cursorColor: Colors.white,
style: TextStyle(color: Theme.of(context).primaryColor),
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(25.0),
borderSide: BorderSide(),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(25.0),
borderSide: BorderSide(
width: 2.0,
),
),
hintText: "Select Location",
hintStyle: TextStyle(
color: Theme.of(context).primaryColor,
fontFamily: "San Francisco",
)),
onTap: () async {
showPlacePicker()
.then((result) => provider.controllerText);
},
),
),
I have validation check on the controller of isEmpty so that's how I am getting to know that the controller is still empty so how can I pass the value to it. Note I can't put Navigator.pop in the function because its a dependency and it has its pre built screen for picking the location I can't use the Navigator.pop there it takes me back to home screen.
I only want the selected location thats all I want I don't have any use for name or location or any of these parameters further. This is the package I'm using place_picker and the PlacePicker library opens this screen in which there's a button to select this location that location is what I want just that and pass it to my provide controller