Created
June 6, 2020 06:49
-
-
Save ashishrawat2911/f5dfdecf685908a4dfad4eb54d8bb497 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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