Skip to content

Commit b2a5e05

Browse files
committed
v2.0.1 - null check on Order vars, flutter format
1 parent a8a2239 commit b2a5e05

File tree

11 files changed

+63
-106
lines changed

11 files changed

+63
-106
lines changed

.idea/workspace.xml

Lines changed: 2 additions & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [2.0.1] - 2021-04-10
2+
3+
* null check on Order vars
4+
* flutter format
5+
16
## [2.0.0] - 2021-04-10
27

38
* Added null safety support

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ In your flutter project add the dependency:
1515
``` dart
1616
dependencies:
1717
...
18-
woosignal: ^2.0.0
18+
woosignal: ^2.0.1
1919
```
2020

2121
### Usage example #

example/lib/main.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ class _MyHomePageState extends State<MyHomePage> {
3030

3131
_incrementCounter() async {
3232
// CONFIG FOR WOOSIGNAL
33-
var wsConfig = {
34-
"appKey": "your app key",
35-
"debugMode": true
36-
};
33+
var wsConfig = {"appKey": "your app key", "debugMode": true};
3734

3835
// CREATING AN INSTANCE
3936
WooSignal wooSignal = await WooSignal.getInstance(config: wsConfig);

lib/models/payload/order_wc.dart

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@ class OrderWC {
5454
status = json['status'];
5555
currency = json['currency'];
5656
customerId = json['customer_id'];
57-
customerNote = json['customer_note'];
58-
parentId = json['parent_id'];
57+
if (json['customer_note'] != null) {
58+
customerNote = json['customer_note'];
59+
}
60+
if (json['parent_id']) {
61+
parentId = json['parent_id'];
62+
}
5963
if (json['meta_data'] != null) {
6064
metaData = [];
6165
json['meta_data'].forEach((v) {
@@ -100,9 +104,15 @@ class OrderWC {
100104
data['set_paid'] = this.setPaid;
101105
data['status'] = this.status;
102106
data['currency'] = this.currency;
103-
data['customer_id'] = this.customerId;
104-
data['customer_note'] = this.customerNote;
105-
data['parent_id'] = this.parentId;
107+
if (this.customerId != null) {
108+
data['customer_id'] = this.customerId;
109+
}
110+
if (this.customerNote != null) {
111+
data['customer_note'] = this.customerNote;
112+
}
113+
if (this.parentId != null) {
114+
data['parent_id'] = this.parentId;
115+
}
106116
if (this.metaData != null) {
107117
data['meta_data'] = this.metaData!.map((v) => v.toJson()).toList();
108118
}
@@ -358,8 +368,12 @@ class LineItems {
358368
if (this.taxClass != null) {
359369
data['tax_class'] = this.taxClass;
360370
}
361-
data['subtotal'] = this.subtotal;
362-
data['total'] = this.total;
371+
if (this.subtotal != null) {
372+
data['subtotal'] = this.subtotal;
373+
}
374+
if (data['total'] != null) {
375+
data['total'] = this.total;
376+
}
363377
data['quantity'] = this.quantity;
364378
return data;
365379
}

lib/models/response/continent.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ class Country {
9898
"name": name,
9999
"states": List<dynamic>.from(states!.map((x) => x.toJson())),
100100
"currency_code": currencyCode == null ? null : currencyCode,
101-
"currency_pos":
102-
currencyPos == null ? null : currencyPosValues.reverse![currencyPos!],
101+
"currency_pos": currencyPos == null
102+
? null
103+
: currencyPosValues.reverse![currencyPos!],
103104
"decimal_sep":
104105
decimalSep == null ? null : sepValues.reverse![decimalSep!],
105106
"dimension_unit": dimensionUnit == null

0 commit comments

Comments
 (0)