flex_grid
the flexgrid control provides a powerful and quickly way to display data in a tabular format. it is including that frozened column/row,loading more, high performance and better experience in tabbarview/pageview.
parameter | description | default |
---|---|---|
frozenedcolumnscount | the count of forzened columns | 0 |
frozenedrowscount | the count of forzened rows | 0 |
cellbuilder | the builder to create cell | required |
cellbuilder | the builder to create header | required |
columnscount | the count of columns, it should big than 0 | required |
source | the data source of [flexgrid] | required |
rowwrapper | decorate row widget in this call back | null |
rebuildcustomscrollview | rebuild when source is changed, it’s from [loadingmorecustomscrollview] | false |
controller | the [scrollcontroller] on vertical direction | null |
horizontalcontroller | the [synccontrollermixin] for horizontal direction | null |
outerhorizontalsynccontroller | the outer [synccontrollermixin], for example [extendedtabbarview] or [extendedpageview]. it make better experience when scroll on horizontal direction | null |
physics | the physics on both horizontal and vertical direction | null |
highperformance | if true, forces the children to have the given extent(cell height/width) in the scroll direction. | false |
headerstyle | an immutable style describing how to create header | cellstyle.header() |
cellstyle | an immutable style describing how to create cell | cellstyle.cell() |
indicatorbuilder | widget builder for different loading state, it’s from [loadingmorecustomscrollview] | null |
extendedlistdelegate | a delegate that provides extensions, it’s from [loadingmorecustomscrollview] | null |
headersbuilder | the builder to custom the headers of [flexgrid] | null |
source
[flexgrid.source] is form loading_more_list, loadingmorebase is data collection for loading more. override loaddata method to load your data. set hasmore to false when it has no more data.
class flexgridsource extends loadingmorebase<gridrow> {
int _pageindex = 1;
void _load() {
for (int i = 0; i < 15; i++) {
add(gridrow(name: 'index:$_pageindex-$i'));
}
}
@override
bool get hasmore => _pageindex < 4;
@override
future<bool> loaddata([bool isloadmoreaction = false]) async {
await future<void>.delayed(const duration(seconds: 2));
_load();
_pageindex++;
return true;
}
@override
future<bool> refresh([bool notifystatechanged = false]) async {
_pageindex = 1;
return super.refresh(notifystatechanged);
}
}
rowwrapper
decorate row widget in this call back.
flexgrid(
rowwrapper: (
buildcontext context,
t data,
int row,
widget child,
) {
return column(
children: <widget>[
child,
const divider(),
],
);
},
);
headersbuilder
you can add anyother headers in this call back.
flexgrid(
headersbuilder: (buildcontext b, widget header) {
return <widget>[
header,
slivertoboxadapter(
child: pulltorefreshcontainer(
(pulltorefreshscrollnotificationinfo info) {
return pulltorefreshheader(
info,
source.lastrefreshtime,
);
}),
),
];
},
);
Comments are closed.