phase3(foundation): http_util dio5 migration + null-safe models
- http_util.dart: dio4->5 (DioException, nullable params, drop unused statusCode, null-safe e.response!.data), countryCode ?? '' - models/* (39 files): make all instance fields nullable (fromJson initializer-list pattern forces nullable); fix internal method usages (cart_info/cart_line_item/ order/shipping_rate) with !/?? - models/ now passes dart analyze with 0 errors Widget-level null-safety + remaining utils/store continue in next batch.
This commit is contained in:
@@ -4,9 +4,9 @@ import 'dart:convert';
|
|||||||
import 'package:flutter_wisetronic/models/product_attribute.dart';
|
import 'package:flutter_wisetronic/models/product_attribute.dart';
|
||||||
|
|
||||||
class Subproduct {
|
class Subproduct {
|
||||||
int id;
|
int? id;
|
||||||
SimpleProduct product;
|
SimpleProduct? product;
|
||||||
double quantity;
|
double? quantity;
|
||||||
|
|
||||||
Subproduct.fromJson(Map<String, dynamic> json) :
|
Subproduct.fromJson(Map<String, dynamic> json) :
|
||||||
id = json['id'],
|
id = json['id'],
|
||||||
@@ -26,15 +26,15 @@ class Subproduct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SimpleProduct {
|
class SimpleProduct {
|
||||||
int id;
|
int? id;
|
||||||
String name;
|
String? name;
|
||||||
String sku;
|
String? sku;
|
||||||
double price;
|
double? price;
|
||||||
String description;
|
String? description;
|
||||||
String image;
|
String? image;
|
||||||
List<ProductAttribute> productAttributes;
|
List<ProductAttribute>? productAttributes;
|
||||||
double customerLastPrice;
|
double? customerLastPrice;
|
||||||
String extraData;
|
String? extraData;
|
||||||
|
|
||||||
SimpleProduct.fromJson(Map<String, dynamic> json) :
|
SimpleProduct.fromJson(Map<String, dynamic> json) :
|
||||||
id = json['id'],
|
id = json['id'],
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class Address {
|
class Address {
|
||||||
int id;
|
int? id;
|
||||||
String addressLine1;
|
String? addressLine1;
|
||||||
String addressLine2;
|
String? addressLine2;
|
||||||
String city;
|
String? city;
|
||||||
String state;
|
String? state;
|
||||||
String country;
|
String? country;
|
||||||
String zip;
|
String? zip;
|
||||||
String phone;
|
String? phone;
|
||||||
String fax;
|
String? fax;
|
||||||
String email;
|
String? email;
|
||||||
String contactName;
|
String? contactName;
|
||||||
int gender;
|
int? gender;
|
||||||
String lat;
|
String? lat;
|
||||||
String lng;
|
String? lng;
|
||||||
String fullAddress;
|
String? fullAddress;
|
||||||
|
|
||||||
Address.fromJson(Map<String, dynamic> json)
|
Address.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class Section {
|
class Section {
|
||||||
int id;
|
int? id;
|
||||||
String name;
|
String? name;
|
||||||
|
|
||||||
Section.fromJson(Map<String, dynamic> json) :
|
Section.fromJson(Map<String, dynamic> json) :
|
||||||
id = json['id'],
|
id = json['id'],
|
||||||
@@ -21,14 +21,14 @@ class Section {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Blog {
|
class Blog {
|
||||||
int id;
|
int? id;
|
||||||
String title;
|
String? title;
|
||||||
String body;
|
String? body;
|
||||||
String createdAt;
|
String? createdAt;
|
||||||
String thumbUrl;
|
String? thumbUrl;
|
||||||
String imageUrl;
|
String? imageUrl;
|
||||||
String videoUrl;
|
String? videoUrl;
|
||||||
Section section;
|
Section? section;
|
||||||
|
|
||||||
Blog.fromJson(Map<String, dynamic> json) :
|
Blog.fromJson(Map<String, dynamic> json) :
|
||||||
id = json['id'],
|
id = json['id'],
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import 'dart:convert';
|
|||||||
import 'booking_time.dart';
|
import 'booking_time.dart';
|
||||||
|
|
||||||
class BookingDateTime {
|
class BookingDateTime {
|
||||||
String viewDate;
|
String? viewDate;
|
||||||
int unixTime;
|
int? unixTime;
|
||||||
String sendTimeTip;
|
String? sendTimeTip;
|
||||||
List<BookingTime> bookTimes;
|
List<BookingTime>? bookTimes;
|
||||||
|
|
||||||
BookingDateTime(this.viewDate, this.unixTime, this.sendTimeTip, this.bookTimes);
|
BookingDateTime(this.viewDate, this.unixTime, this.sendTimeTip, this.bookTimes);
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class BookingTime {
|
class BookingTime {
|
||||||
String viewTime;
|
String? viewTime;
|
||||||
int unixTime;
|
int? unixTime;
|
||||||
String sendTimeTip;
|
String? sendTimeTip;
|
||||||
|
|
||||||
BookingTime(this.viewTime, this.unixTime, this.sendTimeTip);
|
BookingTime(this.viewTime, this.unixTime, this.sendTimeTip);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import 'product.dart';
|
|||||||
import 'waiting_line.dart';
|
import 'waiting_line.dart';
|
||||||
|
|
||||||
class QuickInput {
|
class QuickInput {
|
||||||
String value;
|
String? value;
|
||||||
QuickInput.fromJson(Map<String, dynamic> json)
|
QuickInput.fromJson(Map<String, dynamic> json)
|
||||||
: value = json['value'];
|
: value = json['value'];
|
||||||
|
|
||||||
@@ -23,48 +23,48 @@ class QuickInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Business {
|
class Business {
|
||||||
int id;
|
int? id;
|
||||||
String name;
|
String? name;
|
||||||
String phone;
|
String? phone;
|
||||||
Address address;
|
Address? address;
|
||||||
String fullAddress;
|
String? fullAddress;
|
||||||
String picUrl;
|
String? picUrl;
|
||||||
int status;
|
int? status;
|
||||||
List<BusinessTime> openingTime;
|
List<BusinessTime>? openingTime;
|
||||||
double shippingFee;
|
double? shippingFee;
|
||||||
double packageFee;
|
double? packageFee;
|
||||||
double minPrice;
|
double? minPrice;
|
||||||
int shippingTime;
|
int? shippingTime;
|
||||||
int monthSales;
|
int? monthSales;
|
||||||
String bulletin;
|
String? bulletin;
|
||||||
int category;
|
int? category;
|
||||||
bool isLike;
|
bool? isLike;
|
||||||
String description;
|
String? description;
|
||||||
String policy;
|
String? policy;
|
||||||
String bannerImageUrl;
|
String? bannerImageUrl;
|
||||||
int todayOpen;
|
int? todayOpen;
|
||||||
int todayClose;
|
int? todayClose;
|
||||||
bool showMonthlySold;
|
bool? showMonthlySold;
|
||||||
List<ImageUrl> slideImages;
|
List<ImageUrl>? slideImages;
|
||||||
List<Product> promoProducts;
|
List<Product>? promoProducts;
|
||||||
String paypalEmail;
|
String? paypalEmail;
|
||||||
bool deliveryCanadaPost;
|
bool? deliveryCanadaPost;
|
||||||
bool deliveryStoreDelivery;
|
bool? deliveryStoreDelivery;
|
||||||
bool deliveryPickup;
|
bool? deliveryPickup;
|
||||||
String currency;
|
String? currency;
|
||||||
List<WaitingLine> waitingLine;
|
List<WaitingLine>? waitingLine;
|
||||||
bool enableWaitingLine;
|
bool? enableWaitingLine;
|
||||||
double pointsToCreditsConversionRate;
|
double? pointsToCreditsConversionRate;
|
||||||
String chaseXLogin;
|
String? chaseXLogin;
|
||||||
String chaseTransactionKey;
|
String? chaseTransactionKey;
|
||||||
String chaseResponseKey;
|
String? chaseResponseKey;
|
||||||
DistanceInfo distanceInfo;
|
DistanceInfo? distanceInfo;
|
||||||
int commentsCount;
|
int? commentsCount;
|
||||||
bool forceClose;
|
bool? forceClose;
|
||||||
bool isPublic;
|
bool? isPublic;
|
||||||
double referrerCoupon;
|
double? referrerCoupon;
|
||||||
bool instanceDelivery;
|
bool? instanceDelivery;
|
||||||
List<QuickInput> quickInputs;
|
List<QuickInput>? quickInputs;
|
||||||
|
|
||||||
Business.fromJson(Map<String, dynamic> json)
|
Business.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class BusinessTime {
|
class BusinessTime {
|
||||||
String openTime;
|
String? openTime;
|
||||||
String closeTime;
|
String? closeTime;
|
||||||
|
|
||||||
BusinessTime.fromJson(Map<String, dynamic> json)
|
BusinessTime.fromJson(Map<String, dynamic> json)
|
||||||
: openTime = json['open_time'],
|
: openTime = json['open_time'],
|
||||||
|
|||||||
@@ -7,18 +7,18 @@ import 'cart_line_item.dart';
|
|||||||
import 'extra_fee.dart';
|
import 'extra_fee.dart';
|
||||||
|
|
||||||
class CartInfo {
|
class CartInfo {
|
||||||
int id;
|
int? id;
|
||||||
double originPrice;
|
double? originPrice;
|
||||||
double discountPrice;
|
double? discountPrice;
|
||||||
double totalPrice;
|
double? totalPrice;
|
||||||
Business businessInfo;
|
Business? businessInfo;
|
||||||
List<CartLineItem> productList;
|
List<CartLineItem>? productList;
|
||||||
List<ExtraFee> extraFeeList;
|
List<ExtraFee>? extraFeeList;
|
||||||
List<ExtraFee> discountList;
|
List<ExtraFee>? discountList;
|
||||||
int deliveryMethod;
|
int? deliveryMethod;
|
||||||
String shippingMethod;
|
String? shippingMethod;
|
||||||
double amountPaid;
|
double? amountPaid;
|
||||||
String extraData;
|
String? extraData;
|
||||||
|
|
||||||
CartInfo.fromJson(Map<String, dynamic> json)
|
CartInfo.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
@@ -53,7 +53,7 @@ class CartInfo {
|
|||||||
if (productList == null) {
|
if (productList == null) {
|
||||||
productList = [item];
|
productList = [item];
|
||||||
} else {
|
} else {
|
||||||
productList.add(item);
|
productList!.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -74,19 +74,19 @@ class CartInfo {
|
|||||||
originPrice = 0.0;
|
originPrice = 0.0;
|
||||||
discountPrice = 0.0;
|
discountPrice = 0.0;
|
||||||
totalPrice = 0.0;
|
totalPrice = 0.0;
|
||||||
for (var i = 0; i < productList.length; i++) {
|
for (var i = 0; i < (productList?.length ?? 0); i++) {
|
||||||
newTotal += productList[i].getTotalPrice();
|
newTotal += productList![i].getTotalPrice();
|
||||||
}
|
}
|
||||||
originPrice = newTotal;
|
originPrice = newTotal;
|
||||||
totalPrice = newTotal;
|
totalPrice = newTotal;
|
||||||
return totalPrice;
|
return totalPrice ?? 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getProductListTotalQuantity() {
|
int getProductListTotalQuantity() {
|
||||||
int qty = 0;
|
int qty = 0;
|
||||||
if (productList != null && productList.length > 0) {
|
if (productList != null && productList!.length > 0) {
|
||||||
for (var i = 0; i < productList.length; i++) {
|
for (var i = 0; i < productList!.length; i++) {
|
||||||
qty += productList[i].quantity.round();
|
qty += (productList![i].quantity ?? 0).round();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return qty;
|
return qty;
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ import 'package:uuid/uuid.dart';
|
|||||||
import 'product.dart';
|
import 'product.dart';
|
||||||
|
|
||||||
class CartLineItem {
|
class CartLineItem {
|
||||||
int id;
|
int? id;
|
||||||
double unitPrice;
|
double? unitPrice;
|
||||||
double totalPrice;
|
double? totalPrice;
|
||||||
Product product;
|
Product? product;
|
||||||
String name;
|
String? name;
|
||||||
String description;
|
String? description;
|
||||||
double quantity;
|
double? quantity;
|
||||||
String uuid;
|
String? uuid;
|
||||||
String parentUuid;
|
String? parentUuid;
|
||||||
|
|
||||||
CartLineItem() {
|
CartLineItem() {
|
||||||
uuid = Uuid().v4();
|
uuid = Uuid().v4();
|
||||||
@@ -48,7 +48,7 @@ class CartLineItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double getTotalPrice() {
|
double getTotalPrice() {
|
||||||
totalPrice = unitPrice * quantity;
|
totalPrice = (unitPrice ?? 0.0) * (quantity ?? 0);
|
||||||
return totalPrice;
|
return totalPrice ?? 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class Category {
|
class Category {
|
||||||
int id;
|
int? id;
|
||||||
String name;
|
String? name;
|
||||||
|
|
||||||
Category.fromJson(Map<String, dynamic> json)
|
Category.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import 'dart:convert';
|
|||||||
import 'product.dart';
|
import 'product.dart';
|
||||||
|
|
||||||
class CategoryProducts {
|
class CategoryProducts {
|
||||||
int id;
|
int? id;
|
||||||
int businessId;
|
int? businessId;
|
||||||
String name;
|
String? name;
|
||||||
String description;
|
String? description;
|
||||||
String iconUrl;
|
String? iconUrl;
|
||||||
List<Product> products;
|
List<Product>? products;
|
||||||
|
|
||||||
CategoryProducts.fromJson(Map<String, dynamic> json)
|
CategoryProducts.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ import 'dart:convert';
|
|||||||
import 'product_image.dart';
|
import 'product_image.dart';
|
||||||
|
|
||||||
class Comment {
|
class Comment {
|
||||||
int id;
|
int? id;
|
||||||
String contact;
|
String? contact;
|
||||||
String content;
|
String? content;
|
||||||
int rating;
|
int? rating;
|
||||||
List<ProductImage> images;
|
List<ProductImage>? images;
|
||||||
String createdAt;
|
String? createdAt;
|
||||||
int thumbUp;
|
int? thumbUp;
|
||||||
int thumbDown;
|
int? thumbDown;
|
||||||
String replyFromStore;
|
String? replyFromStore;
|
||||||
|
|
||||||
Comment.fromJson(Map<String, dynamic> json) :
|
Comment.fromJson(Map<String, dynamic> json) :
|
||||||
id = json['id'],
|
id = json['id'],
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import 'dart:convert';
|
|||||||
import 'business.dart';
|
import 'business.dart';
|
||||||
|
|
||||||
class Coupon {
|
class Coupon {
|
||||||
int id;
|
int? id;
|
||||||
String code;
|
String? code;
|
||||||
String description;
|
String? description;
|
||||||
String expirationDate;
|
String? expirationDate;
|
||||||
double minAmount;
|
double? minAmount;
|
||||||
Business store;
|
Business? store;
|
||||||
double valueAmount;
|
double? valueAmount;
|
||||||
bool isPercentage;
|
bool? isPercentage;
|
||||||
|
|
||||||
Coupon.fromJson(Map<String, dynamic> json)
|
Coupon.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import 'dart:convert';
|
|||||||
import 'text_value.dart';
|
import 'text_value.dart';
|
||||||
|
|
||||||
class DistanceInfo {
|
class DistanceInfo {
|
||||||
TextValue duration;
|
TextValue? duration;
|
||||||
TextValue distance;
|
TextValue? distance;
|
||||||
String status;
|
String? status;
|
||||||
|
|
||||||
DistanceInfo.fromJson(Map<String, dynamic> json)
|
DistanceInfo.fromJson(Map<String, dynamic> json)
|
||||||
: duration = json['duration'] != null ? TextValue.fromJson(json['duration']) : null,
|
: duration = json['duration'] != null ? TextValue.fromJson(json['duration']) : null,
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class ErrorMessage {
|
class ErrorMessage {
|
||||||
String code;
|
String? code;
|
||||||
String string;
|
String? string;
|
||||||
|
|
||||||
ErrorMessage.fromJson(Map<String, dynamic> json)
|
ErrorMessage.fromJson(Map<String, dynamic> json)
|
||||||
: code = json['code'],
|
: code = json['code'],
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class ExtraFee {
|
class ExtraFee {
|
||||||
int id;
|
int? id;
|
||||||
String name;
|
String? name;
|
||||||
String description;
|
String? description;
|
||||||
double rate;
|
double? rate;
|
||||||
double price;
|
double? price;
|
||||||
|
|
||||||
ExtraFee.fromJson(Map<String, dynamic> json)
|
ExtraFee.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class Fulfillment {
|
class Fulfillment {
|
||||||
int id;
|
int? id;
|
||||||
String shippingMethod;
|
String? shippingMethod;
|
||||||
String trackingNumber;
|
String? trackingNumber;
|
||||||
String note;
|
String? note;
|
||||||
String createdAt;
|
String? createdAt;
|
||||||
|
|
||||||
Fulfillment.fromJson(Map<String, dynamic> json) :
|
Fulfillment.fromJson(Map<String, dynamic> json) :
|
||||||
id = json['id'],
|
id = json['id'],
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class Gallery {
|
class Gallery {
|
||||||
int id;
|
int? id;
|
||||||
String image;
|
String? image;
|
||||||
String linkUrl;
|
String? linkUrl;
|
||||||
|
|
||||||
Gallery.fromJson(Map<String, dynamic> json)
|
Gallery.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class Group {
|
class Group {
|
||||||
int id;
|
int? id;
|
||||||
String name;
|
String? name;
|
||||||
|
|
||||||
Group.fromJson(Map<String, dynamic> json) :
|
Group.fromJson(Map<String, dynamic> json) :
|
||||||
id = json['id'],
|
id = json['id'],
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class ImageUrl {
|
class ImageUrl {
|
||||||
int id;
|
int? id;
|
||||||
String imageUrl;
|
String? imageUrl;
|
||||||
|
|
||||||
ImageUrl.fromJson(Map<String, dynamic> json)
|
ImageUrl.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
class KeyValue {
|
class KeyValue {
|
||||||
String name;
|
String? name;
|
||||||
dynamic value;
|
dynamic? value;
|
||||||
|
|
||||||
KeyValue(this.name, this.value);
|
KeyValue(this.name, this.value);
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class LocatedAddress {
|
class LocatedAddress {
|
||||||
int storeId;
|
int? storeId;
|
||||||
double latitude;
|
double? latitude;
|
||||||
double longitude;
|
double? longitude;
|
||||||
String streetNumber;
|
String? streetNumber;
|
||||||
String streetName;
|
String? streetName;
|
||||||
String city;
|
String? city;
|
||||||
String locality;
|
String? locality;
|
||||||
String province;
|
String? province;
|
||||||
String country;
|
String? country;
|
||||||
String postalCode;
|
String? postalCode;
|
||||||
String formattedAddress;
|
String? formattedAddress;
|
||||||
|
|
||||||
LocatedAddress.fromJson(Map<String, dynamic> json)
|
LocatedAddress.fromJson(Map<String, dynamic> json)
|
||||||
: storeId = json['store_id'],
|
: storeId = json['store_id'],
|
||||||
|
|||||||
@@ -11,33 +11,33 @@ import 'fulfillment.dart';
|
|||||||
import 'user_position.dart';
|
import 'user_position.dart';
|
||||||
|
|
||||||
class Order {
|
class Order {
|
||||||
int id;
|
int? id;
|
||||||
int userId;
|
int? userId;
|
||||||
int businessId;
|
int? businessId;
|
||||||
Business businessInfo;
|
Business? businessInfo;
|
||||||
CartInfo cartInfo;
|
CartInfo? cartInfo;
|
||||||
int status;
|
int? status;
|
||||||
double originPrice;
|
double? originPrice;
|
||||||
double discountPrice;
|
double? discountPrice;
|
||||||
double totalPrice;
|
double? totalPrice;
|
||||||
String consignee;
|
String? consignee;
|
||||||
String phone;
|
String? phone;
|
||||||
String address;
|
String? address;
|
||||||
Address shippingAddress;
|
Address? shippingAddress;
|
||||||
int payMethod;
|
int? payMethod;
|
||||||
String remark;
|
String? remark;
|
||||||
String orderNum;
|
String? orderNum;
|
||||||
int bookedAt;
|
int? bookedAt;
|
||||||
int createdAt;
|
int? createdAt;
|
||||||
String shippingMethod;
|
String? shippingMethod;
|
||||||
String paymentStatus; // UNPAID, PAID, PARTIALPAID
|
String paymentStatus; // UNPAID, PAID, PARTIALPAID
|
||||||
double amountPaid;
|
double? amountPaid;
|
||||||
List<Fulfillment> fulfillments;
|
List<Fulfillment>? fulfillments;
|
||||||
String extraData;
|
String? extraData;
|
||||||
bool hasComment;
|
bool? hasComment;
|
||||||
double fee;
|
double? fee;
|
||||||
UserPosition shipperPosition;
|
UserPosition? shipperPosition;
|
||||||
DistanceInfo deliveryDistance;
|
DistanceInfo? deliveryDistance;
|
||||||
|
|
||||||
Order.fromJson(Map<String, dynamic> json)
|
Order.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
@@ -100,7 +100,7 @@ class Order {
|
|||||||
|
|
||||||
double getSubtotal() {
|
double getSubtotal() {
|
||||||
double subtotal = 0.0;
|
double subtotal = 0.0;
|
||||||
for (CartLineItem lineItem in cartInfo.productList) {
|
for (CartLineItem lineItem in cartInfo?.productList ?? <CartLineItem>[]) {
|
||||||
subtotal += lineItem.getTotalPrice();
|
subtotal += lineItem.getTotalPrice();
|
||||||
}
|
}
|
||||||
return subtotal;
|
return subtotal;
|
||||||
|
|||||||
@@ -6,19 +6,19 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import '../generated/l10n.dart';
|
import '../generated/l10n.dart';
|
||||||
|
|
||||||
class PaymentPlatform {
|
class PaymentPlatform {
|
||||||
int id;
|
int? id;
|
||||||
String name;
|
String? name;
|
||||||
String code;
|
String? code;
|
||||||
String method;
|
String? method;
|
||||||
String icon;
|
String? icon;
|
||||||
String xLogin;
|
String? xLogin;
|
||||||
String transactionKey;
|
String? transactionKey;
|
||||||
String responseKey;
|
String? responseKey;
|
||||||
String squareAppId;
|
String? squareAppId;
|
||||||
String squareAccessToken;
|
String? squareAccessToken;
|
||||||
String squareLocationId;
|
String? squareLocationId;
|
||||||
String publishableKey;
|
String? publishableKey;
|
||||||
String merchantId;
|
String? merchantId;
|
||||||
|
|
||||||
PaymentPlatform(this.code);
|
PaymentPlatform(this.code);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
class Position {
|
class Position {
|
||||||
final double latitude;
|
final double? latitude;
|
||||||
final double longitude;
|
final double? longitude;
|
||||||
|
|
||||||
Position({this.latitude, this.longitude});
|
Position({this.latitude, this.longitude});
|
||||||
|
|
||||||
|
|||||||
@@ -5,23 +5,23 @@ import 'Subproduct.dart';
|
|||||||
import 'product_attribute.dart';
|
import 'product_attribute.dart';
|
||||||
|
|
||||||
class Product {
|
class Product {
|
||||||
int id;
|
int? id;
|
||||||
int businessId;
|
int? businessId;
|
||||||
int categoryId;
|
int? categoryId;
|
||||||
String name;
|
String? name;
|
||||||
double price;
|
double? price;
|
||||||
double regularPrice;
|
double? regularPrice;
|
||||||
String description;
|
String? description;
|
||||||
String detailDescription;
|
String? detailDescription;
|
||||||
String imagePath;
|
String? imagePath;
|
||||||
String secondImagePath;
|
String? secondImagePath;
|
||||||
double monthSales;
|
double? monthSales;
|
||||||
int rate;
|
int? rate;
|
||||||
double leftNum;
|
double? leftNum;
|
||||||
List<ProductAttribute> productAttributes;
|
List<ProductAttribute>? productAttributes;
|
||||||
bool nonInventory;
|
bool? nonInventory;
|
||||||
String extraData;
|
String? extraData;
|
||||||
List<Subproduct> subproducts;
|
List<Subproduct>? subproducts;
|
||||||
|
|
||||||
Product(int id, int businessId, String name, double price, String description,
|
Product(int id, int businessId, String name, double price, String description,
|
||||||
String imagePath, List<ProductAttribute> productAttributes) {
|
String imagePath, List<ProductAttribute> productAttributes) {
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import 'dart:convert';
|
|||||||
import 'product_option.dart';
|
import 'product_option.dart';
|
||||||
|
|
||||||
class ProductAttribute {
|
class ProductAttribute {
|
||||||
int id;
|
int? id;
|
||||||
String name;
|
String? name;
|
||||||
List<ProductOption> productOptions;
|
List<ProductOption>? productOptions;
|
||||||
bool singleSelection;
|
bool? singleSelection;
|
||||||
bool byQuantity;
|
bool? byQuantity;
|
||||||
bool required;
|
bool? required;
|
||||||
String extra;
|
String? extra;
|
||||||
bool disabled;
|
bool? disabled;
|
||||||
|
|
||||||
ProductAttribute.fromJson(Map<String, dynamic> json)
|
ProductAttribute.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -8,30 +8,30 @@ import 'product_attribute.dart';
|
|||||||
import 'product_image.dart';
|
import 'product_image.dart';
|
||||||
|
|
||||||
class ProductDetail {
|
class ProductDetail {
|
||||||
int id;
|
int? id;
|
||||||
String image;
|
String? image;
|
||||||
List<ProductImage> images;
|
List<ProductImage>? images;
|
||||||
String sku;
|
String? sku;
|
||||||
String name;
|
String? name;
|
||||||
double price;
|
double? price;
|
||||||
double regularPrice;
|
double? regularPrice;
|
||||||
String description;
|
String? description;
|
||||||
String description2;
|
String? description2;
|
||||||
String detailDescription;
|
String? detailDescription;
|
||||||
double monthSales;
|
double? monthSales;
|
||||||
int rate;
|
int? rate;
|
||||||
double leftNum;
|
double? leftNum;
|
||||||
List<ProductAttribute> productAttributes;
|
List<ProductAttribute>? productAttributes;
|
||||||
bool nonInventory;
|
bool? nonInventory;
|
||||||
String extraData;
|
String? extraData;
|
||||||
String purchaseNote;
|
String? purchaseNote;
|
||||||
double weight;
|
double? weight;
|
||||||
double dimentionsLength;
|
double? dimentionsLength;
|
||||||
double dimentionsWidth;
|
double? dimentionsWidth;
|
||||||
double dimentionsHeight;
|
double? dimentionsHeight;
|
||||||
bool reviewsAllowed;
|
bool? reviewsAllowed;
|
||||||
List<Category> categories;
|
List<Category>? categories;
|
||||||
List<Subproduct> subproducts;
|
List<Subproduct>? subproducts;
|
||||||
|
|
||||||
ProductDetail.fromJson(Map<String, dynamic> json)
|
ProductDetail.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class ProductImage {
|
class ProductImage {
|
||||||
int id;
|
int? id;
|
||||||
String image;
|
String? image;
|
||||||
|
|
||||||
ProductImage.fromJson(Map<String, dynamic> json)
|
ProductImage.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class ProductOption {
|
class ProductOption {
|
||||||
int id;
|
int? id;
|
||||||
String name;
|
String? name;
|
||||||
double adjustAmount;
|
double? adjustAmount;
|
||||||
String extra;
|
String? extra;
|
||||||
bool disabled;
|
bool? disabled;
|
||||||
|
|
||||||
ProductOption.fromJson(Map<String, dynamic> json)
|
ProductOption.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import 'dart:convert';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
class ShippingRate {
|
class ShippingRate {
|
||||||
String name;
|
String? name;
|
||||||
double price;
|
double? price;
|
||||||
List<Rate> rates;
|
List<Rate>? rates;
|
||||||
|
|
||||||
ShippingRate.fromJson(Map<String, dynamic> json)
|
ShippingRate.fromJson(Map<String, dynamic> json)
|
||||||
: name = json['name'],
|
: name = json['name'],
|
||||||
@@ -25,7 +25,7 @@ class ShippingRate {
|
|||||||
other is ShippingRate &&
|
other is ShippingRate &&
|
||||||
runtimeType == other.runtimeType &&
|
runtimeType == other.runtimeType &&
|
||||||
name == other.name &&
|
name == other.name &&
|
||||||
price.toStringAsFixed(2) == other.price.toStringAsFixed(2) &&
|
price?.toStringAsFixed(2) == other.price?.toStringAsFixed(2) &&
|
||||||
listEquals(rates, other.rates);
|
listEquals(rates, other.rates);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -41,8 +41,8 @@ class ShippingRate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Rate {
|
class Rate {
|
||||||
String name;
|
String? name;
|
||||||
double rate;
|
double? rate;
|
||||||
|
|
||||||
Rate.fromJson(Map<String, dynamic> json)
|
Rate.fromJson(Map<String, dynamic> json)
|
||||||
: name = json['name'],
|
: name = json['name'],
|
||||||
@@ -59,7 +59,7 @@ class Rate {
|
|||||||
other is Rate &&
|
other is Rate &&
|
||||||
runtimeType == other.runtimeType &&
|
runtimeType == other.runtimeType &&
|
||||||
name == other.name &&
|
name == other.name &&
|
||||||
rate.toStringAsFixed(2) == other.rate.toStringAsFixed(2);
|
rate?.toStringAsFixed(2) == other.rate?.toStringAsFixed(2);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import 'dart:convert';
|
|||||||
import 'address.dart';
|
import 'address.dart';
|
||||||
|
|
||||||
class Store {
|
class Store {
|
||||||
int id;
|
int? id;
|
||||||
String name;
|
String? name;
|
||||||
Address address;
|
Address? address;
|
||||||
|
|
||||||
Store.fromJson(Map<String, dynamic> json)
|
Store.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class SimpleProduct {
|
class SimpleProduct {
|
||||||
int id;
|
int? id;
|
||||||
String name;
|
String? name;
|
||||||
double price;
|
double? price;
|
||||||
double regularPrice;
|
double? regularPrice;
|
||||||
String description;
|
String? description;
|
||||||
String imagePath;
|
String? imagePath;
|
||||||
|
|
||||||
SimpleProduct.fromJson(Map<String, dynamic> json)
|
SimpleProduct.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class TextValue {
|
class TextValue {
|
||||||
String text;
|
String? text;
|
||||||
int value;
|
int? value;
|
||||||
|
|
||||||
TextValue.fromJson(Map<String, dynamic> json)
|
TextValue.fromJson(Map<String, dynamic> json)
|
||||||
: text = json['text'],
|
: text = json['text'],
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import 'dart:convert';
|
|||||||
import 'simple_business.dart';
|
import 'simple_business.dart';
|
||||||
|
|
||||||
class TicketFile {
|
class TicketFile {
|
||||||
int id;
|
int? id;
|
||||||
String url;
|
String? url;
|
||||||
String fileName;
|
String? fileName;
|
||||||
String fileType;
|
String? fileType;
|
||||||
|
|
||||||
TicketFile.fromJson(Map<String, dynamic> json)
|
TicketFile.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
@@ -29,9 +29,9 @@ class TicketFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Issue {
|
class Issue {
|
||||||
int id;
|
int? id;
|
||||||
String msg;
|
String? msg;
|
||||||
List<TicketFile> files;
|
List<TicketFile>? files;
|
||||||
|
|
||||||
Issue.fromJson(Map<String, dynamic> json)
|
Issue.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
@@ -51,11 +51,11 @@ class Issue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FollowUp {
|
class FollowUp {
|
||||||
int id;
|
int? id;
|
||||||
String msg;
|
String? msg;
|
||||||
String poster;
|
String? poster;
|
||||||
String createdAt;
|
String? createdAt;
|
||||||
List<TicketFile> files;
|
List<TicketFile>? files;
|
||||||
|
|
||||||
FollowUp.fromJson(Map<String, dynamic> json)
|
FollowUp.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
@@ -79,12 +79,12 @@ class FollowUp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Ticket {
|
class Ticket {
|
||||||
int id;
|
int? id;
|
||||||
Issue issue;
|
Issue? issue;
|
||||||
Store store;
|
Store? store;
|
||||||
List<FollowUp> followUps;
|
List<FollowUp>? followUps;
|
||||||
bool isClosed;
|
bool? isClosed;
|
||||||
String createdAt;
|
String? createdAt;
|
||||||
|
|
||||||
Ticket.fromJson(Map<String, dynamic> json)
|
Ticket.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -2,22 +2,22 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class User {
|
class User {
|
||||||
int id;
|
int? id;
|
||||||
String username;
|
String? username;
|
||||||
String nickname;
|
String? nickname;
|
||||||
String mobile;
|
String? mobile;
|
||||||
String email;
|
String? email;
|
||||||
String avatarUrl;
|
String? avatarUrl;
|
||||||
int lastAddressId;
|
int? lastAddressId;
|
||||||
String passCode;
|
String? passCode;
|
||||||
double credit;
|
double? credit;
|
||||||
double wallet;
|
double? wallet;
|
||||||
int coupon;
|
int? coupon;
|
||||||
int points;
|
int? points;
|
||||||
int orderNum;
|
int? orderNum;
|
||||||
double pointsToCreditsConversionRate;
|
double? pointsToCreditsConversionRate;
|
||||||
String contactNumber;
|
String? contactNumber;
|
||||||
String flutterMiniStoreToken;
|
String? flutterMiniStoreToken;
|
||||||
|
|
||||||
User.fromJson(Map<String, dynamic> json)
|
User.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class UserPosition {
|
class UserPosition {
|
||||||
double lat;
|
double? lat;
|
||||||
double lng;
|
double? lng;
|
||||||
|
|
||||||
UserPosition.fromJson(Map<String, dynamic> json) :
|
UserPosition.fromJson(Map<String, dynamic> json) :
|
||||||
lat = double.parse(json['lat'].toString()),
|
lat = double.parse(json['lat'].toString()),
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import 'dart:convert';
|
|||||||
import 'waiting_line_item.dart';
|
import 'waiting_line_item.dart';
|
||||||
|
|
||||||
class WaitingLine {
|
class WaitingLine {
|
||||||
List<WaitingLineItem> waitingLines;
|
List<WaitingLineItem>? waitingLines;
|
||||||
String storeSn;
|
String? storeSn;
|
||||||
|
|
||||||
WaitingLine.fromJson(Map<String, dynamic> json)
|
WaitingLine.fromJson(Map<String, dynamic> json)
|
||||||
: waitingLines = (json['waiting_lines'] as List).map((i) => WaitingLineItem.fromJson(i)).toList(),
|
: waitingLines = (json['waiting_lines'] as List).map((i) => WaitingLineItem.fromJson(i)).toList(),
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class WaitingLineItem {
|
class WaitingLineItem {
|
||||||
String deviceId;
|
String? deviceId;
|
||||||
String phone;
|
String? phone;
|
||||||
String createdAt;
|
String? createdAt;
|
||||||
int peopleCount;
|
int? peopleCount;
|
||||||
int waitingNumber;
|
int? waitingNumber;
|
||||||
|
|
||||||
WaitingLineItem.fromJson(Map<String, dynamic> json)
|
WaitingLineItem.fromJson(Map<String, dynamic> json)
|
||||||
: deviceId = json['device_id'],
|
: deviceId = json['device_id'],
|
||||||
|
|||||||
@@ -14,10 +14,8 @@ import '../constants.dart';
|
|||||||
|
|
||||||
typedef void PostCallback(Response response);
|
typedef void PostCallback(Response response);
|
||||||
|
|
||||||
String generateSignature(String string, {String key}) {
|
String generateSignature(String string, {String? key}) {
|
||||||
if (key == null) {
|
key ??= Constants.API_SECRET;
|
||||||
key = Constants.API_SECRET;
|
|
||||||
}
|
|
||||||
Hmac mac = new Hmac(sha256, utf8.encode(key));
|
Hmac mac = new Hmac(sha256, utf8.encode(key));
|
||||||
Digest digest = mac.convert(utf8.encode(string + key));
|
Digest digest = mac.convert(utf8.encode(string + key));
|
||||||
String base64Mac = base64.encode(utf8.encode("$digest"));
|
String base64Mac = base64.encode(utf8.encode("$digest"));
|
||||||
@@ -38,16 +36,16 @@ class HttpUtil {
|
|||||||
'Http-Device-Type': Utils.getOs(checkWeb: true),
|
'Http-Device-Type': Utils.getOs(checkWeb: true),
|
||||||
'Http-Api-Branch': 'flutter',
|
'Http-Api-Branch': 'flutter',
|
||||||
'Http-Language-Code': store.state.locale.languageCode,
|
'Http-Language-Code': store.state.locale.languageCode,
|
||||||
'Http-Country-Code': store.state.locale.countryCode,
|
'Http-Country-Code': store.state.locale.countryCode ?? '',
|
||||||
};
|
};
|
||||||
|
|
||||||
static Future<dynamic> httpGet(String url,
|
static Future<dynamic> httpGet(String url,
|
||||||
{
|
{
|
||||||
Map<String, dynamic> queryParameters,
|
Map<String, dynamic>? queryParameters,
|
||||||
int businessId = 0,
|
int businessId = 0,
|
||||||
Function(int, int) receiveProgress,
|
Function(int, int)? receiveProgress,
|
||||||
bool returnError = false,
|
bool returnError = false,
|
||||||
Map<String, String> additionalHeaders,
|
Map<String, String>? additionalHeaders,
|
||||||
}) async {
|
}) async {
|
||||||
Map<String, dynamic> localHeaders = json.decode(json.encode(headers));
|
Map<String, dynamic> localHeaders = json.decode(json.encode(headers));
|
||||||
if (additionalHeaders != null) {
|
if (additionalHeaders != null) {
|
||||||
@@ -69,7 +67,7 @@ class HttpUtil {
|
|||||||
requestUrl = url;
|
requestUrl = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.jsonPrettyPrint(queryParameters);
|
Utils.jsonPrettyPrint(queryParameters ?? {});
|
||||||
|
|
||||||
Dio dio = Dio();
|
Dio dio = Dio();
|
||||||
try {
|
try {
|
||||||
@@ -84,9 +82,8 @@ class HttpUtil {
|
|||||||
// print('response data: ${response.data}');
|
// print('response data: ${response.data}');
|
||||||
// Utils.jsonPrettyPrint(response.data);
|
// Utils.jsonPrettyPrint(response.data);
|
||||||
|
|
||||||
int statusCode = response.statusCode;
|
|
||||||
return response.data;
|
return response.data;
|
||||||
} on DioError catch(e) {
|
} on DioException catch(e) {
|
||||||
print('HttpGet failed, request: $requestUrl, headers: $localHeaders, error ${e.response}');
|
print('HttpGet failed, request: $requestUrl, headers: $localHeaders, error ${e.response}');
|
||||||
if (returnError) {
|
if (returnError) {
|
||||||
return e;
|
return e;
|
||||||
@@ -97,14 +94,14 @@ class HttpUtil {
|
|||||||
|
|
||||||
static Future<dynamic> httpPost(String url, PostCallback callback,
|
static Future<dynamic> httpPost(String url, PostCallback callback,
|
||||||
{
|
{
|
||||||
Map<String, dynamic> queryParameters,
|
Map<String, dynamic>? queryParameters,
|
||||||
int businessId = 0,
|
int businessId = 0,
|
||||||
bool isFormData = false,
|
bool isFormData = false,
|
||||||
Map<String, String> additionalHeaders,
|
Map<String, String>? additionalHeaders,
|
||||||
Map<String, dynamic> body,
|
Map<String, dynamic>? body,
|
||||||
FormData formData,
|
FormData? formData,
|
||||||
Function(int, int) sendProgress,
|
Function(int, int)? sendProgress,
|
||||||
Function(int, int) receiveProgress,
|
Function(int, int)? receiveProgress,
|
||||||
bool returnError = false,
|
bool returnError = false,
|
||||||
}) async {
|
}) async {
|
||||||
|
|
||||||
@@ -130,15 +127,15 @@ class HttpUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Don't print body will cause upload Multipart file failed
|
// Don't print body will cause upload Multipart file failed
|
||||||
//Utils.jsonPrettyPrint(body);
|
//Utils.jsonPrettyPrint(body ?? {});
|
||||||
|
|
||||||
Dio dio = Dio();
|
Dio dio = Dio();
|
||||||
dio.interceptors.add(LogInterceptor());
|
dio.interceptors.add(LogInterceptor());
|
||||||
try {
|
try {
|
||||||
Response response = await dio.post(
|
Response response = await dio.post(
|
||||||
requestUrl,
|
requestUrl,
|
||||||
queryParameters: queryParameters == null ? {} : queryParameters,
|
queryParameters: queryParameters ?? {},
|
||||||
data: isFormData ? ((formData != null)?formData:FormData.fromMap(body)) : json.encode(body),
|
data: isFormData ? ((formData != null)?formData:FormData.fromMap(body ?? {})) : json.encode(body),
|
||||||
options: Options(
|
options: Options(
|
||||||
headers: localHeaders,
|
headers: localHeaders,
|
||||||
contentType: isFormData ? Headers.formUrlEncodedContentType : Headers.jsonContentType,
|
contentType: isFormData ? Headers.formUrlEncodedContentType : Headers.jsonContentType,
|
||||||
@@ -149,17 +146,16 @@ class HttpUtil {
|
|||||||
|
|
||||||
// Utils.jsonPrettyPrint(response.data);
|
// Utils.jsonPrettyPrint(response.data);
|
||||||
|
|
||||||
int statusCode = response.statusCode;
|
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback(response);
|
callback(response);
|
||||||
}
|
}
|
||||||
return response.data;
|
return response.data;
|
||||||
} on DioError catch(e, stacktrace) {
|
} on DioException catch(e, stacktrace) {
|
||||||
if (e.response != null) {
|
if (e.response != null) {
|
||||||
try {
|
try {
|
||||||
Utils.jsonPrettyPrint(e.response.data);
|
Utils.jsonPrettyPrint(e.response!.data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
print(e.response.data);
|
print(e.response!.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (returnError) {
|
if (returnError) {
|
||||||
@@ -171,12 +167,12 @@ class HttpUtil {
|
|||||||
|
|
||||||
static Future<dynamic> httpPut(String url, PostCallback callback,
|
static Future<dynamic> httpPut(String url, PostCallback callback,
|
||||||
{
|
{
|
||||||
Map<String, dynamic> queryParameters,
|
Map<String, dynamic>? queryParameters,
|
||||||
int businessId = 0,
|
int businessId = 0,
|
||||||
Map<String, String> additionalHeaders,
|
Map<String, String>? additionalHeaders,
|
||||||
Map<String, dynamic> body,
|
Map<String, dynamic>? body,
|
||||||
Function(int, int) sendProgress,
|
Function(int, int)? sendProgress,
|
||||||
Function(int, int) receiveProgress,
|
Function(int, int)? receiveProgress,
|
||||||
bool returnError = false,
|
bool returnError = false,
|
||||||
}) async {
|
}) async {
|
||||||
|
|
||||||
@@ -207,7 +203,7 @@ class HttpUtil {
|
|||||||
try {
|
try {
|
||||||
Response response = await dio.put(
|
Response response = await dio.put(
|
||||||
requestUrl,
|
requestUrl,
|
||||||
queryParameters: queryParameters == null ? {} : queryParameters,
|
queryParameters: queryParameters ?? {},
|
||||||
data: json.encode(body),
|
data: json.encode(body),
|
||||||
options: Options(
|
options: Options(
|
||||||
headers: localHeaders,
|
headers: localHeaders,
|
||||||
@@ -218,14 +214,13 @@ class HttpUtil {
|
|||||||
|
|
||||||
// Utils.jsonPrettyPrint(response.data);
|
// Utils.jsonPrettyPrint(response.data);
|
||||||
|
|
||||||
int statusCode = response.statusCode;
|
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback(response);
|
callback(response);
|
||||||
}
|
}
|
||||||
return response.data;
|
return response.data;
|
||||||
} on DioError catch(e) {
|
} on DioException catch(e) {
|
||||||
if (e.response != null) {
|
if (e.response != null) {
|
||||||
Utils.jsonPrettyPrint(e.response.data);
|
Utils.jsonPrettyPrint(e.response!.data);
|
||||||
}
|
}
|
||||||
if (returnError) {
|
if (returnError) {
|
||||||
return e;
|
return e;
|
||||||
@@ -236,12 +231,12 @@ class HttpUtil {
|
|||||||
|
|
||||||
static Future<dynamic> httpPatch(String url, PostCallback callback,
|
static Future<dynamic> httpPatch(String url, PostCallback callback,
|
||||||
{
|
{
|
||||||
Map<String, dynamic> queryParameters,
|
Map<String, dynamic>? queryParameters,
|
||||||
int businessId = 0,
|
int businessId = 0,
|
||||||
Map<String, String> additionalHeaders,
|
Map<String, String>? additionalHeaders,
|
||||||
Map<String, dynamic> body,
|
Map<String, dynamic>? body,
|
||||||
Function(int, int) sendProgress,
|
Function(int, int)? sendProgress,
|
||||||
Function(int, int) receiveProgress,
|
Function(int, int)? receiveProgress,
|
||||||
bool returnError = false,
|
bool returnError = false,
|
||||||
}) async {
|
}) async {
|
||||||
|
|
||||||
@@ -268,13 +263,13 @@ class HttpUtil {
|
|||||||
requestUrl = url;
|
requestUrl = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.jsonPrettyPrint(body);
|
Utils.jsonPrettyPrint(body ?? {});
|
||||||
|
|
||||||
Dio dio = Dio();
|
Dio dio = Dio();
|
||||||
try {
|
try {
|
||||||
Response response = await dio.patch(
|
Response response = await dio.patch(
|
||||||
requestUrl,
|
requestUrl,
|
||||||
queryParameters: queryParameters == null ? {} : queryParameters,
|
queryParameters: queryParameters ?? {},
|
||||||
data: json.encode(body),
|
data: json.encode(body),
|
||||||
options: Options(
|
options: Options(
|
||||||
headers: localHeaders,
|
headers: localHeaders,
|
||||||
@@ -285,14 +280,13 @@ class HttpUtil {
|
|||||||
|
|
||||||
// Utils.jsonPrettyPrint(response.data);
|
// Utils.jsonPrettyPrint(response.data);
|
||||||
|
|
||||||
int statusCode = response.statusCode;
|
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback(response);
|
callback(response);
|
||||||
}
|
}
|
||||||
return response.data;
|
return response.data;
|
||||||
} on DioError catch(e) {
|
} on DioException catch(e) {
|
||||||
if (e.response != null) {
|
if (e.response != null) {
|
||||||
Utils.jsonPrettyPrint(e.response.data);
|
Utils.jsonPrettyPrint(e.response!.data);
|
||||||
}
|
}
|
||||||
if (returnError) {
|
if (returnError) {
|
||||||
return e;
|
return e;
|
||||||
@@ -303,10 +297,10 @@ class HttpUtil {
|
|||||||
|
|
||||||
static Future<dynamic> httpDelete(String url, PostCallback callback,
|
static Future<dynamic> httpDelete(String url, PostCallback callback,
|
||||||
{
|
{
|
||||||
Map<String, dynamic> queryParameters,
|
Map<String, dynamic>? queryParameters,
|
||||||
int businessId = 0,
|
int businessId = 0,
|
||||||
Map<String, String> additionalHeaders,
|
Map<String, String>? additionalHeaders,
|
||||||
Map<String, dynamic> body,
|
Map<String, dynamic>? body,
|
||||||
bool returnError = false,
|
bool returnError = false,
|
||||||
}) async {
|
}) async {
|
||||||
|
|
||||||
@@ -333,13 +327,13 @@ class HttpUtil {
|
|||||||
requestUrl = url;
|
requestUrl = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.jsonPrettyPrint(body);
|
Utils.jsonPrettyPrint(body ?? {});
|
||||||
|
|
||||||
Dio dio = Dio();
|
Dio dio = Dio();
|
||||||
try {
|
try {
|
||||||
Response response = await dio.delete(
|
Response response = await dio.delete(
|
||||||
requestUrl,
|
requestUrl,
|
||||||
queryParameters: queryParameters == null ? {} : queryParameters,
|
queryParameters: queryParameters ?? {},
|
||||||
data: json.encode(body),
|
data: json.encode(body),
|
||||||
options: Options(
|
options: Options(
|
||||||
headers: localHeaders,
|
headers: localHeaders,
|
||||||
@@ -348,14 +342,13 @@ class HttpUtil {
|
|||||||
|
|
||||||
// Utils.jsonPrettyPrint(response.data);
|
// Utils.jsonPrettyPrint(response.data);
|
||||||
|
|
||||||
int statusCode = response.statusCode;
|
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback(response);
|
callback(response);
|
||||||
}
|
}
|
||||||
return response.data;
|
return response.data;
|
||||||
} on DioError catch(e) {
|
} on DioException catch(e) {
|
||||||
if (e.response != null) {
|
if (e.response != null) {
|
||||||
Utils.jsonPrettyPrint(e.response.data);
|
Utils.jsonPrettyPrint(e.response!.data);
|
||||||
}
|
}
|
||||||
if(returnError) {
|
if(returnError) {
|
||||||
return e;
|
return e;
|
||||||
|
|||||||
Reference in New Issue
Block a user