Need help creating a custom widget with a pub.dev package.

I am trying to use a pub.dev table to display data. I require a more advanced table than the stock DataTable.

I am importing the correct dependencies and have tested this in flutter (v3.13.7)

I received an "Unknown Error" when compiling.

I have tried to implement other pub.dev packages as suggested in another question but am having the same issue.

I can't find much help info, can anyone point me in the right direction?

The code I have is not final, the first goal is to have it work!

I have this working in a flutter project:

class CustomDataTable extends StatelessWidget {
  final int rowCount;
  final int columnCount;

  CustomDataTable({Key? key, this.rowCount = 30, this.columnCount = 32})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    final data = CustomDataTableSource(rowCount, columnCount);

    List<DataColumn> generateColumns(int count) {
      return List.generate(
        count,
        (index) {
          String columnName;
          if (index < 26) {
            columnName = String.fromCharCode('A'.codeUnitAt(0) + index);
          } else {
            columnName =
                'A' + String.fromCharCode('A'.codeUnitAt(0) + index - 26);
          }
          return DataColumn(label: Text('Col $columnName'));
        },
      );
    }

    const int defaultRowsPerPage = 30;

    return Container(
      width: 1240, // Fixed width
      height: 800, // Fixed height
      child: PaginatedDataTable2(
        columnSpacing: 12,
        horizontalMargin: 12,
        minWidth: 3000,
        columns: generateColumns(columnCount),
        source: data,
        rowsPerPage: defaultRowsPerPage,
        fixedLeftColumns: 1,
        fixedTopRows: 1,
        availableRowsPerPage: [5, 10, 20, 30],
        onRowsPerPageChanged: (newRowsPerPage) {},
        // Add other PaginatedDataTable2 properties as needed.
      ),
    );
  }
}

class CustomDataTableSource extends DataTableSource {
  final int columnCount;
  final int rowCount;

  CustomDataTableSource(this.rowCount, this.columnCount);

  @override
  DataRow? getRow(int index) {
    if (index >= rowCount) return null;
    return DataRow.byIndex(
      index: index,
      cells: List<DataCell>.generate(
        columnCount,
        (columnIndex) => DataCell(Text('R${index + 1}C${columnIndex + 1}')),
      ),
    );
  }

  @override
  bool get isRowCountApproximate => false;
  @override
  int get selectedRowCount => 0;
}
1