Blank rows shown if there are not enough entries to display #492

This commit is contained in:
Hillel Coren 2023-06-01 19:17:47 +03:00
parent 7213eaf459
commit 07c075c14f
1 changed files with 10 additions and 5 deletions

View File

@ -322,8 +322,10 @@ class AppPaginatedDataTableState extends State<AppPaginatedDataTable> {
haveProgressIndicator = true; haveProgressIndicator = true;
} }
} }
row ??= _getBlankRowFor(index); if (row != null) {
result.add(row); row ??= _getBlankRowFor(index);
result.add(row);
}
} }
return result; return result;
} }
@ -378,6 +380,8 @@ class AppPaginatedDataTableState extends State<AppPaginatedDataTable> {
// FOOTER // FOOTER
final TextStyle footerTextStyle = themeData.textTheme.bodySmall; final TextStyle footerTextStyle = themeData.textTheme.bodySmall;
final List<Widget> footerWidgets = <Widget>[]; final List<Widget> footerWidgets = <Widget>[];
final realRowCount =
widget.subtractOneFromCount ? _rowCount - 1 : _rowCount;
if (widget.onRowsPerPageChanged != null) { if (widget.onRowsPerPageChanged != null) {
final List<Widget> availableRowsPerPage = widget.availableRowsPerPage final List<Widget> availableRowsPerPage = widget.availableRowsPerPage
//.where((int value) => value <= _rowCount || value == widget.rowsPerPage) //.where((int value) => value <= _rowCount || value == widget.rowsPerPage)
@ -387,6 +391,7 @@ class AppPaginatedDataTableState extends State<AppPaginatedDataTable> {
child: Text('$value'), child: Text('$value'),
); );
}).toList(); }).toList();
footerWidgets.addAll(<Widget>[ footerWidgets.addAll(<Widget>[
Container(width: 14.0), Container(width: 14.0),
// to match trailing padding in case we overflow and end up scrolling // to match trailing padding in case we overflow and end up scrolling
@ -413,9 +418,9 @@ class AppPaginatedDataTableState extends State<AppPaginatedDataTable> {
Container(width: 32.0), Container(width: 32.0),
Text( Text(
localizations.pageRowsInfoTitle( localizations.pageRowsInfoTitle(
_firstRowIndex + 1, realRowCount > 0 ? _firstRowIndex + 1 : 0,
_firstRowIndex + widget.rowsPerPage, _firstRowIndex + math.min(widget.rowsPerPage, realRowCount),
_rowCount - (widget.subtractOneFromCount ? 1 : 0), realRowCount,
_rowCountApproximate, _rowCountApproximate,
), ),
), ),