null safety

This commit is contained in:
phyothandar
2021-09-10 12:00:08 +06:30
parent a144c945b6
commit 5e672937b5
67 changed files with 901 additions and 896 deletions

View File

@@ -9,11 +9,11 @@ import 'package:flutter/material.dart';
typedef OnSelect = Function(Carton carton, bool checked);
class InvoiceCartonTable extends StatelessWidget {
final List<Carton> cartons;
final OnSelect onSelect;
final Rate rate;
final List<Carton>? cartons;
final OnSelect? onSelect;
final Rate? rate;
const InvoiceCartonTable({Key key, this.cartons, this.onSelect, this.rate})
const InvoiceCartonTable({Key? key, this.cartons, this.onSelect, this.rate})
: super(key: key);
@override
@@ -36,20 +36,20 @@ class InvoiceCartonTable extends StatelessWidget {
final rows = cartons == null
? [Container()]
: cartons.asMap().entries.map((p) {
: 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),
),
),
@@ -64,8 +64,8 @@ class InvoiceCartonTable 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: Column(
@@ -82,15 +82,15 @@ class InvoiceCartonTable extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
new Text(
"${p.value?.length ?? ""} x ${p.value?.width ?? ""} x ${p.value?.height ?? ""}",
"${p.value.length} x ${p.value.width} x ${p.value.height}",
style: textStyle,
),
new Text(
"${p.value?.getShipmentWeight(rate.volumetricRatio)?.toStringAsFixed(2) ?? "0"} lb",
"${p.value.getShipmentWeight(rate!.volumetricRatio).toStringAsFixed(2)} lb",
style: textStyle,
),
new Text(
"${p.value?.actualWeight?.toStringAsFixed(2) ?? "0"} lb (Actual)",
"${p.value.actualWeight.toStringAsFixed(2)} lb (Actual)",
style: textStyle,
),
],