较新版本的flutter无法在DataRow()中设置颜色,但您可以在DataTable中设置颜色,如下例所示。
[![enter image description here][1]][1]DataTable(
headingRowColor:
MaterialStateColor.resolveWith((states) => Colors.blue),
dataRowColor: MaterialStateColor.resolveWith((states) => Colors.grey),
columns: const <DataColumn>[
DataColumn(
label: Text(
'Profesional',
style: TextStyle(fontStyle: FontStyle.italic,fontWeight: FontWeight.bold),
),
),
DataColumn(
label: Text(
'Entregados',
style: TextStyle(fontStyle: FontStyle.italic,fontWeight: FontWeight.bold),
),
),
DataColumn(
label: Text(
'Aceptado',
style: TextStyle(fontStyle: FontStyle.italic,fontWeight: FontWeight.bold),
),
),
DataColumn(
label: Text(
'Rechazado',
style: TextStyle(fontStyle: FontStyle.italic,fontWeight: FontWeight.bold),
),
),
DataColumn(
label: Text(
'Pendiente',
style: TextStyle(fontStyle: FontStyle.italic,fontWeight: FontWeight.bold),
),
),
DataColumn(
label: Text(
'Total',
style: TextStyle(fontStyle: FontStyle.italic,fontWeight: FontWeight.bold),
),
),
DataColumn(
label: Text(
'Precio Aceptado',
style: TextStyle(fontStyle: FontStyle.italic,fontWeight: FontWeight.bold),
),
),
DataColumn(
label: Text(
'Precio Rechazado',
style: TextStyle(fontStyle: FontStyle.italic,fontWeight: FontWeight.bold),
),
),
DataColumn(
label: Text(
'Precio Pendiente',
style: TextStyle(fontStyle: FontStyle.italic,fontWeight: FontWeight.bold),
),
),
],
rows: const <DataRow>[
DataRow(
cells: <DataCell>[
DataCell(Text('Iván Molina Pastor',style: TextStyle(color: Colors.blue),)),
DataCell(Text('1',style:TextStyle(color: Colors.blueAccent),)),
DataCell(Text('1',style: TextStyle(color: Colors.lightGreen),),),
DataCell(Text('0',style: TextStyle(color: Colors.redAccent),)),
DataCell(Text('0',style: TextStyle(color: Colors.orangeAccent),)),
DataCell(Text('€ 36.30',style: TextStyle(color: Colors.indigo),)),
DataCell(Text('€ 36.30',style: TextStyle(color: Colors.lightGreen),)),
DataCell(Text('€ 0.00',style: TextStyle(color: Colors.red),)),
DataCell(Text('€ 0.00',style: TextStyle(color: Colors.yellowAccent),)),
],
),
DataRow(
cells: <DataCell>[
DataCell(Text('Juan Celdran Alenda',style:TextStyle(color: Colors.blue),)),
DataCell(Text('3',style:TextStyle(color: Colors.blueAccent),)),
DataCell(Text('2',style: TextStyle(color: Colors.lightGreen),),),
DataCell(Text('0',style: TextStyle(color: Colors.redAccent),)),
DataCell(Text('0',style: TextStyle(color: Colors.orangeAccent),)),
DataCell(Text('€ 8,433.70',style: TextStyle(color: Colors.indigo),)),
DataCell(Text('€ 6,316.20',style: TextStyle(color: Colors.lightGreen),)),
DataCell(Text('€ 0.00',style: TextStyle(color: Colors.red),)),
DataCell(Text('€ 2,117.50',style: TextStyle(color: Colors.yellowAccent),)),
],
),
],
),