blackmann / locationpicker

Location picker for Flutter.
Other
167 stars 159 forks source link

Back button request #82

Open Tpow99 opened 1 year ago

Tpow99 commented 1 year ago

Hey! Super minor and hopefully trivial request, but a back or cancel button would be amazing!

rajesh-h commented 1 year ago

I am here for the same request. if you edit the package you can get the back button, but when you update the package it is lost so I wish if this was provided as boolean option.

Below line will decide on back button

https://github.com/blackmann/locationpicker/blob/71cd5e6040e769a185b68b0ce1f13d5ba106ac25/lib/widgets/place_picker.dart#L149

blewis-1 commented 1 year ago

I am here for the same request. Kindly have a look at it, users are stuck on the location_picker screen and there's no way to go back on iOS. Thanks.

dharambudh1 commented 1 year ago

I am here for the same request. if you edit the package you can get the back button, but when you update the package it is lost so I wish if this was provided as boolean option.

Below line will decide on back button

https://github.com/blackmann/locationpicker/blob/71cd5e6040e769a185b68b0ce1f13d5ba106ac25/lib/widgets/place_picker.dart#L149

Working, thanks!

mutairibassam commented 1 year ago

Maybe some of you still wondering how to implement Back Button. Above answer is still not obvious how it should be implemented. Below are the path you should follow to get it.

  1. You need to get the package from github not pub.dev. I used pull request #85 to be my reference.

Note: one of the bad things is whenever the pull request get updated, will be immediately reflected in you application so you might create fork it and modify the changes and refer to your repo.

  1. Refer to github repo instead of pub.dev in your pubspec.yml file

    place_picker:
    git:
      url: https://github.com/Lzyct/locationpicker.git
      # ref: branch_name # if branch not the master
      # rev: commit_hash # if you want to get specific commit
  2. In your code

    LocationResult? result = await Navigator.of(context).push(MaterialPageRoute(
    builder: (context) => PlacePicker(
        "API_KEY",
        // important to be added
        appBarOptions: AppBarOptions(showBackButton: true),
        ),
    ),
    );