Commit c3a17517 authored by Brian Egan's avatar Brian Egan

Update GridView to use a builder

parent 9cea0574
...@@ -33,18 +33,24 @@ class FontAwesomeGalleryHomeState extends State<FontAwesomeGalleryHome> { ...@@ -33,18 +33,24 @@ class FontAwesomeGalleryHomeState extends State<FontAwesomeGalleryHome> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( final filteredIcons = icons
appBar: _isSearching ? _searchBar(context) : _titleBar(),
body: new GridView.count(
crossAxisCount:
MediaQuery.of(context).orientation == Orientation.portrait
? 2
: 3,
children: icons
.where((icon) => .where((icon) =>
_searchTerm.isEmpty || _searchTerm.isEmpty ||
icon.title.toLowerCase().startsWith(_searchTerm.toLowerCase())) icon.title.toLowerCase().startsWith(_searchTerm.toLowerCase()))
.map((icon) => new InkWell( .toList();
final orientation = MediaQuery.of(context).orientation;
return new Scaffold(
appBar: _isSearching ? _searchBar(context) : _titleBar(),
body: new GridView.builder(
itemCount: filteredIcons.length,
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: orientation == Orientation.portrait ? 2 : 3,
),
itemBuilder: (context, index) {
final icon = filteredIcons[index];
return new InkWell(
onTap: () { onTap: () {
Navigator.push( Navigator.push(
context, context,
...@@ -75,8 +81,8 @@ class FontAwesomeGalleryHomeState extends State<FontAwesomeGalleryHome> { ...@@ -75,8 +81,8 @@ class FontAwesomeGalleryHomeState extends State<FontAwesomeGalleryHome> {
child: new Text(icon.title)) child: new Text(icon.title))
], ],
), ),
)) );
.toList()), }),
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment