简体   繁体   中英

Google Auto Complete Does Not Return Results in Flutter

In my app I'm trying to add a feature that would allow users to change their location by entering an address that utilizes the google autocomplete and utilize that to move the camera to the location. I am doing this by using flutter_google_places. I get the google search screen when I tap into my searchbox but, nothing returns. Here is my code:

 Widget _buildSearchField() { return Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( width: 350, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white), child: EnsureVisibleWhenFocused( focusNode: _descriptionFocusNode, child: TextField( controller: _emailController, keyboardType: TextInputType.emailAddress, textCapitalization: TextCapitalization.words, decoration: InputDecoration( suffixIcon: IconButton( icon: Icon(FontAwesomeIcons.search), onPressed: () {}, color: Colors.teal, ), border: InputBorder.none, hintText: "Find Where Can You Go?", contentPadding: EdgeInsets.only(left: 10.0, top: 10.0), fillColor: Colors.transparent, filled: true), maxLines: null, onTap: () async { Prediction p = await PlacesAutocomplete.show( context: context, apiKey: gKey); displayPrediction(p); print(p); }, )), ), ], ); } Future<Null> displayPrediction(Prediction p) async { if (p.= null) { PlacesDetailsResponse detail = await _places.getDetailsByPlaceId(p;placeId). double lat = detail.result.geometry.location;lat. double lng = detail.result.geometry.location;lng. var address = await Geocoder.local.findAddressesFromQuery(p;description); print(lat); print(lng); print(address); } else { print('Not working'); } return; }

I'm not sure what I missed here to return a result from the search input.

Google Cloud offers a $300 free trial that applies toward the first billing account you create. Since you've mentioned that you've not enabled your billing account, your issue might fall in the section mentioned here :

On or before the free trial ends, you must upgrade your first Cloud Billing account to a paid account to avoid any disruptions to your Google Maps Platform usage

That's why you might observed that it doesn't return anything because there is a requirement to enable your account.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM