We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am using provider as a state Management,and the following is my code:
` Widget build(BuildContext context) { print("Build PaginationController"); final p = context.watch(); PaginationController _paginationController=PaginationController( rowCount: p.data.isEmpty ? 16 : p.data.length, rowsPerPage:ItemUtils.calculateMaxRows(context), ); return Scaffold( body: Column( children: [ PosHeaderBuilder( code: widget.code, dataLength: p.data.length, icon: widget.iconData, title: p.title, onSearch: (x) async { if (x.isNotEmpty) { var c = p.data.where((e) => e.name!.contains(x) || e.id.toString().contains(x)); p.data = (c.toList()); } else { await p.loadList(); } p.refresh(); }, onRefresh: p.init, context: context, ), Divider(height: 2, thickness: 0.5), Expanded( child: ScrollableTableView( // paginationController: _paginationController(p, context), paginationController: _paginationController, rowDividerHeight: 3, headerBackgroundColor: kBackgroundColor, headers: ItemUtils.generateHeaderList(widget.code, p).map((column) { return TableViewHeader( textStyle: TextStyle( fontWeight: FontWeight.w700, fontFamily: 'OpenSans', color: Colors.black, fontSize: 18, ), minWidth: 80, width: 150, label: column, ); }).toList(), rows: !p.isLoading ? p.data.map((item) { return TableViewRow( height: 30, cells: [ TableViewCell( child: Container( margin: EdgeInsets.symmetric(horizontal: 10), child: Text( (p.data.indexOf(item) + 1).toString()?? '', textAlign: TextAlign.center, style: TextStyle(fontWeight: FontWeight.bold), ), ), ), TableViewCell( child: Text( item.itemNo ?? '-', textAlign: TextAlign.center, style: TextStyle(fontWeight: FontWeight.bold), ), ), TableViewCell( child: Text( item.name ?? '-', textAlign: TextAlign.center, style: TextStyle(fontWeight: FontWeight.bold), ), ), TableViewCell( child: Text( Instance.warehouses .firstWhere( (e) => e.id == item.warehouseId, orElse: () => Warehouse(), ) .title ?? '-', textAlign: TextAlign.center, style: TextStyle(fontWeight: FontWeight.bold), ), ), TableViewCell( child: Text( Instance.classifications .firstWhere( (e) => e.id == item.classificationId, orElse: () => Classification(), ) .title ?? '-', textAlign: TextAlign.center, style: TextStyle(fontWeight: FontWeight.bold), ), ), TableViewCell( child: Text( item.count?.toString() ?? '-', textAlign: TextAlign.center, style: TextStyle(fontWeight: FontWeight.bold), ), ), TableViewCell( child: Container( margin: EdgeInsets.symmetric(horizontal: 10), child: Checkbox( value: item.isFavorite ?? false, onChanged: (x) { // p.isFavorite = (x)!; if (isEdit(widget.code)) { item?.isFavorite = x; HelpPos.changeStatus(context, p, item, callBack: (x) async { await HiveRepository.addItemsCashing( convertItemToLocal([item])); await p.loadList(); p.refresh(); }); } }), ), ), TableViewCell( child: Container( margin: EdgeInsets.symmetric(horizontal: 10), child: Checkbox( value: item.status ?? false, onChanged: (x) { if (isEdit(widget.code)) { item.status = x!; HelpPos.changeStatus(context, p, item, callBack: (x) async { await HiveRepository.addItemsCashing( convertItemToLocal([item])); await p.loadList(); p.refresh(); }); } }), ), ), TableViewCell( child: Responsive.isDesktop(context) ? Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ if (isEdit(widget.code)) transactionEntity( onTap: () => p.edit(context, item), icon: Icons.edit, ), SizedBox(width: 5), if (isDelete(widget.code)) transactionEntity( onTap: () => p.delete(context, item), icon: Icons.delete, ), transactionEntity( onTap: () => p.showS(context, item), icon: Icons.info, ), ], ) : buildPopupMenuActions([ if (isEdit(widget.code)) buildPopupMenuItem( title: 'تعديل', iconData: Icons.edit, onClick: () => p.edit(context, item), context: context, ), if (isDelete(widget.code)) buildPopupMenuItem( title: 'حذف', iconData: CupertinoIcons.delete, onClick: () => p.delete(context, item), context: context, ), buildPopupMenuItem( title: 'تفاصيل الصنف', iconData: CupertinoIcons.info, onClick: () => p.showS(context, item), context: context, ), ]), ), ], ); }).toList() : generateShimmerLoading(length: 16).map((lod) { return TableViewRow(height: 30, cells: [ TableViewCell( child: lod, ), TableViewCell( child: lod, ), TableViewCell( child: lod, ), TableViewCell( child: lod, ), TableViewCell( child: lod, ), TableViewCell( child: lod, ), TableViewCell( child: lod, ), TableViewCell( child: lod, ), TableViewCell( child: lod, ), ]); }).toList(), ), ), ], ), persistentFooterButtons: [ WebPagination( displayItemCount: 3, onPageChanged: (int page) {
setState(() { // _paginationController(p, context).jumpTo(page); _paginationController.jumpTo(page); _paginationController.value=page; _paginationController.addListener(() { _paginationController.jumpTo(page); _paginationController.value=page; }); _paginationController.notifyListeners(); _paginationController.next(); print("Has Listner :${_paginationController.hasListeners}"); p.notifyListeners(); p.refresh(); }); print( "WebPagination Current page :${_paginationController.currentPage}"); }, currentPage:_paginationController.currentPage, totalPage:_paginationController.pageCount) ] );
} ` The data in next page did not display,becuase the current page did not updated,, so what the problem?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am using provider as a state Management,and the following is my code:
` Widget build(BuildContext context) {
print("Build PaginationController");
final p = context.watch();
PaginationController _paginationController=PaginationController(
rowCount: p.data.isEmpty ? 16 : p.data.length,
rowsPerPage:ItemUtils.calculateMaxRows(context),
);
return Scaffold(
body: Column(
children: [
PosHeaderBuilder(
code: widget.code,
dataLength: p.data.length,
icon: widget.iconData,
title: p.title,
onSearch: (x) async {
if (x.isNotEmpty) {
var c = p.data.where((e) =>
e.name!.contains(x) || e.id.toString().contains(x));
p.data = (c.toList());
} else {
await p.loadList();
}
p.refresh();
},
onRefresh: p.init,
context: context,
),
Divider(height: 2, thickness: 0.5),
Expanded(
child: ScrollableTableView(
// paginationController: _paginationController(p, context),
paginationController: _paginationController,
rowDividerHeight: 3,
headerBackgroundColor: kBackgroundColor,
headers: ItemUtils.generateHeaderList(widget.code, p).map((column) {
return TableViewHeader(
textStyle: TextStyle(
fontWeight: FontWeight.w700,
fontFamily: 'OpenSans',
color: Colors.black,
fontSize: 18,
),
minWidth: 80,
width: 150,
label: column,
);
}).toList(),
rows: !p.isLoading
? p.data.map((item) {
return TableViewRow(
height: 30,
cells: [
TableViewCell(
child: Container(
margin: EdgeInsets.symmetric(horizontal: 10),
child: Text(
(p.data.indexOf(item) + 1).toString()?? '',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
),
TableViewCell(
child: Text(
item.itemNo ?? '-',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
TableViewCell(
child: Text(
item.name ?? '-',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
TableViewCell(
child: Text(
Instance.warehouses
.firstWhere(
(e) => e.id == item.warehouseId,
orElse: () => Warehouse(),
)
.title ??
'-',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
TableViewCell(
child: Text(
Instance.classifications
.firstWhere(
(e) => e.id == item.classificationId,
orElse: () => Classification(),
)
.title ??
'-',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
TableViewCell(
child: Text(
item.count?.toString() ?? '-',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
TableViewCell(
child: Container(
margin: EdgeInsets.symmetric(horizontal: 10),
child: Checkbox(
value: item.isFavorite ?? false,
onChanged: (x) {
// p.isFavorite = (x)!;
if (isEdit(widget.code)) {
item?.isFavorite = x;
HelpPos.changeStatus(context, p, item,
callBack: (x) async {
await HiveRepository.addItemsCashing(
convertItemToLocal([item]));
await p.loadList();
p.refresh();
});
}
}),
),
),
TableViewCell(
child: Container(
margin: EdgeInsets.symmetric(horizontal: 10),
child: Checkbox(
value: item.status ?? false,
onChanged: (x) {
if (isEdit(widget.code)) {
item.status = x!;
HelpPos.changeStatus(context, p, item,
callBack: (x) async {
await HiveRepository.addItemsCashing(
convertItemToLocal([item]));
await p.loadList();
p.refresh();
});
}
}),
),
),
TableViewCell(
child: Responsive.isDesktop(context)
? Row(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
if (isEdit(widget.code))
transactionEntity(
onTap: () => p.edit(context, item),
icon: Icons.edit,
),
SizedBox(width: 5),
if (isDelete(widget.code))
transactionEntity(
onTap: () =>
p.delete(context, item),
icon: Icons.delete,
),
transactionEntity(
onTap: () => p.showS(context, item),
icon: Icons.info,
),
],
)
: buildPopupMenuActions([
if (isEdit(widget.code))
buildPopupMenuItem(
title: 'تعديل',
iconData: Icons.edit,
onClick: () => p.edit(context, item),
context: context,
),
if (isDelete(widget.code))
buildPopupMenuItem(
title: 'حذف',
iconData: CupertinoIcons.delete,
onClick: () =>
p.delete(context, item),
context: context,
),
buildPopupMenuItem(
title: 'تفاصيل الصنف',
iconData: CupertinoIcons.info,
onClick: () => p.showS(context, item),
context: context,
),
]),
),
],
);
}).toList()
: generateShimmerLoading(length: 16).map((lod) {
return TableViewRow(height: 30, cells: [
TableViewCell(
child: lod,
),
TableViewCell(
child: lod,
),
TableViewCell(
child: lod,
),
TableViewCell(
child: lod,
),
TableViewCell(
child: lod,
),
TableViewCell(
child: lod,
),
TableViewCell(
child: lod,
),
TableViewCell(
child: lod,
),
TableViewCell(
child: lod,
),
]);
}).toList(),
),
),
],
),
persistentFooterButtons: [
WebPagination(
displayItemCount: 3,
onPageChanged: (int page) {
}
` The data in next page did not display,becuase the current page did not updated,, so what the problem?
The text was updated successfully, but these errors were encountered: