check null safety

This commit is contained in:
tzw
2021-09-10 14:27:38 +06:30
parent a144c945b6
commit 7670779b03
57 changed files with 620 additions and 626 deletions

View File

@@ -16,33 +16,33 @@ class RateDataProvider {
static final RateDataProvider instance = RateDataProvider._();
RateDataProvider._();
StreamController<Rate> controller;
late StreamController<Rate> controller;
static Rate _rate = Rate();
Stream<Rate> _rateStream() async* {
Stream<DocumentSnapshot> snapshot = Firestore.instance
Stream<DocumentSnapshot> snapshot = FirebaseFirestore.instance
.collection(config_collection)
.document(rate_doc_id)
.doc(rate_doc_id)
.snapshots();
await for (var snap in snapshot) {
Rate rate = Rate.fromMap(snap.data);
Rate rate = Rate.fromMap(snap.data() as Map<String, dynamic>);
yield rate;
}
}
Stream<List<CargoType>> _cargoTypeStream() async* {
List<CargoType> cargoTypes = [];
Stream<QuerySnapshot> snapshots = Firestore.instance
Stream<QuerySnapshot> snapshots = FirebaseFirestore.instance
.collection(config_collection)
.document(rate_doc_id)
.doc(rate_doc_id)
.collection(cargo_types_collection)
.where("custom_duty", isEqualTo: false)
.snapshots();
await for (var snaps in snapshots) {
cargoTypes = [];
cargoTypes = snaps.documents.map((snap) {
return CargoType.fromMap(snap.data, snap.documentID);
cargoTypes = snaps.docs.map((snap) {
return CargoType.fromMap(snap.data() as Map<String, dynamic>, snap.id);
}).toList();
yield cargoTypes;
@@ -51,17 +51,17 @@ class RateDataProvider {
Stream<List<CargoType>> _customDutiesStream() async* {
List<CargoType> customDuries = [];
Stream<QuerySnapshot> snapshots = Firestore.instance
Stream<QuerySnapshot> snapshots = FirebaseFirestore.instance
.collection(config_collection)
.document(rate_doc_id)
.doc(rate_doc_id)
.collection(cargo_types_collection)
.where("custom_duty", isEqualTo: true)
.snapshots();
await for (var snaps in snapshots) {
customDuries = [];
customDuries = snaps.documents.map((snap) {
return CargoType.fromMap(snap.data, snap.documentID);
customDuries = snaps.docs.map((snap) {
return CargoType.fromMap(snap.data() as Map<String, dynamic>, snap.id);
}).toList();
yield customDuries;
}
@@ -69,25 +69,26 @@ class RateDataProvider {
Stream<List<DiscountByWeight>> _discountByWeightStream() async* {
List<DiscountByWeight> discountByWeight = [];
Stream<QuerySnapshot> snapshots = Firestore.instance
Stream<QuerySnapshot> snapshots = FirebaseFirestore.instance
.collection(config_collection)
.document(rate_doc_id)
.doc(rate_doc_id)
.collection(discounts_by_weights_collection)
.snapshots();
await for (var snaps in snapshots) {
discountByWeight = [];
discountByWeight = snaps.documents.map((snap) {
return DiscountByWeight.fromMap(snap.data, snap.documentID);
discountByWeight = snaps.docs.map((snap) {
return DiscountByWeight.fromMap(
snap.data() as Map<String, dynamic>, snap.id);
}).toList();
yield discountByWeight;
}
}
StreamSubscription<Rate> rateListener;
StreamSubscription<List<CargoType>> cargoListener;
StreamSubscription<List<CargoType>> customListener;
StreamSubscription<List<DiscountByWeight>> discountListener;
late StreamSubscription<Rate> rateListener;
late StreamSubscription<List<CargoType>> cargoListener;
late StreamSubscription<List<CargoType>> customListener;
late StreamSubscription<List<DiscountByWeight>> discountListener;
Stream<Rate> rate() {
Future<void> _start() async {
rateListener = _rateStream().listen((rate) {