Skip to content

Instantly share code, notes, and snippets.

@ashishrawat2911
Created June 6, 2020 07:07
Show Gist options
  • Save ashishrawat2911/4892e72602204c34fade8b874ca15ede to your computer and use it in GitHub Desktop.
Save ashishrawat2911/4892e72602204c34fade8b874ca15ede to your computer and use it in GitHub Desktop.
StreamBuilder<Result<List<Prediction>>>(
stream: placePredictionSearchBloc.streamController.stream,
initialData: Result.idle(),
builder: (BuildContext context,
AsyncSnapshot<Result<List<Prediction>>> snapshot) {
return snapshot.data.when(idle: () {
return Container();
}, loading: () {
return CircularProgressIndicator();
}, success: (List<AutocompletePrediction> value) {
return ListView.builder(
shrinkWrap: true,
itemCount: value.length,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return Text(
"${value[index].description}",
style: TextStyle(
fontSize: 16,
color: AppColors.color20203E,
),
);
},
);
}, failure: (String reason) {
return Text(reason);
});
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment