diff --git a/examples/flutter_gallery/lib/gallery/home.dart b/examples/flutter_gallery/lib/gallery/home.dart index 7f2fa18190..894f01425b 100644 --- a/examples/flutter_gallery/lib/gallery/home.dart +++ b/examples/flutter_gallery/lib/gallery/home.dart @@ -99,20 +99,17 @@ class GalleryHome extends StatefulWidget { class GalleryHomeState extends State { static final Key _homeKey = new ValueKey("Gallery Home"); static final GlobalKey _scrollableKey = new GlobalKey(); - final List _listItems = []; - - @override - void initState() { - super.initState(); + List _galleryListItems() { + final List listItems = []; final ThemeData themeData = Theme.of(context); final TextStyle headerStyle = themeData.textTheme.body2.copyWith(color: themeData.accentColor); String category; for (GalleryItem galleryItem in kAllGalleryItems) { if (category != galleryItem.category) { if (category != null) - _listItems.add(new Divider()); - _listItems.add( + listItems.add(new Divider()); + listItems.add( new Container( height: 48.0, padding: const EdgeInsets.only(left: 16.0), @@ -122,8 +119,9 @@ class GalleryHomeState extends State { ); category = galleryItem.category; } - _listItems.add(galleryItem); + listItems.add(galleryItem); } + return listItems; } @override @@ -160,7 +158,7 @@ class GalleryHomeState extends State { body: new Block( scrollableKey: _scrollableKey, padding: new EdgeInsets.only(top: _kFlexibleSpaceMaxHeight + statusBarHeight), - children: _listItems + children: _galleryListItems() ) ); }