Skip to content

Instantly share code, notes, and snippets.

@ashishrawat2911
Created June 6, 2020 06:49
Show Gist options
  • Save ashishrawat2911/f5dfdecf685908a4dfad4eb54d8bb497 to your computer and use it in GitHub Desktop.
Save ashishrawat2911/f5dfdecf685908a4dfad4eb54d8bb497 to your computer and use it in GitHub Desktop.
class PlacePredictionSearchBloc {
StreamController<Result<List<Prediction>>> streamController =
StreamController<Result<List<Prediction>>>();
AppRepository appRepository = AppRepository();
Future<void> getCurrentAddress(String search) async {
streamController.sink.add(Result.loading());
try {
Prediction prediction = await appRepository.getPlacesPrediction(search);
streamController.sink
.add(Result.success(data: prediction.predictionsList));
} catch (e) {
streamController.sink.add(Result.failure(reason: e.toString()));
}
}
dispose() {
streamController?.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment