GridView is the new hotness

278 views
Skip to first unread message

Adam Barth

unread,
Feb 6, 2017, 1:46:48 PM2/6/17
to Flutter Dev
I recently landed a change that removes CustomGrid, FixedColumnCountGrid, and MaxTileWidthGrid.  These have been replaced with GridView:


GridView is higher performance than the previous grid widgets because it supports viewporting: when a child isn't visible, we're able to avoid spending resources on it during layout and paint.  In addition, GridView supports grid layouts in every direction (top-to-bottom, left-to-right, bottom-to-top, and right-to-left) whereas the old grids supported only top-to-bottom layouts.

Here's a cheat sheet for converting your existing uses of the grid widgets:

 * CustomGrid -> GridView.custom
 * FixedColumnCountGrid -> GridView.count
 * MaxTileWidthGrid -> GridView.extent

The old grid widgets would shrink wrap their height by default.  If you want shrink wrapping with GridView, you can set the shrinkWrap property to true.  (The default is not to shrink wrap, which is more efficient.)

GridView also supports scrolling, which means you should also replace uses of ScrollableGrid with GridView.  I'll be removing ScrollableGrid widget as well once I finish converting the remaining clients.

(As usual, If your code is internal to Google or in fuchsia.googlesource.com, I've migrated your code for you.)

Thanks, and happy grid-making,
Adam

Adam Barth

unread,
Feb 9, 2017, 2:07:17 AM2/9/17
to Flutter Dev
I've removed ScrollableGrid as well now.  You should be able to use GridView instead.
Reply all
Reply to author
Forward
0 new messages