fysoul17 / google_maps_place_picker

Place picker on Google Maps for Flutter
MIT License
223 stars 364 forks source link

Issue when using [selectedPlaceWidgetBuilder] with MediaQuery #30

Closed RicardoRB closed 4 years ago

RicardoRB commented 4 years ago

Describe the bug When the selectedPlaceWidgetBuilder is overridden and want to search an address by the top bar, it doesn't move the map to the found address.

To Reproduce Steps to reproduce the behavior:

  1. Rewrite selectedPlaceWidgetBuilder: Example: selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) { return isSearchBarFocused ? Container() // Use FloatingCard or just create your own Widget. : FloatingCard( bottomPosition: MediaQuery.of(context).size.height 0.05, leftPosition: MediaQuery.of(context).size.width 0.05, width: MediaQuery.of(context).size.width * 0.9, borderRadius: BorderRadius.circular(12.0), child: state == SearchingState.Searching ? Center(child: CircularProgressIndicator()) : RaisedButton(onPressed: () { print("do something with [selectedPlace] data"); },), ); },

  2. Click on top bar

  3. Write a address

  4. Click the address

  5. You get the adress but the map doesn't move to the selected address

Expected behavior When the user selects the address in top bar, the map should move there

Flutter Doctor -v [✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Linux, locale en_US.UTF-8) • Flutter version 1.12.13+hotfix.9 at /home/ricardo/flutter • Framework revision f139b11009 (4 weeks ago), 2020-03-30 13:57:30 -0700 • Engine revision af51afceb8 • Dart version 2.7.2

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) • Android SDK at /home/ricardo/Android/Sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 28.0.3 • Java binary at: /snap/android-studio/88/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211) • All Android licenses accepted.

[✓] Android Studio (version 3.6) • Android Studio at /snap/android-studio/88/android-studio • Flutter plugin version 45.1.1 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] Connected device (1 available) • Redmi 4X • 6f9199b7d440 • android-arm64 • Android 7.1.2 (API 25)

• No issues found!

fysoul17 commented 4 years ago

Hi @RicardoRB ,

I think it is because of MediaQuery since it rebuilds your widget.

Try to put something like:

bottomPosition: 0.0,    
leftPosition: 0.0,
rightPosition: 0.0,

instead of MediaQuery.

RicardoRB commented 4 years ago

Hi @fysoul17

That's the trick!

Thanks!