Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom picked place rebuild the map #8

Closed
jcsena opened this issue Feb 22, 2020 · 2 comments
Closed

Custom picked place rebuild the map #8

jcsena opened this issue Feb 22, 2020 · 2 comments
Labels
question Further information is requested

Comments

@jcsena
Copy link

jcsena commented Feb 22, 2020

When you add the "selectedPlaceWidgetBuilder" and search using the search bar, selecting a location will reset the map. It only works well if the position is selected using the marker pin.

...
          useCurrentLocation: true,
          usePlaceDetailSearch: true,
          selectInitialPosition: false,
          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");
                            },
                          ),
                  );
          },
...
@fysoul17
Copy link
Owner

That is because of MediaQuery.
As you might already guess, the keyboard cause the MediaQuery to rebuild the whole widget.
I removed it from the example to avoid confusion.

By Flutter document,

Querying the current media using MediaQuery.of will cause your widget to rebuild automatically > whenever the MediaQueryData changes (e.g., if the user rotates their device).

I am not sure if setting resizeToAvoidBottomInset to false will prevent this, but it is worth trying. I just updated the new version (0.6.4) so that you can handle 'resizeToAvoidBottomInset' property.

If it doesn't work, you must put MediaQuery.of(context) somewhere else or use another method to calculate screen size. (eg. Renderbox)

@fysoul17 fysoul17 added the question Further information is requested label Feb 22, 2020
@jcsena
Copy link
Author

jcsena commented Feb 22, 2020

I confirm that in the new version(0.6.4) it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants