phase3: checkout files clean (nullable fields, ternary/concat/condition fixes). 142->131
This commit is contained in:
@@ -292,7 +292,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
|
|||||||
itemCount: 6,
|
itemCount: 6,
|
||||||
addAutomaticKeepAlives: true,
|
addAutomaticKeepAlives: true,
|
||||||
itemBuilder: (BuildContext context, int position) {
|
itemBuilder: (BuildContext context, int position) {
|
||||||
var deliveryTimeInSeconds = cartInfo!.businessInfo!.shippingTime! * 60 + (durationInTraffic != null ? durationInTraffic!.value : 0);
|
var deliveryTimeInSeconds = cartInfo!.businessInfo!.shippingTime! * 60 + (durationInTraffic != null ? durationInTraffic!.value ?? 0 : 0);
|
||||||
print('aaa: $deliveryTimeInSeconds');
|
print('aaa: $deliveryTimeInSeconds');
|
||||||
DateTime now = DateTime.now();
|
DateTime now = DateTime.now();
|
||||||
var formatter = DateFormat('H:mm');
|
var formatter = DateFormat('H:mm');
|
||||||
@@ -494,7 +494,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
Container(
|
||||||
child: Text(
|
child: Text(
|
||||||
shipAddress != null ? shipAddress!.fullAddress : S.of(context).enter_delivery_address,
|
shipAddress != null ? shipAddress!.fullAddress! : S.of(context).enter_delivery_address,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16.0
|
fontSize: 16.0
|
||||||
),
|
),
|
||||||
@@ -505,7 +505,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
|
|||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(top: 6.0),
|
padding: EdgeInsets.only(top: 6.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
shipAddress != null ? shipAddress!.contactName! + ' ' + shipAddress!.phone : '',
|
shipAddress != null ? shipAddress!.contactName! + ' ' + shipAddress!.phone! : '',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14.0,
|
fontSize: 14.0,
|
||||||
color: Colors.black38,
|
color: Colors.black38,
|
||||||
@@ -654,7 +654,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
|
|||||||
child: Text(
|
child: Text(
|
||||||
bookingTimeList.length > 0 ? '${Utils.timestampToString(context, bookingTimeList[bookingTimeIndex].unixTime!)}'
|
bookingTimeList.length > 0 ? '${Utils.timestampToString(context, bookingTimeList[bookingTimeIndex].unixTime!)}'
|
||||||
: ((bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ? ''
|
: ((bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ? ''
|
||||||
: bookingDateTimeList[bookingDateIndex].viewDate! + ' ' + (bookingDateTimeList[bookingDateIndex].bookTimes!.length > 0 ? bookingDateTimeList[bookingDateIndex].bookTimes![bookingTimeIndex].viewTime : '')),
|
: bookingDateTimeList[bookingDateIndex].viewDate! + ' ' + (bookingDateTimeList[bookingDateIndex].bookTimes!.length > 0 ? bookingDateTimeList[bookingDateIndex].bookTimes![bookingTimeIndex].viewTime! : '')),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
@@ -1075,7 +1075,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
|
|||||||
if (cartInfo != null) {
|
if (cartInfo != null) {
|
||||||
Utils.showLoadingDialog(context);
|
Utils.showLoadingDialog(context);
|
||||||
}
|
}
|
||||||
CartInfo ci = Utils.getCartInfoByBusinessId(store.state.cartInfos, widget.businessId);
|
CartInfo ci = Utils.getCartInfoByBusinessId(store.state.cartInfos, widget.businessId)!;
|
||||||
HttpUtil.httpPost('v1/orders/check', (response) {
|
HttpUtil.httpPost('v1/orders/check', (response) {
|
||||||
if (cartInfo != null) {
|
if (cartInfo != null) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
@@ -1706,7 +1706,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
|
|||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: selectedCoupon == 0 ? BoxDecoration(
|
decoration: selectedCoupon == 0 ? BoxDecoration(
|
||||||
color: subtotal > cartInfo!.businessInfo!.minPrice ? Colors
|
color: subtotal > cartInfo!.businessInfo!.minPrice! ? Colors
|
||||||
.transparent : Colors.black38,
|
.transparent : Colors.black38,
|
||||||
border: Border(
|
border: Border(
|
||||||
top: BorderSide(
|
top: BorderSide(
|
||||||
@@ -1727,7 +1727,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
) : BoxDecoration(
|
) : BoxDecoration(
|
||||||
color: subtotal > cartInfo!.businessInfo!.minPrice ? Colors
|
color: subtotal > cartInfo!.businessInfo!.minPrice! ? Colors
|
||||||
.transparent : Colors.black38,
|
.transparent : Colors.black38,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -1768,7 +1768,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
|
|||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: selectedCoupon == coupon.id ? BoxDecoration(
|
decoration: selectedCoupon == coupon.id ? BoxDecoration(
|
||||||
color: subtotal > cartInfo!.businessInfo!.minPrice ? Colors
|
color: subtotal > cartInfo!.businessInfo!.minPrice! ? Colors
|
||||||
.transparent : Colors.black38,
|
.transparent : Colors.black38,
|
||||||
border: Border(
|
border: Border(
|
||||||
top: BorderSide(
|
top: BorderSide(
|
||||||
@@ -1789,7 +1789,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
) : BoxDecoration(
|
) : BoxDecoration(
|
||||||
color: subtotal > coupon.minAmount ? Colors
|
color: subtotal > coupon.minAmount! ? Colors
|
||||||
.transparent : Colors.black26,
|
.transparent : Colors.black26,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -1799,7 +1799,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
|
|||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: 16.0, top: 16.0, right: 16.0, bottom: 16.0),
|
left: 16.0, top: 16.0, right: 16.0, bottom: 16.0),
|
||||||
child: coupon.isPercentage ?
|
child: coupon.isPercentage == true ?
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -1910,12 +1910,12 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (subtotal > coupon.minAmount &&
|
if (subtotal > coupon.minAmount! &&
|
||||||
mounted) {
|
mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedCoupon = coupon.id;
|
selectedCoupon = coupon.id;
|
||||||
if (coupon.isPercentage == true) {
|
if (coupon.isPercentage == true) {
|
||||||
couponDiscountAmount = subtotal * coupon.valueAmount / 100.0;
|
couponDiscountAmount = subtotal * coupon.valueAmount! / 100.0;
|
||||||
} else {
|
} else {
|
||||||
couponDiscountAmount = coupon.valueAmount!;
|
couponDiscountAmount = coupon.valueAmount!;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
|||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
new Text(
|
new Text(
|
||||||
product.productAttributes![this.index].required ? S.of(context).radio_option_is_required : S.of(context).radio_option_is_optional,
|
product.productAttributes![this.index].required == true ? S.of(context).radio_option_is_required : S.of(context).radio_option_is_optional,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: 10.0,
|
fontSize: 10.0,
|
||||||
color: new Color(0xFF999999)
|
color: new Color(0xFF999999)
|
||||||
|
|||||||
@@ -46,13 +46,13 @@ class MobileCheckout extends StatefulWidget {
|
|||||||
|
|
||||||
class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
|
class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
|
||||||
late CartInfo cartInfo;
|
late CartInfo cartInfo;
|
||||||
late Address shipAddress;
|
Address? shipAddress;
|
||||||
late bool canSubmit;
|
late bool canSubmit;
|
||||||
late List<ErrorMessage> errorMessages;
|
late List<ErrorMessage> errorMessages;
|
||||||
late List<BookingTime> bookingTimeList;
|
late List<BookingTime> bookingTimeList;
|
||||||
late List<BookingDateTime> bookingDateTimeList;
|
late List<BookingDateTime> bookingDateTimeList;
|
||||||
late List<PaymentPlatform> paymentPlatforms;
|
late List<PaymentPlatform> paymentPlatforms;
|
||||||
late TextValue durationInTraffic;
|
TextValue? durationInTraffic;
|
||||||
late int selectedCoupon;
|
late int selectedCoupon;
|
||||||
double couponDiscountAmount = 0;
|
double couponDiscountAmount = 0;
|
||||||
late List<Coupon> coupons;
|
late List<Coupon> coupons;
|
||||||
@@ -65,7 +65,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
int deliveryMethodIndex = 0;
|
int deliveryMethodIndex = 0;
|
||||||
late String deliveryMethod;
|
late String deliveryMethod;
|
||||||
List<ShippingRate> shippingRates = [];
|
List<ShippingRate> shippingRates = [];
|
||||||
late ShippingRate selectedShippingRate;
|
ShippingRate? selectedShippingRate;
|
||||||
|
|
||||||
List<String> shippingMethodLabels = [];
|
List<String> shippingMethodLabels = [];
|
||||||
List<IconData> shippingMethodIcons = [];
|
List<IconData> shippingMethodIcons = [];
|
||||||
@@ -203,7 +203,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
cartInfo.businessInfo!.isPublic ? SizedBox.shrink() : Container(
|
cartInfo.businessInfo!.isPublic == true ? SizedBox.shrink() : Container(
|
||||||
padding: EdgeInsets.only(top: 2.0, bottom: 2.0, left: 5.0, right: 5.0),
|
padding: EdgeInsets.only(top: 2.0, bottom: 2.0, left: 5.0, right: 5.0),
|
||||||
width: 100.0,
|
width: 100.0,
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
@@ -267,7 +267,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
itemCount: 6,
|
itemCount: 6,
|
||||||
addAutomaticKeepAlives: true,
|
addAutomaticKeepAlives: true,
|
||||||
itemBuilder: (BuildContext context, int position) {
|
itemBuilder: (BuildContext context, int position) {
|
||||||
var deliveryTimeInSeconds = cartInfo.businessInfo!.shippingTime! * 60 + (durationInTraffic != null ? durationInTraffic.value : 0);
|
var deliveryTimeInSeconds = cartInfo.businessInfo!.shippingTime! * 60 + (durationInTraffic != null ? durationInTraffic!.value ?? 0 : 0);
|
||||||
print('aaa: $deliveryTimeInSeconds');
|
print('aaa: $deliveryTimeInSeconds');
|
||||||
DateTime now = DateTime.now();
|
DateTime now = DateTime.now();
|
||||||
var formatter = DateFormat('H:mm');
|
var formatter = DateFormat('H:mm');
|
||||||
@@ -469,7 +469,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
Container(
|
||||||
child: Text(
|
child: Text(
|
||||||
shipAddress != null ? shipAddress.fullAddress : S.of(context).enter_delivery_address,
|
shipAddress != null ? shipAddress!.fullAddress! : S.of(context).enter_delivery_address,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16.0
|
fontSize: 16.0
|
||||||
),
|
),
|
||||||
@@ -480,7 +480,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(top: 6.0),
|
padding: EdgeInsets.only(top: 6.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
shipAddress != null ? shipAddress.contactName! + ' ' + shipAddress.phone : '',
|
shipAddress != null ? shipAddress!.contactName! + ' ' + shipAddress!.phone! : '',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14.0,
|
fontSize: 14.0,
|
||||||
color: Colors.black38,
|
color: Colors.black38,
|
||||||
@@ -553,7 +553,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: Text(
|
child: Text(
|
||||||
selectedShippingRate != null ?
|
selectedShippingRate != null ?
|
||||||
'${selectedShippingRate.name} \$${selectedShippingRate.price!.toStringAsFixed(2)}' :
|
'${selectedShippingRate!.name} \$${selectedShippingRate!.price!.toStringAsFixed(2)}' :
|
||||||
S.of(context).please_select,
|
S.of(context).please_select,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 15.0,
|
fontSize: 15.0,
|
||||||
@@ -629,7 +629,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
child: Text(
|
child: Text(
|
||||||
bookingTimeList.length > 0 ? '${Utils.timestampToString(context, bookingTimeList[bookingTimeIndex].unixTime!)}'
|
bookingTimeList.length > 0 ? '${Utils.timestampToString(context, bookingTimeList[bookingTimeIndex].unixTime!)}'
|
||||||
: ((bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ? ''
|
: ((bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ? ''
|
||||||
: bookingDateTimeList[bookingDateIndex].viewDate! + ' ' + (bookingDateTimeList[bookingDateIndex].bookTimes!.length > 0 ? bookingDateTimeList[bookingDateIndex].bookTimes![bookingTimeIndex].viewTime : '')),
|
: bookingDateTimeList[bookingDateIndex].viewDate! + ' ' + (bookingDateTimeList[bookingDateIndex].bookTimes!.length > 0 ? bookingDateTimeList[bookingDateIndex].bookTimes![bookingTimeIndex].viewTime! : '')),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
@@ -1050,7 +1050,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
if (cartInfo != null) {
|
if (cartInfo != null) {
|
||||||
Utils.showLoadingDialog(context);
|
Utils.showLoadingDialog(context);
|
||||||
}
|
}
|
||||||
CartInfo ci = Utils.getCartInfoByBusinessId(store.state.cartInfos, widget.businessId);
|
CartInfo ci = Utils.getCartInfoByBusinessId(store.state.cartInfos, widget.businessId)!;
|
||||||
HttpUtil.httpPost('v1/orders/check', (response) {
|
HttpUtil.httpPost('v1/orders/check', (response) {
|
||||||
if (cartInfo != null) {
|
if (cartInfo != null) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
@@ -1681,7 +1681,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: selectedCoupon == 0 ? BoxDecoration(
|
decoration: selectedCoupon == 0 ? BoxDecoration(
|
||||||
color: subtotal > cartInfo.businessInfo!.minPrice ? Colors
|
color: subtotal > cartInfo.businessInfo!.minPrice! ? Colors
|
||||||
.transparent : Colors.black38,
|
.transparent : Colors.black38,
|
||||||
border: Border(
|
border: Border(
|
||||||
top: BorderSide(
|
top: BorderSide(
|
||||||
@@ -1702,7 +1702,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
) : BoxDecoration(
|
) : BoxDecoration(
|
||||||
color: subtotal > cartInfo.businessInfo!.minPrice ? Colors
|
color: subtotal > cartInfo.businessInfo!.minPrice! ? Colors
|
||||||
.transparent : Colors.black38,
|
.transparent : Colors.black38,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -1743,7 +1743,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: selectedCoupon == coupon.id ? BoxDecoration(
|
decoration: selectedCoupon == coupon.id ? BoxDecoration(
|
||||||
color: subtotal > cartInfo.businessInfo!.minPrice ? Colors
|
color: subtotal > cartInfo.businessInfo!.minPrice! ? Colors
|
||||||
.transparent : Colors.black38,
|
.transparent : Colors.black38,
|
||||||
border: Border(
|
border: Border(
|
||||||
top: BorderSide(
|
top: BorderSide(
|
||||||
@@ -1764,7 +1764,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
) : BoxDecoration(
|
) : BoxDecoration(
|
||||||
color: subtotal > coupon.minAmount ? Colors
|
color: subtotal > coupon.minAmount! ? Colors
|
||||||
.transparent : Colors.black26,
|
.transparent : Colors.black26,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -1774,7 +1774,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: 16.0, top: 16.0, right: 16.0, bottom: 16.0),
|
left: 16.0, top: 16.0, right: 16.0, bottom: 16.0),
|
||||||
child: coupon.isPercentage ?
|
child: coupon.isPercentage == true ?
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -1885,12 +1885,12 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (subtotal > coupon.minAmount &&
|
if (subtotal > coupon.minAmount! &&
|
||||||
mounted) {
|
mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedCoupon = coupon.id!;
|
selectedCoupon = coupon.id!;
|
||||||
if (coupon.isPercentage == true) {
|
if (coupon.isPercentage == true) {
|
||||||
couponDiscountAmount = subtotal * coupon.valueAmount / 100.0;
|
couponDiscountAmount = subtotal * coupon.valueAmount! / 100.0;
|
||||||
} else {
|
} else {
|
||||||
couponDiscountAmount = coupon.valueAmount!;
|
couponDiscountAmount = coupon.valueAmount!;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user