placeAutoComplete method

  1. @override
Future<Prediction> placeAutoComplete(
  1. BuildContext context,
  2. String startText
)
override

Implementation

@override
Future<Prediction> placeAutoComplete(BuildContext context, String startText) async {
  AppConfig.logger.d("Entering placeAutocomplate method");

  Prediction prediction = Prediction();

  try {
    Prediction? retrievedPrediction =  await PlacesAutocomplete.show(
      startText: startText,
      offset: 0,
      radius: 1000,
      types: [],
      location: location,
      strictbounds: false,
      mode: Mode.fullscreen,
      context: context,
      apiKey: AppProperties.getGoogleApiKey(),
      onError: onError,
      language: "mx",
      decoration: InputDecoration(
        hintText: CoreConstants.search.tr,
        fillColor: Colors.yellow
      ),

      components: [Component(Component.country, "mx")],
    );

    if(retrievedPrediction != null) prediction = retrievedPrediction;

  } catch (e) {
    AppConfig.logger.d(e.toString());
  }

  return prediction;
}