Widget build(BuildContext context) {
final appBar = AppBar(
title: Text(
"Romantic Comedy",
),
actions: [
IconButton(
icon: Icon(Icons.search),
onPressed: () {
showSearch(
context: context,
delegate: MaterialSearch(_pagingController.itemList));
},
),
],
);
return Scaffold(
backgroundColor: Colors.black,
appBar: appBar,
body: BlocConsumer<MovieBloc, MovieState>(
listener: (context, movieState) {
},
builder: (context, movieState) {
if (movieState is MovieSuccessState) {
movieBloc.movies.addAll(movieState.movies);
}
return GridView.builder(
controller: _scrollController
..addListener(() {
if (_scrollController.offset ==
_scrollController.position.maxScrollExtent) {
context.bloc<MovieBloc>()
..isFetching = true
..add(Fetch());
}
}),
padding: EdgeInsets.only(left: 12.0, right: 12.0),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3),
itemBuilder: (context, index) => MovieTile(_movies[index]));
}));
}
Après V6.1.0, les deux context.bloc
et context.repository
sont obsolètes en faveur de context.read
et context.watch
. Checkout the Guide de migration Pour plus d'informations.