null safety
This commit is contained in:
@@ -8,10 +8,10 @@ import 'package:flutter/material.dart';
|
||||
typedef OnSelect = Function(Carton carton, bool checked);
|
||||
|
||||
class CartonMixTable extends StatelessWidget {
|
||||
final List<Carton> cartons;
|
||||
final OnSelect onSelect;
|
||||
final List<Carton>? cartons;
|
||||
final OnSelect? onSelect;
|
||||
|
||||
const CartonMixTable({Key key, this.cartons, this.onSelect})
|
||||
const CartonMixTable({Key? key, this.cartons, this.onSelect})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -32,21 +32,21 @@ class CartonMixTable extends StatelessWidget {
|
||||
);
|
||||
|
||||
final rows = cartons == null
|
||||
? []
|
||||
: cartons.asMap().entries.map((p) {
|
||||
? [Container()]
|
||||
: cartons!.asMap().entries.map((p) {
|
||||
return Container(
|
||||
color: p.value.isChecked
|
||||
? Colors.grey.withOpacity(0.2)
|
||||
: Colors.grey[50].withOpacity(0.2),
|
||||
: Colors.grey.shade50.withOpacity(0.2),
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: 0.0, right: 10.0, top: 3.0, bottom: 3.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: p.key == cartons.length - 1
|
||||
color: p.key == cartons!.length - 1
|
||||
? Colors.white
|
||||
: Colors.grey[350],
|
||||
: Colors.grey.shade300,
|
||||
width: 1),
|
||||
),
|
||||
),
|
||||
@@ -55,16 +55,16 @@ class CartonMixTable extends StatelessWidget {
|
||||
Checkbox(
|
||||
value: p.value.isChecked,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (bool check) {
|
||||
if (onSelect != null) onSelect(p.value, check);
|
||||
onChanged: (bool? check) {
|
||||
if (onSelect != null) onSelect!(p.value, check!);
|
||||
}),
|
||||
Expanded(
|
||||
child: new Text(
|
||||
p.value.cartonNumber ?? "",
|
||||
p.value.cartonNumber,
|
||||
style: textStyle,
|
||||
)),
|
||||
new Text(
|
||||
p.value?.actualWeight?.toString() ?? "",
|
||||
p.value.actualWeight.toString(),
|
||||
style: textStyle,
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user