Created
July 2, 2019 21:07
-
-
Save xsahil03x/18cef8734c72c2ab0aa766f506b758bc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where in the codebase are defining this return MovieList(movieList: snapshot.data.data);