使用搜索框自动完成Google搜索

时间:2020-01-08 06:28:32

标签: flutter maps

如何在扑朔迷离中添加Google Maps自动填充搜索框?

我想使用dart在Google地图中添加自动填充搜索框。

1 个答案:

答案 0 :(得分:0)

在pubspec.yaml中添加依赖项

  flutter_google_places:

之后,您可以使用此方法

Future<void> _handlePressButton() async {
    // show input autocomplete with selected mode
    // then get the Prediction selected
    Prediction p = await PlacesAutocomplete.show(
      context: context,
      apiKey: 'your_api_key',
//      onError: onError,
      mode: Mode.overlay,
      language: "en",
      components: [Component(Component.country, "in")],
    );

  }
相关问题