【问题标题】:change color of paginated datatable in flutter?在颤动中改变分页数据表的颜色?
【发布时间】:2021-07-21 00:13:09
【问题描述】:

我希望使用颤振改变分页数据表的颜色,

我使用深色主题和分页数据表采用该颜色,我也从颤振网站enter link description here阅读

使用这个 CardTheme,但是如何使用它.. 这是我的分页数据表的简单代码..

 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;
}

但现在我得到了这个

我需要将颜色设置为color: Color(0xff232d37), 任何帮助都可以得到帮助>>

问候

【问题讨论】:

    标签: flutter dart datatable flutter-layout flutter-web


    【解决方案1】:

    找到了,

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

    这解决了我的问题

    问候

    【讨论】:

      猜你喜欢
      • 2019-09-27
      • 2021-04-30
      • 1970-01-01
      • 2021-06-23
      • 1970-01-01
      • 2019-10-03
      • 2020-09-27
      • 1970-01-01
      • 2021-03-16
      相关资源
      最近更新 更多