Skip to content

Instantly share code, notes, and snippets.

@xsahil03x
Created July 2, 2019 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xsahil03x/18cef8734c72c2ab0aa766f506b758bc to your computer and use it in GitHub Desktop.
Save xsahil03x/18cef8734c72c2ab0aa766f506b758bc to your computer and use it in GitHub Desktop.
class MovieScreen extends StatefulWidget {
@override
_MovieScreenState createState() => _MovieScreenState();
}
class _MovieScreenState extends State<MovieScreen> {
MovieBloc _bloc;
@override
void initState() {
super.initState();
_bloc = MovieBloc();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Movie Mania')),
backgroundColor: Colors.black54,
body: RefreshIndicator(
onRefresh: () => _bloc.fetchMovieList(),
child: StreamBuilder<ApiResponse<List<Movie>>>(
stream: _bloc.movieListStream,
builder: (context, snapshot) {
if (snapshot.hasData) {
switch (snapshot.data.status) {
case Status.LOADING:
return Loading(
loadingMessage: snapshot.data.message,
);
break;
case Status.COMPLETED:
return MovieList(movieList: snapshot.data.data);
break;
case Status.ERROR:
return Error(
errorMessage: snapshot.data.message,
onRetryPressed: () => _bloc.fetchMovieList(),
);
break;
}
}
return Container();
},
),
),
);
}
@override
void dispose() {
_bloc.dispose();
super.dispose();
}
}
@nasznjoka
Copy link

where in the codebase are defining this return MovieList(movieList: snapshot.data.data);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment