onSearchResults method
Implementation
Future<void> onSearchResults(
BuildContext context, SearchResult searchResult) async {
final SearchBloc searchBloc = BlocProvider.of<SearchBloc>(context);
final LocationBloc locationBloc = BlocProvider.of<LocationBloc>(context);
final MapBloc mapBloc = BlocProvider.of<MapBloc>(context);
if (searchResult.isManual) {
searchBloc.add(OnEnableManualMarkerEvent());
return;
}
if (searchResult.position != null) {
final LatLng? start = locationBloc.state.lastKnownLocation;
if (start == null) return;
final LatLng? end = searchResult.position;
if (end == null) return;
showLoadingMessage(context: context);
final RouteDestination destination =
await searchBloc.getCoorsStartToEnd(start, end);
await mapBloc.drawRoutePolyline(destination);
Navigator.pop(context);
}
}