3

i look to change the color of paginated datatable using flutter ,

i use dark themes and paginated datatable take that color , also i read from the flutter web site enter link description here

to use this CardTheme, but how to use it .. this my simple code for paginated datatable ..

 class DataTableDemo extends StatelessWidget {
  Widget build(BuildContext context) {
    print("tesat");

    MySource mySource = new MySource(
      // ["test1##test2", "test3##test4", "test5##test6", "test7##test8"],
      //  ["test1##test2", "test3##test4", "test5##test6", "test7##test8"]
      test2,
      test3,
    );

    return Container(
      // appBar: AppBar(
      //   title: Text('Data Tables'),
      // ),
      //backgroundColor: Color(0xff232d37),
      color: Color(0xff232d37),
      child: ListView(
        padding: const EdgeInsets.all(2),
        children: [
          PaginatedDataTable(
            //header: Text('Header Text'),
            rowsPerPage: 10,
            columns: [
              DataColumn(label: Text('Header A')),
              DataColumn(label: Text('Header B')),
              DataColumn(label: Text('Header C')),
            ],
            //source: _DataSource(context),
            source: mySource,
          ),
        ],
      ),
    );
  }
}


class MySource extends DataTableSource {
  List<String> value;
  List<String> test1;
  String a;
  String b;
  MySource(this.value, this.test1) {
    print(value);
  }

  @override
  DataRow getRow(int index) {
    // TODO: implement getRow
    // print('test');
    //test1 = value[index].split("");
    return DataRow.byIndex(
      //color: MaterialStateColor.resolveWith((states) => Colors.blue),
      index: index,
      cells: [
        DataCell(Text(value[index].toString())),
        DataCell(Text(test1[index].toString())),
        DataCell(
          InkWell(
            onTap: () {
              print((value[index]));
            },
            child: Text("Click"),
          ),
        ),
      ],
    );
  }

  @override
  // TODO: implement isRowCountApproximate
  bool get isRowCountApproximate => false;

  @override
  // TODO: implement rowCount
  int get rowCount => value.length;

  @override
  // TODO: implement selectedRowCount
  int get selectedRowCount => 0;
}

but now i got this enter image description here

i need to set color as the color: Color(0xff232d37), any help is apricated >>

regards

Lansen Portan
  • 131
  • 1
  • 7
  • Does this answer your question? [How to change color of a paginated datatable in flutter?](https://stackoverflow.com/questions/56062661/how-to-change-color-of-a-paginated-datatable-in-flutter) – Keegan Skeate Mar 12 '23 at 18:56

1 Answers1

6

found it ,

Theme(
        data: Theme.of(context)
            .copyWith(cardColor: Color(0xff232d37), dividerColor: Colors.green),
        child: ListView(

this solve my issue

regards

Lansen Portan
  • 131
  • 1
  • 7