check null safety
This commit is contained in:
@@ -36,7 +36,7 @@ class _CartonSizeEditorState extends State<CartonSizeEditor> {
|
||||
if (widget.cartonSize != null) {
|
||||
_cartonSize = widget.cartonSize;
|
||||
_isNew = false;
|
||||
_nameController.text = _cartonSize!.name;
|
||||
_nameController.text = _cartonSize!.name ?? "";
|
||||
_widthController.text = _cartonSize!.width.toString();
|
||||
_heightController.text = _cartonSize!.height.toString();
|
||||
_lengthController.text = _cartonSize!.length.toString();
|
||||
|
||||
@@ -40,7 +40,7 @@ class _CartonSizeListState extends State<CartonSizeList> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
new Text(
|
||||
p.name,
|
||||
p.name ?? "",
|
||||
style: TextStyle(fontSize: 15.0),
|
||||
),
|
||||
Padding(
|
||||
@@ -135,7 +135,7 @@ class _CartonSizeListState extends State<CartonSizeList> {
|
||||
CartonSizeModel cartonSizeModel =
|
||||
Provider.of<CartonSizeModel>(context, listen: false);
|
||||
try {
|
||||
await cartonSizeModel.deleteCartonSize(cartonSize.id);
|
||||
await cartonSizeModel.deleteCartonSize(cartonSize.id!);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
|
||||
@@ -13,7 +13,7 @@ class CartonSizeModel extends BaseModel {
|
||||
List<CartonSize> cartonSizes = [];
|
||||
final log = Logger('CartonSizeModel');
|
||||
|
||||
StreamSubscription<QuerySnapshot> listener;
|
||||
StreamSubscription<QuerySnapshot>? listener;
|
||||
|
||||
List<CartonSize> get getCartonSizes {
|
||||
var _cartonSizes = new List<CartonSize>.from(cartonSizes);
|
||||
@@ -27,17 +27,18 @@ class CartonSizeModel extends BaseModel {
|
||||
|
||||
Future<void> _loadCartonSizes() async {
|
||||
try {
|
||||
if (listener != null) listener.cancel();
|
||||
if (listener != null) listener!.cancel();
|
||||
|
||||
listener = Firestore.instance
|
||||
listener = FirebaseFirestore.instance
|
||||
.collection(
|
||||
"/$config_collection/$setting_doc_id/$carton_sizes_collection")
|
||||
.snapshots()
|
||||
.listen((QuerySnapshot snapshot) {
|
||||
cartonSizes.clear();
|
||||
cartonSizes = snapshot.documents.map((documentSnapshot) {
|
||||
cartonSizes = snapshot.docs.map((documentSnapshot) {
|
||||
var c = CartonSize.fromMap(
|
||||
documentSnapshot.data, documentSnapshot.documentID);
|
||||
documentSnapshot.data() as Map<String, dynamic>,
|
||||
documentSnapshot.id);
|
||||
return c;
|
||||
}).toList();
|
||||
notifyListeners();
|
||||
@@ -49,7 +50,7 @@ class CartonSizeModel extends BaseModel {
|
||||
|
||||
@override
|
||||
logout() async {
|
||||
if (listener != null) await listener.cancel();
|
||||
if (listener != null) await listener!.cancel();
|
||||
cartonSizes = [];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user