null safety
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
|
||||
import 'carton_search.dart';
|
||||
|
||||
class CartonListRow extends StatefulWidget {
|
||||
final CallbackCartonSelect callbackCartonSelect;
|
||||
final Carton carton;
|
||||
final CallbackCartonSelect? callbackCartonSelect;
|
||||
final Carton? carton;
|
||||
|
||||
// const CartonListRow({this.carton, this.callbackCartonSelect});
|
||||
CartonListRow(
|
||||
{Key key, this.carton, this.callbackCartonSelect})
|
||||
{Key? key, this.carton, this.callbackCartonSelect})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -20,7 +20,7 @@ class CartonListRow extends StatefulWidget {
|
||||
|
||||
class _CartonListRowState extends State<CartonListRow> {
|
||||
final double dotSize = 15.0;
|
||||
Carton _carton;
|
||||
Carton? _carton;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -32,14 +32,14 @@ class _CartonListRowState extends State<CartonListRow> {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey[300]),
|
||||
bottom: BorderSide(color: Colors.grey.shade300),
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
if (widget.callbackCartonSelect != null)
|
||||
widget.callbackCartonSelect(widget.carton);
|
||||
widget.callbackCartonSelect!(widget.carton!);
|
||||
},
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
@@ -64,7 +64,7 @@ class _CartonListRowState extends State<CartonListRow> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text(
|
||||
_carton.cartonNumber ?? "",
|
||||
_carton!.cartonNumber,
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.black),
|
||||
),
|
||||
@@ -72,7 +72,7 @@ class _CartonListRowState extends State<CartonListRow> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, top: 10),
|
||||
child: new Text(
|
||||
_carton.userName ?? "",
|
||||
_carton!.userName,
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
@@ -86,7 +86,7 @@ class _CartonListRowState extends State<CartonListRow> {
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
"${_carton.cartonWeight?.toStringAsFixed(2) ?? ''} lb",
|
||||
"${_carton!.cartonWeight.toStringAsFixed(2)} lb",
|
||||
style: new TextStyle(
|
||||
fontSize: 15.0, color: Colors.grey),
|
||||
),
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/popupmenu.dart';
|
||||
import 'package:fcs/pagination/paginator_listview.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -18,15 +18,15 @@ import 'carton_list_row.dart';
|
||||
|
||||
typedef CallbackCartonSelect(Carton carton);
|
||||
|
||||
Future<Carton> searchCarton(BuildContext context,
|
||||
{CallbackCartonSelect callbackCartonSelect}) async =>
|
||||
Future<Carton?> searchCarton(BuildContext context,
|
||||
{CallbackCartonSelect? callbackCartonSelect}) async =>
|
||||
await showSearch<Carton>(
|
||||
context: context,
|
||||
delegate: PartSearchDelegate(callbackCartonSelect: callbackCartonSelect),
|
||||
);
|
||||
|
||||
class PartSearchDelegate extends SearchDelegate<Carton> {
|
||||
final CallbackCartonSelect callbackCartonSelect;
|
||||
final CallbackCartonSelect? callbackCartonSelect;
|
||||
PartSearchDelegate({this.callbackCartonSelect});
|
||||
|
||||
@override
|
||||
@@ -38,10 +38,10 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
|
||||
return theme.copyWith(
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
hintStyle: TextStyle(
|
||||
color: theme.primaryTextTheme.caption.color, fontSize: 14)),
|
||||
color: theme.primaryTextTheme.caption!.color, fontSize: 14)),
|
||||
textTheme: theme.textTheme.copyWith(
|
||||
title: theme.textTheme.title.copyWith(
|
||||
color: theme.primaryTextTheme.title.color, fontSize: 16)),
|
||||
title: theme.textTheme.title!.copyWith(
|
||||
color: theme.primaryTextTheme.title!.color, fontSize: 16)),
|
||||
primaryColor: primaryColor,
|
||||
);
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
|
||||
Widget buildLeading(BuildContext context) {
|
||||
return IconButton(
|
||||
icon: Icon(Icons.arrow_back),
|
||||
onPressed: () => close(context, null),
|
||||
onPressed: () => close(context, new Carton()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
|
||||
future: cartonModel.searchCarton(query),
|
||||
builder: (context, AsyncSnapshot<List<Carton>> snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
if (snapshot.data.length == 0) {
|
||||
if (snapshot.data!.length == 0) {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text(
|
||||
@@ -109,7 +109,7 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
child: ListView(
|
||||
children: snapshot.data
|
||||
children: snapshot.data!
|
||||
.map((u) => CartonListRow(
|
||||
key: ValueKey(u.id),
|
||||
carton: u,
|
||||
@@ -158,17 +158,17 @@ class PartSearchDelegate extends SearchDelegate<Carton> {
|
||||
}
|
||||
|
||||
_scan(BuildContext context) async {
|
||||
PermissionStatus permission =
|
||||
await PermissionHandler().checkPermissionStatus(PermissionGroup.camera);
|
||||
if (permission != PermissionStatus.granted) {
|
||||
Map<PermissionGroup, PermissionStatus> permissions =
|
||||
await PermissionHandler()
|
||||
.requestPermissions([PermissionGroup.camera]);
|
||||
if (permissions[PermissionGroup.camera] != PermissionStatus.granted) {
|
||||
showMsgDialog(context, "Error", "Camera permission is not granted");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// PermissionStatus permission =
|
||||
// await PermissionHandler().checkPermissionStatus(PermissionGroup.camera);
|
||||
// if (permission != PermissionStatus.granted) {
|
||||
// Map<PermissionGroup, PermissionStatus> permissions =
|
||||
// await PermissionHandler()
|
||||
// .requestPermissions([PermissionGroup.camera]);
|
||||
// if (permissions[PermissionGroup.camera] != PermissionStatus.granted) {
|
||||
// showMsgDialog(context, "Error", "Camera permission is not granted");
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
try {
|
||||
String barcode = await scanBarcode();
|
||||
|
||||
Reference in New Issue
Block a user