A simple flutter widget based on code used multiple private projects.
Pass a list of similar sized widgets to the GriddedPageView
and set a preferred size to display them in a combination of GridView
and PageView
.
GriddedPageView
distrubutes its children over these pages depending on the available size.
This widget uses page_indicator.
Example (see example main.dart):
GriddedPageView(
controller: _controller,
preferredChildWidth: 160,
preferredChildHeight: 160,
children: List<Widget>.generate(20, (int index) {
return Container(
color: Color((Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0),
);
}),
// overlapIndicator: false,
);
GriddedPageView
accepts the following arguments:
controller
(required): a PageControllerchildren
(required): a List of WidgetsminChildWidth
(required): the minimum width of each child. Used to calculate how many columns can fit on a pageminChildHeight
(required): the minimum height of each child. Used to calculate how many rows can fit on a pageonPageChanged
: a callback used to report a page changeonPageAmountChanged:
a callback used to report a change in the amount of pagesshowIndicator
: whether to show the page indicator (true by default)overLapIndicator
: whether the page indicator should overlap the children (true by default)pagePadding
: padding around the page content (GridView)indicatorPadding
: padding around the page indicatorindicatorColor
: color of the page indicatorindicatorSelectorColor
: color of the current page indicator
Feel free to ask questions, report issues, fork and create pull requests.
I will not maintain this actively beyond my specific needs, so don't expect me to implement new features.