null safety

This commit is contained in:
Phaung Phaung
2021-09-10 16:48:20 +06:30
parent 52fe4b4568
commit 0f84fec2f7
12 changed files with 103 additions and 106 deletions

View File

@@ -135,7 +135,7 @@ class _DeliveryInfoState extends State<DeliveryInfo> {
final cartonTypeBox = LocalRadioButtons(
readOnly: true,
values: cartonModel.cartonTypesInfo,
selectedValue: _box.isShipmentCarton ?? false
selectedValue: (_box.isShipmentCarton ?? false)
? carton_from_shipments
: _box.cartonType);
final shipmentBox = DisplayText(

View File

@@ -14,18 +14,18 @@ class DeliveryModel extends BaseModel {
List<Carton> get cartons =>
_selectedIndex == 1 ? _cartons : List<Carton>.from(_delivered.values);
Paginator _delivered;
late Paginator _delivered;
int _selectedIndex = 1;
bool isLoading = false;
List<Carton> _cartons = [];
StreamSubscription<QuerySnapshot> listener;
StreamSubscription<QuerySnapshot>? listener;
set selectedIndex(int index) {
_selectedIndex = index;
notifyListeners();
}
get selectedIndex => _selectedIndex;
int get selectedIndex => _selectedIndex;
initData() {
_selectedIndex = 1;
@@ -37,9 +37,9 @@ class DeliveryModel extends BaseModel {
}
Future<void> _loadCartons() async {
if (user == null || !user.hasDeliveries()) return;
if (user == null || !user!.hasDeliveries()) return;
String path = "/$cartons_collection/";
if (listener != null) listener.cancel();
if (listener != null) listener!.cancel();
_cartons = [];
try {
listener = FirebaseFirestore.instance
@@ -55,9 +55,9 @@ class DeliveryModel extends BaseModel {
.snapshots()
.listen((QuerySnapshot snapshot) {
_cartons.clear();
_cartons = snapshot.documents.map((documentSnapshot) {
_cartons = snapshot.docs.map((documentSnapshot) {
var s = Carton.fromMap(
documentSnapshot.data, documentSnapshot.documentID);
documentSnapshot.data as Map<String, dynamic>, documentSnapshot.id);
return s;
}).toList();
notifyListeners();
@@ -68,9 +68,9 @@ class DeliveryModel extends BaseModel {
}
Paginator _getDelivered() {
if (user == null || !user.hasDeliveries()) return null;
if (user == null || !user!.hasDeliveries()) throw "No Privilege";
var pageQuery = Firestore.instance
var pageQuery = FirebaseFirestore.instance
.collection("/$cartons_collection")
.where("is_delivered", isEqualTo: true)
.where("status", whereIn: [carton_delivered_status]).where("is_deleted",
@@ -105,7 +105,7 @@ class DeliveryModel extends BaseModel {
@override
logout() async {
if (listener != null) await listener.cancel();
if (listener != null) await listener!.cancel();
if (_delivered != null) _delivered.close();
_cartons = [];
}