Skip to content

Getting null error when using "lastDetails" in getRow and in "customFooter" aswell #26

@Raviteja11122

Description

@Raviteja11122
class ExampleSource extends AdvancedDataTableSource<HelpRequestModel> {
  final data = List<HelpRequestModel>.generate(
    100,
    (index) => HelpRequestModel(
      concernType: lorem(paragraphs: 1, words: 2),
      concernSubType: lorem(paragraphs: 1, words: 3),
      issueIdentifier: lorem(paragraphs: 1, words: 5),
      summaryDetails: lorem(paragraphs: 1, words: 10),
      date: "20/11/2021",
      time: "15:54.34",
      status: lorem(paragraphs: 1, words: 2)
    )
  );

  @override
  DataRow? getRow(int index) {
    final currentRowData = lastDetails!.rows[index];
    return DataRow(
      cells: [
        DataCell(Text((index + 1).toString(), style: TextStyle(fontSize: 12.sp))),
        DataCell(Text(currentRowData.concernType ?? "", style: TextStyle(fontSize: 12.sp))),
        DataCell(Text(currentRowData.concernSubType ?? "", style: TextStyle(fontSize: 12.sp))),
        DataCell(Text(currentRowData.issueIdentifier ?? "", style: TextStyle(fontSize: 12.sp))),
        DataCell(Text(currentRowData.summaryDetails ?? "", style: TextStyle(fontSize: 12.sp))),
        DataCell(Text(currentRowData.date ?? "", style: TextStyle(fontSize: 12.sp))),
        DataCell(Text(currentRowData.time ?? "", style: TextStyle(fontSize: 12.sp))),
        DataCell(Text(currentRowData.status ?? "", style: TextStyle(fontSize: 12.sp))),
        DataCell(
          Row(
            children: [
              Container(
                width: 30,
                height: 30,
                alignment: Alignment.center,
                decoration: BoxDecoration(
                  borderRadius: const BorderRadius.all(Radius.circular(15)).r,
                  border: Border.all(color: ColorName.performanceProgressBgColor, width: 1),
                ),
                child: Icon(Icons.visibility_outlined, size: 18.r)
              ),
              13.72.horizontalSpace,
              Icon(Icons.delete_outlined, size: 20.r, color: ColorName.defaultFontColor)
            ]
          )
        ),
      ],
    );
  }

  @override
  int get selectedRowCount => 0;

  @override
  Future<RemoteDataSourceDetails<HelpRequestModel>> getNextPage(
      NextPageRequest pageRequest) async {
    return RemoteDataSourceDetails(
      data.length,
      data
          .skip(pageRequest.offset)
          .take(pageRequest.pageSize)
          .toList(), //again in a real world example you would only get the right amount of rows
    );
  }
}


AdvancedPaginatedDataTable(
                addEmptyRows: false,
                source: model.source,
                showHorizontalScrollbarAlways: true,
                rowsPerPage: model.rowsPerPage,
                //availableRowsPerPage: const [10, 20, 30, 50],
                onRowsPerPageChanged: model.setRowsPerPage,
                columns: [
                  DataColumn(
                    label: Text('Sl No.', style: Theme.of(context).textTheme.caption!.copyWith(
                      color: ColorName.primary
                    )),
                    numeric: true,
                  ),
                  DataColumn(
                    label: Text('Concern Type', style: Theme.of(context).textTheme.caption!.copyWith(
                        color: ColorName.primary
                    )),
                  ),
                  DataColumn(
                    label: Text('Concern Sub Type', style: Theme.of(context).textTheme.caption!.copyWith(
                        color: ColorName.primary
                    )),
                  ),
                  DataColumn(
                    label: Text('Issue Identifier', style: Theme.of(context).textTheme.caption!.copyWith(
                        color: ColorName.primary
                    )),
                  ),
                  DataColumn(
                    label: Text('Summary Details', style: Theme.of(context).textTheme.caption!.copyWith(
                        color: ColorName.primary
                    )),
                  ),
                  DataColumn(
                    label: Text('Date', style: Theme.of(context).textTheme.caption!.copyWith(
                        color: ColorName.primary
                    )),
                  ),
                  DataColumn(
                    label: Text('Time', style: Theme.of(context).textTheme.caption!.copyWith(
                        color: ColorName.primary
                    )),
                  ),
                  DataColumn(
                    label: Text('Status', style: Theme.of(context).textTheme.caption!.copyWith(
                        color: ColorName.primary
                    )),
                  ),
                  DataColumn(
                    label: Text('Action', style: Theme.of(context).textTheme.caption!.copyWith(
                        color: ColorName.primary
                    )),
                  ),
                ],
              )```

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions