phase3: nullfix.py batch script — bang/late/param-nullable

Automated null-safety fixes driven by dart analyze (no corruption):
- unchecked_use_of_nullable_value: insert '!' on receiver (property/method/[]/op)
- not_initialized field/var: mark 'late'
- missing_default_value_for_parameter: nullable param
Errors: 2374(peak) -> 907
This commit is contained in:
2026-07-25 18:13:01 +08:00
parent 8f3d3509ea
commit fce670664b
99 changed files with 1013 additions and 838 deletions

View File

@@ -30,7 +30,7 @@ class BuyService extends StatefulWidget {
} }
class BuyServiceState extends State<BuyService> { class BuyServiceState extends State<BuyService> {
Map<String, dynamic> data; late Map<String, dynamic> data;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@@ -22,7 +22,7 @@ class ContactUs extends StatefulWidget {
} }
class ContactUsState extends State<ContactUs> { class ContactUsState extends State<ContactUs> {
Business business; late Business business;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@@ -30,7 +30,7 @@ class Download extends StatefulWidget {
class DownloadState extends State<Download> { class DownloadState extends State<Download> {
final _scaffoldKey = GlobalKey<ScaffoldState>(); final _scaffoldKey = GlobalKey<ScaffoldState>();
Map<String, dynamic> data; late Map<String, dynamic> data;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -79,7 +79,7 @@ class DownloadState extends State<Download> {
super.initState(); super.initState();
eventBus.on<OpenDrawer>().listen((event) { eventBus.on<OpenDrawer>().listen((event) {
if (mounted) { if (mounted) {
_scaffoldKey.currentState.openDrawer(); _scaffoldKey.currentState!.openDrawer();
} }
}); });
_loadData(); _loadData();

View File

@@ -26,7 +26,7 @@ class IGoShowLearnMore extends StatefulWidget {
class IGoShowLearnMoreState extends State<IGoShowLearnMore> { class IGoShowLearnMoreState extends State<IGoShowLearnMore> {
final _scaffoldKey = GlobalKey<ScaffoldState>(); final _scaffoldKey = GlobalKey<ScaffoldState>();
Map<String, dynamic> data; late Map<String, dynamic> data;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@@ -26,7 +26,7 @@ class MiniPosLearnMore extends StatefulWidget {
class MiniPosLearnMoreState extends State<MiniPosLearnMore> { class MiniPosLearnMoreState extends State<MiniPosLearnMore> {
final _scaffoldKey = GlobalKey<ScaffoldState>(); final _scaffoldKey = GlobalKey<ScaffoldState>();
Map<String, dynamic> data; late Map<String, dynamic> data;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@@ -23,7 +23,7 @@ class PlainPage extends StatefulWidget {
} }
class PlainPageState extends State<PlainPage> { class PlainPageState extends State<PlainPage> {
Blog blog; late Blog blog;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@@ -25,7 +25,7 @@ class RenewMiniOffice extends StatefulWidget {
} }
class RenewMiniOfficeState extends State<RenewMiniOffice> { class RenewMiniOfficeState extends State<RenewMiniOffice> {
Map<String, dynamic> data; late Map<String, dynamic> data;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@@ -34,7 +34,7 @@ class DoubleBackToCloseApp extends StatefulWidget {
class _DoubleBackToCloseAppState extends State<DoubleBackToCloseApp> { class _DoubleBackToCloseAppState extends State<DoubleBackToCloseApp> {
/// The last time the user tapped Android's back-button. /// The last time the user tapped Android's back-button.
DateTime _lastTimeBackButtonWasTapped; late DateTime _lastTimeBackButtonWasTapped;
/// Returns whether the current platform is Android. /// Returns whether the current platform is Android.
bool get _isAndroid => Theme.of(context).platform == TargetPlatform.android; bool get _isAndroid => Theme.of(context).platform == TargetPlatform.android;
@@ -59,7 +59,7 @@ class _DoubleBackToCloseAppState extends State<DoubleBackToCloseApp> {
/// local-history of the current route, in order to handle pop. This is done /// local-history of the current route, in order to handle pop. This is done
/// by [Drawer], for example, so it can close on pop. /// by [Drawer], for example, so it can close on pop.
bool get _willHandlePopInternally => bool get _willHandlePopInternally =>
ModalRoute.of(context).willHandlePopInternally; ModalRoute.of(context)!.willHandlePopInternally;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@@ -35,8 +35,8 @@ class HttpUtil {
'Http-Contact-Authorization': '', 'Http-Contact-Authorization': '',
'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,

View File

@@ -199,8 +199,8 @@ class Util {
return box; return box;
} }
static Widget showImage(String imageUrl, {double width, double height, static Widget showImage(String imageUrl, {double? width, double? height,
BoxFit fit, Widget Function(BuildContext, String, dynamic) errorWidget}) { BoxFit? fit, Widget Function(BuildContext, String, dynamic)? errorWidget}) {
if (imageUrl != null && imageUrl.isNotEmpty && imageUrl.startsWith('https:')) { if (imageUrl != null && imageUrl.isNotEmpty && imageUrl.startsWith('https:')) {
return CachedNetworkImage( return CachedNetworkImage(
imageUrl: imageUrl, imageUrl: imageUrl,
@@ -317,14 +317,14 @@ class Util {
final picker = ImagePicker(); final picker = ImagePicker();
var image = await picker.pickImage(source: ImageSource.gallery); var image = await picker.pickImage(source: ImageSource.gallery);
Navigator.of(context).pop(); Navigator.of(context).pop();
uploadPicture(context, File(image.path), user, commentId: commentId, orderId: orderId); uploadPicture(context, File(image!.path), user, commentId: commentId, orderId: orderId);
} }
void getPictureFromCamera(BuildContext context, User user, {int commentId = -1, int orderId = 0}) async { void getPictureFromCamera(BuildContext context, User user, {int commentId = -1, int orderId = 0}) async {
final picker = ImagePicker(); final picker = ImagePicker();
var image = await picker.pickImage(source: ImageSource.camera); var image = await picker.pickImage(source: ImageSource.camera);
Navigator.of(context).pop(); Navigator.of(context).pop();
uploadPicture(context, File(image.path), user, commentId: commentId, orderId: orderId); uploadPicture(context, File(image!.path), user, commentId: commentId, orderId: orderId);
} }
void uploadPicture(BuildContext context, File image, User user, {int commentId = -1, int orderId = 0}) async { void uploadPicture(BuildContext context, File image, User user, {int commentId = -1, int orderId = 0}) async {
@@ -454,18 +454,18 @@ class Util {
ImagePicker picker = ImagePicker(); ImagePicker picker = ImagePicker();
var image = await picker.pickImage(source: ImageSource.gallery); var image = await picker.pickImage(source: ImageSource.gallery);
Navigator.of(context).pop(); Navigator.of(context).pop();
onGotFile(imageId, image.path); onGotFile(imageId, image!.path);
} }
void getPictureFromCamera2(BuildContext context, int imageId, OnGotFile onGotFile) async { void getPictureFromCamera2(BuildContext context, int imageId, OnGotFile onGotFile) async {
ImagePicker picker = ImagePicker(); ImagePicker picker = ImagePicker();
var image = await picker.pickImage(source: ImageSource.camera); var image = await picker.pickImage(source: ImageSource.camera);
Navigator.of(context).pop(); Navigator.of(context).pop();
onGotFile(imageId, image.path); onGotFile(imageId, image!.path);
} }
Future<void> createTicket(BuildContext context, String msg, List<Map<String, dynamic>> images, Future<void> createTicket(BuildContext context, String msg, List<Map<String, dynamic>> images,
OnSuccess onSuccess, OnError onError, {int id}) { OnSuccess onSuccess, OnError onError, {int? id}) {
var formData = FormData(); var formData = FormData();
formData.fields.add(MapEntry("msg", msg)); formData.fields.add(MapEntry("msg", msg));
formData.fields.add(MapEntry('id', id == null ? '0' : id.toString())); formData.fields.add(MapEntry('id', id == null ? '0' : id.toString()));
@@ -555,6 +555,6 @@ class Util {
ByteData data = await rootBundle.load(path); ByteData data = await rootBundle.load(path);
ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(), targetWidth: width); ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(), targetWidth: width);
ui.FrameInfo fi = await codec.getNextFrame(); ui.FrameInfo fi = await codec.getNextFrame();
return (await fi.image.toByteData(format: ui.ImageByteFormat.png)).buffer.asUint8List(); return (await fi.image.toByteData(format: ui.ImageByteFormat.png))!.buffer.asUint8List();
} }
} }

View File

@@ -35,12 +35,12 @@ class CreateOnlineStore1State extends State<CreateOnlineStore1> {
bool canSubmit = false; bool canSubmit = false;
List<dynamic> stores = []; List<dynamic> stores = [];
Map<String, dynamic> service; late Map<String, dynamic> service;
dynamic selectedStore; dynamic selectedStore;
Group group; late Group group;
String selectedDomain; late String selectedDomain;
List<dynamic> domainResult = []; List<dynamic> domainResult = [];
@override @override
@@ -284,7 +284,7 @@ class CreateOnlineStore1State extends State<CreateOnlineStore1> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).domains_separated_comma; return S.of(context).domains_separated_comma;
} }
return null; return null;

View File

@@ -34,7 +34,7 @@ class DesktopBlog extends StatefulWidget {
} }
class DesktopBlogState extends State<DesktopBlog> { class DesktopBlogState extends State<DesktopBlog> {
List<Blog> blogs; late List<Blog> blogs;
double division = 2; double division = 2;

View File

@@ -27,7 +27,7 @@ class DesktopBuyServiceState extends State<DesktopBuyService> {
double mainSpace = 1200; double mainSpace = 1200;
List<KeyValue> plans = []; List<KeyValue> plans = [];
KeyValue selectedPlan; late KeyValue selectedPlan;
double price = 0.0; double price = 0.0;
double tax = 0.0; double tax = 0.0;
double paymentAmount = 0.0; double paymentAmount = 0.0;

View File

@@ -32,9 +32,9 @@ class DesktopChangeMobileOrEmailState extends State<DesktopChangeMobileOrEmail>
bool usernameEnable = true; bool usernameEnable = true;
final codeController = TextEditingController(); final codeController = TextEditingController();
bool enableGetCode; late bool enableGetCode;
String getCodeText; late String getCodeText;
bool canRegister; late bool canRegister;
var countDownListener; var countDownListener;
@@ -88,7 +88,7 @@ class DesktopChangeMobileOrEmailState extends State<DesktopChangeMobileOrEmail>
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
if (widget.isMobile) { if (widget.isMobile) {
return S return S
.of(context) .of(context)
@@ -99,10 +99,10 @@ class DesktopChangeMobileOrEmailState extends State<DesktopChangeMobileOrEmail>
.email_is_required; .email_is_required;
} }
} }
if (widget.isMobile && value.trim() == store.state.user.mobile) { if (widget.isMobile && value!.trim() == store.state.user!.mobile) {
return S.of(context).the_mobile_number_is_same_as_current; return S.of(context).the_mobile_number_is_same_as_current;
} }
if (!widget.isMobile && value.trim() == store.state.user.email) { if (!widget.isMobile && value!.trim() == store.state.user!.email) {
return S.of(context).the_email_is_same_as_current; return S.of(context).the_email_is_same_as_current;
} }
return null; return null;
@@ -185,7 +185,7 @@ class DesktopChangeMobileOrEmailState extends State<DesktopChangeMobileOrEmail>
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).verification_code_is_required; return S.of(context).verification_code_is_required;
} }
return null; return null;
@@ -332,7 +332,7 @@ class DesktopChangeMobileOrEmailState extends State<DesktopChangeMobileOrEmail>
}, },
isFormData: true, isFormData: true,
body: { body: {
'id': store.state.user.id, 'id': store.state.user!.id,
'mobile': usernameController.text.trim(), 'mobile': usernameController.text.trim(),
'code': codeController.text.trim(), 'code': codeController.text.trim(),
}, },
@@ -344,8 +344,8 @@ class DesktopChangeMobileOrEmailState extends State<DesktopChangeMobileOrEmail>
void getCodeTapped() { void getCodeTapped() {
if (usernameController.text.isNotEmpty && if (usernameController.text.isNotEmpty &&
((widget.isMobile && usernameController.text.trim() != store.state.user.mobile) || ((widget.isMobile && usernameController.text.trim() != store.state.user!.mobile) ||
(!widget.isMobile && usernameController.text.trim() != store.state.user.email))) { (!widget.isMobile && usernameController.text.trim() != store.state.user!.email))) {
HttpUtil.httpPost('v1/users', (response) { HttpUtil.httpPost('v1/users', (response) {
Fluttertoast.showToast( Fluttertoast.showToast(
msg: S.of(context).verification_code_sent, msg: S.of(context).verification_code_sent,
@@ -366,7 +366,7 @@ class DesktopChangeMobileOrEmailState extends State<DesktopChangeMobileOrEmail>
'action': 'change_mobile_email_send_code' 'action': 'change_mobile_email_send_code'
}, },
body: { body: {
'id': store.state.user.id, 'id': store.state.user!.id,
'mobile': usernameController.text, 'mobile': usernameController.text,
}, },
isFormData: true, isFormData: true,
@@ -384,9 +384,9 @@ class DesktopChangeMobileOrEmailState extends State<DesktopChangeMobileOrEmail>
errorMsg = S.of(context).mobile_is_required; errorMsg = S.of(context).mobile_is_required;
} else if (!widget.isMobile && usernameController.text.trim().isEmpty) { } else if (!widget.isMobile && usernameController.text.trim().isEmpty) {
errorMsg = S.of(context).email_is_required; errorMsg = S.of(context).email_is_required;
} else if (widget.isMobile && usernameController.text.trim() == store.state.user.mobile) { } else if (widget.isMobile && usernameController.text.trim() == store.state.user!.mobile) {
errorMsg = S.of(context).the_mobile_number_is_same_as_current; errorMsg = S.of(context).the_mobile_number_is_same_as_current;
} else if (!widget.isMobile && usernameController.text.trim() == store.state.user.email) { } else if (!widget.isMobile && usernameController.text.trim() == store.state.user!.email) {
errorMsg = S.of(context).the_email_is_same_as_current; errorMsg = S.of(context).the_email_is_same_as_current;
} }
Fluttertoast.showToast( Fluttertoast.showToast(

View File

@@ -24,10 +24,10 @@ class DesktopChangePasswordState extends State<DesktopChangePassword> {
final passwordController = TextEditingController(); final passwordController = TextEditingController();
final passwordAgainController = TextEditingController(); final passwordAgainController = TextEditingController();
bool passwordVisible; late bool passwordVisible;
bool passwordAgainVisible; late bool passwordAgainVisible;
bool canReset; late bool canReset;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;
@@ -138,7 +138,7 @@ class DesktopChangePasswordState extends State<DesktopChangePassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).current_password_is_required; return S.of(context).current_password_is_required;
} }
return null; return null;
@@ -192,7 +192,7 @@ class DesktopChangePasswordState extends State<DesktopChangePassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
return null; return null;
@@ -246,10 +246,10 @@ class DesktopChangePasswordState extends State<DesktopChangePassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
if (value.trim() != passwordController.text.trim()) { if (value!.trim() != passwordController.text.trim()) {
return S.of(context).password_is_not_match_password_again; return S.of(context).password_is_not_match_password_again;
} }
return null; return null;
@@ -338,7 +338,7 @@ class DesktopChangePasswordState extends State<DesktopChangePassword> {
}, },
isFormData: true, isFormData: true,
body: { body: {
'id': store.state.user.id, 'id': store.state.user!.id,
'old_password': oldPasswordController.text.trim(), 'old_password': oldPasswordController.text.trim(),
'password': passwordController.text.trim(), 'password': passwordController.text.trim(),
} }

View File

@@ -222,7 +222,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
'\$${(cartInfo.totalPrice - couponDiscountAmount).toStringAsFixed(2)}', '\$${(cartInfo.totalPrice! - couponDiscountAmount).toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 20.0, fontSize: 20.0,
color: Colors.white, color: Colors.white,
@@ -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);
print('aaa: $deliveryTimeInSeconds'); print('aaa: $deliveryTimeInSeconds');
DateTime now = DateTime.now(); DateTime now = DateTime.now();
var formatter = DateFormat('H:mm'); var formatter = DateFormat('H:mm');
@@ -366,7 +366,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
); );
switch (position) { switch (position) {
case 0: case 0:
if (cartInfo.businessInfo.deliveryPickup) { if (cartInfo!.businessInfo!.deliveryPickup) {
return Container( return Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 16.0, bottom: 16.0, left: 16.0, right: 16.0), top: 16.0, bottom: 16.0, left: 16.0, right: 16.0),
@@ -380,8 +380,8 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
), ),
child: Container( child: Container(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: store.state.deviceId != null && store.state.deviceId.isNotEmpty ? ( child: store.state.deviceId != null && store.state.deviceId!.isNotEmpty ? (
store.state.tableNumber != null && store.state.tableNumber.isNotEmpty ? store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty ?
peopleCountSelection : peopleCountSelection :
SizedBox.shrink() SizedBox.shrink()
) : Center(child: toggleSwitch,), ) : Center(child: toggleSwitch,),
@@ -394,8 +394,8 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
} }
break; break;
case 1: case 1:
if (store.state.deviceId != null && store.state.deviceId.isNotEmpty || if (store.state.deviceId != null && store.state.deviceId!.isNotEmpty ||
store.state.tableNumber != null && store.state.tableNumber.isNotEmpty) { store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty) {
return SizedBox.shrink(); return SizedBox.shrink();
} }
if (deliveryMethod == 'pickup') { if (deliveryMethod == 'pickup') {
@@ -414,7 +414,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
Container( Container(
margin: EdgeInsets.only(top: 10.0), margin: EdgeInsets.only(top: 10.0),
child: Text( child: Text(
cartInfo.businessInfo.name, cartInfo!.businessInfo!.name,
style: TextStyle( style: TextStyle(
fontSize: 17.0, fontSize: 17.0,
), ),
@@ -423,7 +423,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
Container( Container(
margin: EdgeInsets.only(top: 5.0), margin: EdgeInsets.only(top: 5.0),
child: Text( child: Text(
cartInfo.businessInfo.address.addressLine1, cartInfo!.businessInfo!.address!.addressLine1,
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
color: Colors.black45, color: Colors.black45,
@@ -431,9 +431,9 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
), ),
), ),
Container( Container(
child: cartInfo.businessInfo.address.addressLine2 != null child: cartInfo!.businessInfo!.address!.addressLine2 != null
&& cartInfo.businessInfo.address.addressLine2.length > 0 ? && cartInfo!.businessInfo!.address!.addressLine2!.length > 0 ?
Text(cartInfo.businessInfo.address.addressLine2, Text(cartInfo!.businessInfo!.address!.addressLine2,
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
color: Colors.black45, color: Colors.black45,
@@ -442,7 +442,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
), ),
Container( Container(
child: Text( child: Text(
'${cartInfo.businessInfo.address.city}, ${cartInfo.businessInfo.address.state}, ${cartInfo.businessInfo.address.zip}', '${cartInfo!.businessInfo!.address!.city}, ${cartInfo!.businessInfo!.address!.state}, ${cartInfo!.businessInfo!.address!.zip}',
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
color: Colors.black45, color: Colors.black45,
@@ -452,7 +452,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
Container( Container(
margin: EdgeInsets.only(top: 5.0), margin: EdgeInsets.only(top: 5.0),
child: Text( child: Text(
'Tel: ${cartInfo.businessInfo.phone}', 'Tel: ${cartInfo!.businessInfo!.phone}',
style: TextStyle( style: TextStyle(
fontSize: 15.0, fontSize: 15.0,
color: Colors.black54, color: Colors.black54,
@@ -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,
@@ -529,13 +529,13 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
), ),
), ),
onTap: () { onTap: () {
Routes.router.navigateTo(context, '/my-addresses/${cartInfo.businessInfo.id}', replace: true); Routes.router.navigateTo(context, '/my-addresses/${cartInfo!.businessInfo!.id}', replace: true);
}, },
); );
break; break;
case 2: case 2:
if (deliveryMethod == 'pickup' || store.state.deviceId != null && store.state.deviceId.isNotEmpty || if (deliveryMethod == 'pickup' || store.state.deviceId != null && store.state.deviceId!.isNotEmpty ||
store.state.tableNumber != null && store.state.tableNumber.isNotEmpty) { store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty) {
return SizedBox.shrink(); return SizedBox.shrink();
} }
if (deliveryMethod == 'canada-post') { if (deliveryMethod == 'canada-post') {
@@ -578,7 +578,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
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,
@@ -608,7 +608,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
}, },
); );
} }
if (!cartInfo.businessInfo.instanceDelivery) { if (!cartInfo!.businessInfo!.instanceDelivery) {
return Container( return Container(
padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 0.0, bottom: 16.0), padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 0.0, bottom: 16.0),
child: Text(S.of(context).no_instance_delivery_desc), child: Text(S.of(context).no_instance_delivery_desc),
@@ -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(
@@ -737,7 +737,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
width: double.infinity, width: double.infinity,
padding: EdgeInsets.only(bottom: 10.0), padding: EdgeInsets.only(bottom: 10.0),
child: Text( child: Text(
cartInfo.businessInfo.name, cartInfo!.businessInfo!.name,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontSize: 16.0, fontSize: 16.0,
@@ -756,9 +756,9 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
subtotal = 0.0; subtotal = 0.0;
for (var i = 0; i < cartInfo.productList.length; i++) { for (var i = 0; i < cartInfo!.productList!.length; i++) {
subtotal += cartInfo.productList[i].totalPrice; subtotal += cartInfo!.productList![i].totalPrice;
column.children.add(lineItem(cartInfo.productList[i])); column.children.add(lineItem(cartInfo!.productList![i]));
} }
column.children.add(GestureDetector( column.children.add(GestureDetector(
child: Container( child: Container(
@@ -851,8 +851,8 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
), ),
)); ));
if (cartInfo.extraFeeList.length > 0) { if (cartInfo!.extraFeeList!.length > 0) {
for (var i = 0; i < cartInfo.extraFeeList.length; i++) { for (var i = 0; i < cartInfo!.extraFeeList!.length; i++) {
column.children.add(Container( column.children.add(Container(
padding: EdgeInsets.only(bottom: 16.0), padding: EdgeInsets.only(bottom: 16.0),
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
@@ -863,7 +863,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
Container( Container(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
S.of(context).extra_fee_token(cartInfo.extraFeeList[i].name, cartInfo.extraFeeList[i].rate), S.of(context).extra_fee_token(cartInfo!.extraFeeList![i].name, cartInfo!.extraFeeList![i].rate),
style: TextStyle( style: TextStyle(
color: Colors.grey, color: Colors.grey,
), ),
@@ -873,7 +873,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
width: 100.0, width: 100.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${cartInfo.extraFeeList[i].price.toStringAsFixed(2)}' '${cartInfo!.extraFeeList![i].price!.toStringAsFixed(2)}'
), ),
), ),
], ],
@@ -901,7 +901,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
width: 100.0, width: 100.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${(cartInfo.totalPrice - couponDiscountAmount).toStringAsFixed(2)}', '${(cartInfo!.totalPrice! - couponDiscountAmount).toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 19.0, fontSize: 19.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -999,7 +999,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
children: <Widget>[ children: <Widget>[
Container( Container(
padding: EdgeInsets.all(5.0), padding: EdgeInsets.all(5.0),
child: Util.showImage('${cartLineItem.product.imagePath}', child: Util.showImage('${cartLineItem.product!.imagePath}',
width: 80.0, width: 80.0,
height: 80.0, height: 80.0,
fit: BoxFit.fill, fit: BoxFit.fill,
@@ -1036,14 +1036,14 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
margin: EdgeInsets.only(right: 10.0), margin: EdgeInsets.only(right: 10.0),
child: Text( child: Text(
'x${cartLineItem.quantity.round()}', 'x${cartLineItem.quantity!.round()}',
), ),
), ),
Container( Container(
width: 60.0, width: 60.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${cartLineItem.totalPrice.toStringAsFixed(2)}', '${cartLineItem.totalPrice!.toStringAsFixed(2)}',
), ),
), ),
], ],
@@ -1099,7 +1099,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
shippingRates = (response.data['shipping_rates'] as List).map((e) => ShippingRate.fromJson(e)).toList(); shippingRates = (response.data['shipping_rates'] as List).map((e) => ShippingRate.fromJson(e)).toList();
selectedShippingRate = (response.data['selected_shipping_rate'] as String).length > 0 ? ShippingRate.fromJson(json.decode(response.data['selected_shipping_rate'])) : null; selectedShippingRate = (response.data['selected_shipping_rate'] as String).length > 0 ? ShippingRate.fromJson(json.decode(response.data['selected_shipping_rate'])) : null;
int i = 0; int i = 0;
if (cartInfo.businessInfo.deliveryStoreDelivery) { if (cartInfo!.businessInfo!.deliveryStoreDelivery) {
shippingMethodLabels.add(S.of(context).delivery); shippingMethodLabels.add(S.of(context).delivery);
shippingMethodIcons.add(Icons.directions_car); shippingMethodIcons.add(Icons.directions_car);
if (deliveryMethod == 'store-delivery') { if (deliveryMethod == 'store-delivery') {
@@ -1107,7 +1107,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
} }
i++; i++;
} }
if (cartInfo.businessInfo.deliveryCanadaPost) { if (cartInfo!.businessInfo!.deliveryCanadaPost) {
shippingMethodLabels.add(S.of(context).canada_post); shippingMethodLabels.add(S.of(context).canada_post);
shippingMethodIcons.add(Icons.local_shipping); shippingMethodIcons.add(Icons.local_shipping);
if (deliveryMethod == 'canada-post') { if (deliveryMethod == 'canada-post') {
@@ -1115,7 +1115,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
} }
i++; i++;
} }
if (cartInfo.businessInfo.deliveryPickup) { if (cartInfo!.businessInfo!.deliveryPickup) {
shippingMethodLabels.add(S.of(context).pickup); shippingMethodLabels.add(S.of(context).pickup);
shippingMethodIcons.add(Icons.store); shippingMethodIcons.add(Icons.store);
if (deliveryMethod == 'pickup') { if (deliveryMethod == 'pickup') {
@@ -1335,14 +1335,14 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
Expanded( Expanded(
child: SizedBox.expand( child: SizedBox.expand(
child: ListView.builder( child: ListView.builder(
itemCount: bookingDateTimeList[bookingDateIndex].bookTimes.length, itemCount: bookingDateTimeList[bookingDateIndex].bookTimes!.length,
itemBuilder: (BuildContext context, int position) { itemBuilder: (BuildContext context, int position) {
BookingDateTime bookingDateTime = bookingDateTimeList[bookingDateIndex]; BookingDateTime bookingDateTime = bookingDateTimeList[bookingDateIndex];
return GestureDetector( return GestureDetector(
child: Container( child: Container(
padding: EdgeInsets.only(left: 12.0, right: 12.0, top: 12.0, bottom: 12.0), padding: EdgeInsets.only(left: 12.0, right: 12.0, top: 12.0, bottom: 12.0),
child: Text( child: Text(
bookingDateTime.bookTimes[position].viewTime, bookingDateTime.bookTimes![position].viewTime,
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border( border: Border(
@@ -1467,16 +1467,16 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
itemBuilder: (BuildContext context, int position) { itemBuilder: (BuildContext context, int position) {
PaymentPlatform paymentPlatform = paymentPlatforms[position]; PaymentPlatform paymentPlatform = paymentPlatforms[position];
if (paymentPlatform.code == Constants.PAYMENT_METHOD_CODE_SQUARE && if (paymentPlatform.code == Constants.PAYMENT_METHOD_CODE_SQUARE &&
(paymentPlatform.squareAppId == null || paymentPlatform.squareAppId.isEmpty) && (paymentPlatform.squareAppId == null || paymentPlatform.squareAppId!.isEmpty) &&
(paymentPlatform.squareAccessToken == null || paymentPlatform.squareAccessToken.isEmpty) && (paymentPlatform.squareAccessToken == null || paymentPlatform.squareAccessToken!.isEmpty) &&
(paymentPlatform.squareLocationId == null || paymentPlatform.squareLocationId.isEmpty) (paymentPlatform.squareLocationId == null || paymentPlatform.squareLocationId!.isEmpty)
) { ) {
return SizedBox.shrink(); return SizedBox.shrink();
} }
if (paymentPlatform.code == Constants.PAYMENT_METHOD_CODE_CHASE && if (paymentPlatform.code == Constants.PAYMENT_METHOD_CODE_CHASE &&
(paymentPlatform.xLogin == null || paymentPlatform.xLogin.isEmpty) && (paymentPlatform.xLogin == null || paymentPlatform.xLogin!.isEmpty) &&
(paymentPlatform.transactionKey == null || paymentPlatform.transactionKey.isEmpty) && (paymentPlatform.transactionKey == null || paymentPlatform.transactionKey!.isEmpty) &&
(paymentPlatform.responseKey == null || paymentPlatform.responseKey.isEmpty) (paymentPlatform.responseKey == null || paymentPlatform.responseKey!.isEmpty)
) { ) {
return SizedBox.shrink(); return SizedBox.shrink();
} }
@@ -1566,7 +1566,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
String getSelectedCouponName() { String getSelectedCouponName() {
if (selectedCoupon == null) { if (selectedCoupon == null) {
if (coupons.length > 0) { if (coupons!.length > 0) {
return S return S
.of(context) .of(context)
.please_select; .please_select;
@@ -1578,10 +1578,10 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
} else if (selectedCoupon == 0) { } else if (selectedCoupon == 0) {
return S.of(context).dont_use; return S.of(context).dont_use;
} else { } else {
for (var i = 0; i < coupons.length; i++) { for (var i = 0; i < coupons!.length; i++) {
if (selectedCoupon == coupons[i].id) { if (selectedCoupon == coupons![i].id) {
if (coupons[i].isPercentage) { if (coupons![i].isPercentage) {
return S.of(context).percentage_discount_token2(couponDiscountAmount.toStringAsFixed(2), coupons[i].valueAmount); return S.of(context).percentage_discount_token2(couponDiscountAmount.toStringAsFixed(2), coupons![i].valueAmount);
} else { } else {
return S.of(context).discount_amount_token(couponDiscountAmount.toStringAsFixed(2)); return S.of(context).discount_amount_token(couponDiscountAmount.toStringAsFixed(2));
} }
@@ -1700,13 +1700,13 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
} else { } else {
widget.children.add(Expanded( widget.children.add(Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: coupons.length + 1, itemCount: coupons!.length + 1,
itemBuilder: (BuildContext context, int position) { itemBuilder: (BuildContext context, int position) {
if (position == 0) { if (position == 0) {
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(
@@ -1764,11 +1764,11 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
}, },
); );
} else { } else {
Coupon coupon = coupons[position - 1]; Coupon coupon = coupons![position - 1];
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(
@@ -1882,7 +1882,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
), ),
Container( Container(
child: Text( child: Text(
coupon.minAmount > 0 ? coupon.minAmount! > 0 ?
S.of(context).min_order_amount_token( S.of(context).min_order_amount_token(
coupon.minAmount) : coupon.minAmount) :
S.of(context) S.of(context)
@@ -1942,7 +1942,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [], children: [],
); );
if (cartInfo.businessInfo.quickInputs.length > 0) { if (cartInfo!.businessInfo!.quickInputs!.length > 0) {
Wrap w = Wrap( Wrap w = Wrap(
children: [], children: [],
); );
@@ -1956,8 +1956,8 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
), ),
), ),
)); ));
for (int i = 0; i < cartInfo.businessInfo.quickInputs.length; i++) { for (int i = 0; i < cartInfo!.businessInfo!.quickInputs!.length; i++) {
String qi = cartInfo.businessInfo.quickInputs[i].value; String qi = cartInfo!.businessInfo!.quickInputs![i].value;
w.children.add(TextButton( w.children.add(TextButton(
child: Text( child: Text(
qi, qi,
@@ -2137,7 +2137,7 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
child: Container( child: Container(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${shippingRate.price.toStringAsFixed(2)}', '${shippingRate.price!.toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 16.0, fontSize: 16.0,
color: Colors.black38, color: Colors.black38,
@@ -2221,14 +2221,14 @@ class DesktopCheckoutState extends State<DesktopCheckout> with SingleTickerProvi
}, },
businessId: widget.businessId, businessId: widget.businessId,
body: { body: {
'cart_id': cartInfo.id, 'cart_id': cartInfo!.id,
'remark': orderRemark, 'remark': orderRemark,
'booked_at': bookingTimeList.length > 0 'booked_at': bookingTimeList.length > 0
? bookingTimeList[bookingTimeIndex].unixTime ? bookingTimeList[bookingTimeIndex].unixTime
: ( : (
(bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ? (bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ?
0 : 0 :
bookingDateTimeList[bookingDateIndex].bookTimes[bookingTimeIndex] bookingDateTimeList[bookingDateIndex].bookTimes![bookingTimeIndex]
.unixTime .unixTime
), ),
'delivery': deliveryMethod, 'delivery': deliveryMethod,

View File

@@ -35,7 +35,7 @@ class DesktopContactUsState extends State<DesktopContactUs> {
String mapUrl = 'https://goo.gl/maps/M365MF5AW35n9ij67'; String mapUrl = 'https://goo.gl/maps/M365MF5AW35n9ij67';
Completer<GoogleMapController> _controller = Completer(); Completer<GoogleMapController> _controller = Completer();
LatLng _lastMapPosition; late LatLng _lastMapPosition;
final Set<Marker> _markers = {}; final Set<Marker> _markers = {};
final Set<Polyline> _polyLine = {}; final Set<Polyline> _polyLine = {};
@@ -253,16 +253,16 @@ class DesktopContactUsState extends State<DesktopContactUs> {
Container( Container(
padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4),
child: Text( child: Text(
'${widget.business.address.addressLine1}', '${widget.business.address!.addressLine1}',
), ),
) )
); );
if (widget.business.address.addressLine2 != null && widget.business.address.addressLine2.isNotEmpty) { if (widget.business.address!.addressLine2 != null && widget.business.address!.addressLine2!.isNotEmpty) {
col.children.add( col.children.add(
Container( Container(
padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4),
child: Text( child: Text(
'${widget.business.address.addressLine2}', '${widget.business.address!.addressLine2}',
), ),
) )
); );
@@ -271,7 +271,7 @@ class DesktopContactUsState extends State<DesktopContactUs> {
Container( Container(
padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4),
child: Text( child: Text(
'${widget.business.address.city}, ${widget.business.address.state}', '${widget.business.address!.city}, ${widget.business.address!.state}',
), ),
) )
); );
@@ -279,7 +279,7 @@ class DesktopContactUsState extends State<DesktopContactUs> {
Container( Container(
padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4),
child: Text( child: Text(
'${widget.business.address.country}, ${widget.business.address.zip}', '${widget.business.address!.country}, ${widget.business.address!.zip}',
), ),
) )
); );
@@ -287,8 +287,8 @@ class DesktopContactUsState extends State<DesktopContactUs> {
_markers.clear(); _markers.clear();
_markers.add(Marker( _markers.add(Marker(
markerId: MarkerId('shop_position'), markerId: MarkerId('shop_position'),
position: LatLng(double.parse(widget.business.address.lat), position: LatLng(double.parse(widget.business.address!.lat),
double.parse(widget.business.address.lng)), double.parse(widget.business.address!.lng)),
infoWindow: InfoWindow( infoWindow: InfoWindow(
title: S title: S
.of(context) .of(context)
@@ -304,8 +304,8 @@ class DesktopContactUsState extends State<DesktopContactUs> {
onMapCreated: _onMapCreated, onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition( initialCameraPosition: CameraPosition(
target: LatLng( target: LatLng(
double.parse(widget.business.address.lat), double.parse(widget.business.address!.lat),
double.parse(widget.business.address.lng)), double.parse(widget.business.address!.lng)),
zoom: 14.0, zoom: 14.0,
), ),
onCameraMove: _onCameraMove, onCameraMove: _onCameraMove,

View File

@@ -27,7 +27,7 @@ class DesktopCoupons extends StatefulWidget {
} }
class DesktopCouponsState extends State<DesktopCoupons> { class DesktopCouponsState extends State<DesktopCoupons> {
List<Coupon> coupons; late List<Coupon> coupons;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;
@@ -120,7 +120,7 @@ class DesktopCouponsState extends State<DesktopCoupons> {
Container( Container(
padding: EdgeInsets.only(right: 5.0), padding: EdgeInsets.only(right: 5.0),
child: coupon.store != null ? child: coupon.store != null ?
Util.showImage('${coupon.store.picUrl}', Util.showImage('${coupon.store!.picUrl}',
fit: BoxFit.fill, fit: BoxFit.fill,
width: 40.0, width: 40.0,
) : ) :
@@ -137,7 +137,7 @@ class DesktopCouponsState extends State<DesktopCoupons> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( Text(
coupon.store != null ? coupon.store.name : S.of(context).general_coupon, coupon.store != null ? coupon.store!.name : S.of(context).general_coupon,
style: TextStyle( style: TextStyle(
fontSize: 20.0, fontSize: 20.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -221,7 +221,7 @@ class DesktopCouponsState extends State<DesktopCoupons> {
), ),
Container( Container(
child: Text( child: Text(
coupon.minAmount > 0 ? coupon.minAmount! > 0 ?
S.of(context).available_for_order_over_token(coupon.minAmount) : S.of(context).available_for_order_over_token(coupon.minAmount) :
S.of(context).no_restriction, S.of(context).no_restriction,
style: TextStyle( style: TextStyle(
@@ -259,7 +259,7 @@ class DesktopCouponsState extends State<DesktopCoupons> {
children: <Widget>[ children: <Widget>[
Container( Container(
child: Text( child: Text(
coupon.expirationDate == null || coupon.expirationDate.length == 0 ? coupon.expirationDate == null || coupon.expirationDate!.length == 0 ?
S.of(context).no_expiration : S.of(context).no_expiration :
S.of(context).expiration_date_token(coupon.expirationDate), S.of(context).expiration_date_token(coupon.expirationDate),
style: TextStyle( style: TextStyle(
@@ -284,7 +284,7 @@ class DesktopCouponsState extends State<DesktopCoupons> {
), ),
onPressed: () { onPressed: () {
if (coupon.store != null) { if (coupon.store != null) {
Routes.router.navigateTo(context, '/shop/${coupon.store.id}/na/na/na'); Routes.router.navigateTo(context, '/shop/${coupon.store!.id}/na/na/na');
} else { } else {
Routes.router.navigateTo(context, '/businesses'); Routes.router.navigateTo(context, '/businesses');
} }

View File

@@ -45,12 +45,12 @@ class DesktopEditAddressState extends State<DesktopEditAddress> {
final emailController = TextEditingController(); final emailController = TextEditingController();
final faxController = TextEditingController(); final faxController = TextEditingController();
String country; late String country;
Gender _selectedGender; late Gender _selectedGender;
String _selectedProvince; late String _selectedProvince;
bool showLoading; late bool showLoading;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;
@@ -362,7 +362,7 @@ class DesktopEditAddressState extends State<DesktopEditAddress> {
.email, .email,
), ),
validator: (String? value) { validator: (String? value) {
if (value.isNotEmpty && !EmailValidator.validate(value)) { if (value!.isNotEmpty && !EmailValidator.validate(value)) {
return S return S
.of(context) .of(context)
.email_is_not_valid; .email_is_not_valid;

View File

@@ -29,9 +29,9 @@ class DesktopForgotPasswordState extends State<DesktopForgotPassword> {
bool usernameEnable = true; bool usernameEnable = true;
final codeController = TextEditingController(); final codeController = TextEditingController();
bool enableGetCode; late bool enableGetCode;
String getCodeText; late String getCodeText;
bool canRegister; late bool canRegister;
var countDownListener; var countDownListener;
@@ -84,7 +84,7 @@ class DesktopForgotPasswordState extends State<DesktopForgotPassword> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).mobile_or_email_is_required; return S.of(context).mobile_or_email_is_required;
} }
return null; return null;
@@ -167,7 +167,7 @@ class DesktopForgotPasswordState extends State<DesktopForgotPassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).verification_code_is_required; return S.of(context).verification_code_is_required;
} }
return null; return null;

View File

@@ -26,9 +26,9 @@ class DesktopLoginState extends State<DesktopLogin> {
final usernameController = TextEditingController(); final usernameController = TextEditingController();
final passwordController = TextEditingController(); final passwordController = TextEditingController();
bool passwordVisible; late bool passwordVisible;
bool onSubmitting; late bool onSubmitting;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;
@@ -150,7 +150,7 @@ class DesktopLoginState extends State<DesktopLogin> {
style: TextStyle(fontSize: 18.0), style: TextStyle(fontSize: 18.0),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).this_field_is_required; return S.of(context).this_field_is_required;
} }
return null; return null;
@@ -194,7 +194,7 @@ class DesktopLoginState extends State<DesktopLogin> {
style: TextStyle(fontSize: 18.0), style: TextStyle(fontSize: 18.0),
obscureText: passwordVisible, obscureText: passwordVisible,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
return null; return null;

View File

@@ -16,9 +16,9 @@ import '../../utils/util_web.dart'
if (dart.library.io) '../../utils/util_io.dart'; if (dart.library.io) '../../utils/util_io.dart';
import '../../utils/utils.dart'; import '../../utils/utils.dart';
MediaQueryData mediaQuery; late MediaQueryData mediaQuery;
double statusBarHeight; late double statusBarHeight;
double screenHeight; late double screenHeight;
class DesktopMe extends StatefulWidget { class DesktopMe extends StatefulWidget {
final Key? key; final Key? key;
@@ -32,11 +32,11 @@ class DesktopMe extends StatefulWidget {
} }
class DesktopMeState extends State<DesktopMe> { class DesktopMeState extends State<DesktopMe> {
int userId; late int userId;
String accessToken; late String accessToken;
bool isLoading; late bool isLoading;
User _user; late User _user;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;
@@ -81,7 +81,7 @@ class DesktopMeState extends State<DesktopMe> {
children: <Widget>[ children: <Widget>[
Container( Container(
margin: EdgeInsets.only(right: 5.0), margin: EdgeInsets.only(right: 5.0),
child: _user != null && _user.avatarUrl.isNotEmpty child: _user != null && _user.avatarUrl!.isNotEmpty
? Util.showImage( ? Util.showImage(
'https:${_user.avatarUrl}', 'https:${_user.avatarUrl}',
width: 60, width: 60,
@@ -182,7 +182,7 @@ class DesktopMeState extends State<DesktopMe> {
Container( Container(
child: Text( child: Text(
_user != null _user != null
? '${_user.wallet.toStringAsFixed(2)}' ? '${_user.wallet!.toStringAsFixed(2)}'
: '0.00', : '0.00',
style: TextStyle( style: TextStyle(
fontSize: 24.0, fontSize: 24.0,

View File

@@ -30,7 +30,7 @@ class DesktopMyAddresses extends StatefulWidget {
} }
class DesktopMyAddressesState extends State<DesktopMyAddresses> { class DesktopMyAddressesState extends State<DesktopMyAddresses> {
List<Address> addresses; late List<Address> addresses;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;

View File

@@ -30,7 +30,7 @@ class DesktopMySupport extends StatefulWidget {
} }
class DesktopMySupportState extends State<DesktopMySupport> { class DesktopMySupportState extends State<DesktopMySupport> {
List<Ticket> tickets; late List<Ticket> tickets;
double division = 3; double division = 3;
@@ -218,7 +218,7 @@ class DesktopMySupportState extends State<DesktopMySupport> {
children: <Widget>[ children: <Widget>[
Container( Container(
child: Text( child: Text(
ticket.issue.msg, ticket.issue!.msg,
style: TextStyle( style: TextStyle(
fontSize: 19.0, fontSize: 19.0,
), ),
@@ -248,7 +248,7 @@ class DesktopMySupportState extends State<DesktopMySupport> {
SizedBox.shrink(), SizedBox.shrink(),
Expanded( Expanded(
child: Text( child: Text(
S.of(context).followups_token(ticket.followUps.length), S.of(context).followups_token(ticket.followUps!.length),
style: TextStyle( style: TextStyle(
fontSize: 15.0, fontSize: 15.0,
color: Colors.black87, color: Colors.black87,

View File

@@ -39,9 +39,9 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
final faxController = TextEditingController(); final faxController = TextEditingController();
String country = 'CA'; String country = 'CA';
Gender _selectedGender; late Gender _selectedGender;
String _selectedProvince; late String _selectedProvince;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;
@@ -98,7 +98,7 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
labelText: S.of(context).contact_name, labelText: S.of(context).contact_name,
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).contact_name_is_required; return S.of(context).contact_name_is_required;
} }
return null; return null;
@@ -142,7 +142,7 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
labelText: S.of(context).mobile_phone_number, labelText: S.of(context).mobile_phone_number,
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).mobile_phone_number_is_required; return S.of(context).mobile_phone_number_is_required;
} }
return null; return null;
@@ -167,7 +167,7 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
labelText: S.of(context).street_line_1, labelText: S.of(context).street_line_1,
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).street_line_1_is_required; return S.of(context).street_line_1_is_required;
} }
return null; return null;
@@ -211,7 +211,7 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
labelText: S.of(context).city, labelText: S.of(context).city,
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).city_is_required; return S.of(context).city_is_required;
} }
return null; return null;
@@ -257,7 +257,7 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
labelText: S.of(context).postal_code, labelText: S.of(context).postal_code,
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).postal_code_is_required; return S.of(context).postal_code_is_required;
} }
return null; return null;
@@ -292,7 +292,7 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
labelText: S.of(context).email, labelText: S.of(context).email,
), ),
validator: (String? value) { validator: (String? value) {
if (value.isNotEmpty && !EmailValidator.validate(value)) { if (value!.isNotEmpty && !EmailValidator.validate(value)) {
return S.of(context).email_is_not_valid; return S.of(context).email_is_not_valid;
} }
return null; return null;
@@ -383,8 +383,8 @@ class DesktopNewAddressState extends State<DesktopNewAddress> {
cityController.text = widget.locatedAddress.city; cityController.text = widget.locatedAddress.city;
postalCodeController.text = widget.locatedAddress.postalCode; postalCodeController.text = widget.locatedAddress.postalCode;
streetLine1Controller.text = (widget.locatedAddress.streetNumber != null streetLine1Controller.text = (widget.locatedAddress.streetNumber != null
&& widget.locatedAddress.streetNumber.isNotEmpty && widget.locatedAddress.streetNumber!.isNotEmpty
? widget.locatedAddress.streetNumber + ' ' : '') ? widget.locatedAddress.streetNumber! + ' ' : '')
+ widget.locatedAddress.streetName; + widget.locatedAddress.streetName;
} else { } else {
_selectedProvince = 'Ontario'; _selectedProvince = 'Ontario';

View File

@@ -34,13 +34,13 @@ class DesktopNewComment extends StatefulWidget {
} }
class DesktopNewCommentState extends State<DesktopNewComment> { class DesktopNewCommentState extends State<DesktopNewComment> {
Comment comment; late Comment comment;
bool _showProgress; late bool _showProgress;
double _progress; late double _progress;
double rating; late double rating;
bool isSubmitting = false; bool isSubmitting = false;
@@ -203,7 +203,7 @@ class DesktopNewCommentState extends State<DesktopNewComment> {
children: <Widget>[], children: <Widget>[],
); );
if (comment != null && comment.images.length > 0) { if (comment != null && comment.images!.length > 0) {
for (ProductImage image in comment.images) { for (ProductImage image in comment.images) {
row.children.add( row.children.add(
Container( Container(
@@ -275,7 +275,7 @@ class DesktopNewCommentState extends State<DesktopNewComment> {
child: Icon( child: Icon(
Icons.add, Icons.add,
size: 60.0, size: 60.0,
color: comment == null || comment.images.length < 3 ? Colors.lightBlue : Colors.black12, color: comment == null || comment.images!.length < 3 ? Colors.lightBlue : Colors.black12,
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white70, color: Colors.white70,
@@ -300,7 +300,7 @@ class DesktopNewCommentState extends State<DesktopNewComment> {
), ),
), ),
onTap: () { onTap: () {
if (comment == null || comment.images.length < 3) { if (comment == null || comment.images!.length < 3) {
showDialog( showDialog(
context: mainContext, context: mainContext,
barrierDismissible: true, barrierDismissible: true,

View File

@@ -155,7 +155,7 @@ class DesktopNewTicketState extends State<DesktopNewTicket> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).this_field_is_required; return S.of(context).this_field_is_required;
} }
return null; return null;

View File

@@ -28,9 +28,9 @@ class DesktopNewUserState extends State<DesktopNewUser> {
bool usernameEnable = true; bool usernameEnable = true;
final codeController = TextEditingController(); final codeController = TextEditingController();
bool enableGetCode; late bool enableGetCode;
String getCodeText; late String getCodeText;
bool canRegister; late bool canRegister;
var countDownListener; var countDownListener;
@@ -81,7 +81,7 @@ class DesktopNewUserState extends State<DesktopNewUser> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).mobile_or_email_is_required; return S.of(context).mobile_or_email_is_required;
} }
return null; return null;
@@ -164,7 +164,7 @@ class DesktopNewUserState extends State<DesktopNewUser> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).verification_code_is_required; return S.of(context).verification_code_is_required;
} }
return null; return null;

View File

@@ -39,18 +39,18 @@ class DesktopOrderDetail extends StatefulWidget {
} }
class DesktopOrderDetailState extends State<DesktopOrderDetail> { class DesktopOrderDetailState extends State<DesktopOrderDetail> {
Order order; late Order order;
LatLng _lastMapPosition; late LatLng _lastMapPosition;
LatLng customerLatLng; late LatLng customerLatLng;
LatLng deliveryLatLng; late LatLng deliveryLatLng;
LatLng storeLatLng; late LatLng storeLatLng;
final Set<Marker> _markers = {}; final Set<Marker> _markers = {};
final Set<Polyline> _polyLine = {}; final Set<Polyline> _polyLine = {};
BitmapDescriptor homeIcon; late BitmapDescriptor homeIcon;
BitmapDescriptor deliveryIcon; late BitmapDescriptor deliveryIcon;
BitmapDescriptor shopIcon; late BitmapDescriptor shopIcon;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;
@@ -110,7 +110,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
width: double.infinity, width: double.infinity,
padding: EdgeInsets.only(top: 0.0, bottom: 16.0), padding: EdgeInsets.only(top: 0.0, bottom: 16.0),
child: Text( child: Text(
order.cartInfo.businessInfo.name, order.cartInfo!.businessInfo!.name,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
@@ -141,7 +141,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
Icons.phone, Icons.phone,
), ),
onTap: () { onTap: () {
Utils.launchURL('tel:${order.businessInfo.phone}'); Utils.launchURL('tel:${order.businessInfo!.phone}');
}, },
), ),
), ),
@@ -156,7 +156,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
child: GoogleMap( child: GoogleMap(
onMapCreated: _onMapCreated, onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition( initialCameraPosition: CameraPosition(
target: new LatLng(double.parse(order.shippingAddress.lat), double.parse(order.shippingAddress.lng)), target: new LatLng(double.parse(order.shippingAddress!.lat), double.parse(order.shippingAddress!.lng)),
zoom: 11.0, zoom: 11.0,
), ),
onCameraMove: _onCameraMove, onCameraMove: _onCameraMove,
@@ -167,14 +167,14 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
].toSet(), ].toSet(),
), ),
)); ));
if (order.deliveryDistance != null && order.deliveryDistance.distance != null) { if (order.deliveryDistance != null && order.deliveryDistance!.distance != null) {
col.children.add(Container( col.children.add(Container(
padding: EdgeInsets.only(top: 6.0, bottom: 6.0), padding: EdgeInsets.only(top: 6.0, bottom: 6.0),
margin: EdgeInsets.only(bottom: 6.0), margin: EdgeInsets.only(bottom: 6.0),
child: Text( child: Text(
S.of(context).delivery_distance_token( S.of(context).delivery_distance_token(
order.deliveryDistance.distance.text, order.deliveryDistance!.distance!.text,
order.deliveryDistance.duration.text order.deliveryDistance!.duration!.text
), ),
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -190,7 +190,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
} }
} }
for (CartLineItem lineItem in order.cartInfo.productList) { for (CartLineItem lineItem in order.cartInfo!.productList) {
col.children.add(Container( col.children.add(Container(
padding: EdgeInsets.only(top: 16.0, bottom: 0.0), padding: EdgeInsets.only(top: 16.0, bottom: 0.0),
@@ -198,7 +198,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Util.showImage('${lineItem.product.imagePath}', Util.showImage('${lineItem.product!.imagePath}',
width: 40.0, width: 40.0,
height: 40.0, height: 40.0,
fit: BoxFit.fill, fit: BoxFit.fill,
@@ -236,7 +236,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
width: 30.0, width: 30.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'x${lineItem.quantity.round()}', 'x${lineItem.quantity!.round()}',
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
), ),
@@ -298,8 +298,8 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
], ],
), ),
); );
for (var i = 0; i < order.cartInfo.extraFeeList.length; i++) { for (var i = 0; i < order.cartInfo!.extraFeeList!.length; i++) {
ExtraFee extraFee = order.cartInfo.extraFeeList[i]; ExtraFee extraFee = order.cartInfo!.extraFeeList![i];
col.children.add( col.children.add(
Row( Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
@@ -323,7 +323,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
width: 100.0, width: 100.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${extraFee.price.toStringAsFixed(2)}', '${extraFee.price!.toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 15.0, fontSize: 15.0,
), ),
@@ -356,7 +356,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
width: 100.0, width: 100.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${order.totalPrice.toStringAsFixed(2)}', '${order.totalPrice!.toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 18.0, fontSize: 18.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -466,7 +466,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
margin: EdgeInsets.only(top: 10.0, bottom: 10.0), margin: EdgeInsets.only(top: 10.0, bottom: 10.0),
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${order.cartInfo.businessInfo.fullAddress}', '${order.cartInfo!.businessInfo!.fullAddress}',
style: TextStyle( style: TextStyle(
color: Colors.black38, color: Colors.black38,
), ),
@@ -893,19 +893,19 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Container( Container(
child: fulfillment.shippingMethod.isNotEmpty && fulfillment.trackingNumber != null && fulfillment.trackingNumber.isNotEmpty ? child: fulfillment.shippingMethod!.isNotEmpty && fulfillment.trackingNumber != null && fulfillment.trackingNumber!.isNotEmpty ?
Text( Text(
'${fulfillment.shippingMethod} ${fulfillment.trackingNumber}', '${fulfillment.shippingMethod} ${fulfillment.trackingNumber}',
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
maxLines: 1, maxLines: 1,
) : (fulfillment.shippingMethod.isNotEmpty ? Text( ) : (fulfillment.shippingMethod!.isNotEmpty ? Text(
'${fulfillment.shippingMethod}', '${fulfillment.shippingMethod}',
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
maxLines: 1, maxLines: 1,
) : SizedBox.shrink()), ) : SizedBox.shrink()),
), ),
Container( Container(
child: fulfillment.note != null && fulfillment.note.isNotEmpty ? child: fulfillment.note != null && fulfillment.note!.isNotEmpty ?
Text( Text(
'${fulfillment.note}', '${fulfillment.note}',
style: TextStyle( style: TextStyle(
@@ -1092,12 +1092,12 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
if (!kIsWeb) { if (!kIsWeb) {
if (order.shippingMethod == 'store-delivery' && order.status != Constants.STATUS_COMPLETE && order.status != Constants.STATUS_CANCELLED) { if (order.shippingMethod == 'store-delivery' && order.status != Constants.STATUS_COMPLETE && order.status != Constants.STATUS_CANCELLED) {
storeLatLng = LatLng(double.parse(order.businessInfo.address.lat), storeLatLng = LatLng(double.parse(order.businessInfo!.address!.lat),
double.parse(order.businessInfo.address.lng)); double.parse(order.businessInfo!.address!.lng));
customerLatLng = LatLng(double.parse(order.shippingAddress.lat), customerLatLng = LatLng(double.parse(order.shippingAddress!.lat),
double.parse(order.shippingAddress.lng)); double.parse(order.shippingAddress!.lng));
deliveryLatLng = deliveryLatLng =
LatLng(order.shipperPosition.lat, order.shipperPosition.lng); LatLng(order.shipperPosition!.lat, order.shipperPosition!.lng);
_polyLine.clear(); _polyLine.clear();
_polyLine.add( _polyLine.add(
@@ -1110,7 +1110,7 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
], ],
width: 3, width: 3,
points: [ points: [
order.shipperPosition.lat != 0.0 ? deliveryLatLng : storeLatLng, order.shipperPosition!.lat != 0.0 ? deliveryLatLng : storeLatLng,
customerLatLng, customerLatLng,
] ]
) )
@@ -1135,12 +1135,12 @@ class DesktopOrderDetailState extends State<DesktopOrderDetail> {
title: S title: S
.of(context) .of(context)
.customer, .customer,
snippet: order.shippingAddress.addressLine1, snippet: order.shippingAddress!.addressLine1,
), ),
icon: homeIcon, icon: homeIcon,
)); ));
if (order.shipperPosition.lat != 0.0 && if (order.shipperPosition!.lat != 0.0 &&
order.shipperPosition.lng != 0.0) { order.shipperPosition!.lng != 0.0) {
_markers.add(Marker( _markers.add(Marker(
markerId: MarkerId('shipper_position'), markerId: MarkerId('shipper_position'),
position: deliveryLatLng, position: deliveryLatLng,

View File

@@ -35,7 +35,7 @@ class DesktopOrders extends StatefulWidget {
class DesktopOrdersState extends State<DesktopOrders> with SingleTickerProviderStateMixin { class DesktopOrdersState extends State<DesktopOrders> with SingleTickerProviderStateMixin {
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
List<Order> orders; late List<Order> orders;
bool _isLoading = false; bool _isLoading = false;
@@ -181,7 +181,7 @@ class DesktopOrdersState extends State<DesktopOrders> with SingleTickerProviderS
row.children.add(Expanded( row.children.add(Expanded(
child: Container( child: Container(
child: Text( child: Text(
order.cartInfo.productList[0].name, order.cartInfo!.productList![0].name,
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
), ),
@@ -190,7 +190,7 @@ class DesktopOrdersState extends State<DesktopOrders> with SingleTickerProviderS
), ),
), ),
)); ));
if (order.cartInfo.productList.length > 1) { if (order.cartInfo!.productList!.length > 1) {
row.children.add(Container( row.children.add(Container(
child: Text( child: Text(
S.of(context).and_more_item_token(Utils.getProductLineInOrder(order.cartInfo)), S.of(context).and_more_item_token(Utils.getProductLineInOrder(order.cartInfo)),
@@ -205,7 +205,7 @@ class DesktopOrdersState extends State<DesktopOrders> with SingleTickerProviderS
width: 80.0, width: 80.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'\$${order.totalPrice.toStringAsFixed(2)}', '\$${order.totalPrice!.toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 16.0, fontSize: 16.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -320,7 +320,7 @@ class DesktopOrdersState extends State<DesktopOrders> with SingleTickerProviderS
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Container( Container(
child: Util.showImage('${order.cartInfo.businessInfo.picUrl}', child: Util.showImage('${order.cartInfo!.businessInfo!.picUrl}',
width: 32.0, width: 32.0,
height: 32.0, height: 32.0,
fit: BoxFit.fill, fit: BoxFit.fill,
@@ -336,7 +336,7 @@ class DesktopOrdersState extends State<DesktopOrders> with SingleTickerProviderS
children: <Widget>[ children: <Widget>[
Container( Container(
child: Text( child: Text(
'${order.cartInfo.businessInfo.name}', '${order.cartInfo!.businessInfo!.name}',
style: TextStyle( style: TextStyle(
fontSize: 20.0, fontSize: 20.0,
), ),

View File

@@ -32,9 +32,9 @@ class DesktopPayNow extends StatefulWidget {
} }
class DesktopPayNowState extends State<DesktopPayNow> { class DesktopPayNowState extends State<DesktopPayNow> {
Order order; late Order order;
List<PaymentPlatform> paymentPlatforms; late List<PaymentPlatform> paymentPlatforms;
User _user; late User _user;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;
@@ -86,7 +86,7 @@ class DesktopPayNowState extends State<DesktopPayNow> {
), ),
), ),
Text( Text(
'\$${order.totalPrice.toStringAsFixed(2)}', '\$${order.totalPrice!.toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 24.0, fontSize: 24.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -103,7 +103,7 @@ class DesktopPayNowState extends State<DesktopPayNow> {
) )
), ),
), ),
store.state.deviceId != null && store.state.deviceId.isNotEmpty || store.state.tableNumber != null && store.state.tableNumber.isNotEmpty ? store.state.deviceId != null && store.state.deviceId!.isNotEmpty || store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty ?
GestureDetector( GestureDetector(
child: Container( child: Container(
padding: EdgeInsets.only(top: 20.0, bottom: 20.0, left: 16.0, right: 16.0), padding: EdgeInsets.only(top: 20.0, bottom: 20.0, left: 16.0, right: 16.0),

View File

@@ -42,13 +42,13 @@ class DesktopProductDetailPage extends StatefulWidget {
class DesktopProductDetailPageState extends State<DesktopProductDetailPage> class DesktopProductDetailPageState extends State<DesktopProductDetailPage>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
TabController _tabController; late TabController _tabController;
final double _tabBarHeight = 50; final double _tabBarHeight = 50;
ProductDetail productDetail; late ProductDetail productDetail;
bool refresh; late bool refresh;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;
@@ -207,7 +207,7 @@ class DesktopProductDetailPageState extends State<DesktopProductDetailPage>
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
(productDetail.subproducts.length > 0) ? (productDetail.subproducts!.length > 0) ?
subProducts(productDetail.subproducts) : subProducts(productDetail.subproducts) :
SizedBox.shrink(), SizedBox.shrink(),
Container( Container(
@@ -222,7 +222,7 @@ class DesktopProductDetailPageState extends State<DesktopProductDetailPage>
Container( Container(
padding: EdgeInsets.only(left: 10.0, right: 10.0), padding: EdgeInsets.only(left: 10.0, right: 10.0),
child: (productDetail.description2 != null && child: (productDetail.description2 != null &&
!productDetail.description2.isEmpty) !productDetail.description2!.isEmpty)
? Text( ? Text(
'${productDetail.description2}', '${productDetail.description2}',
style: TextStyle( style: TextStyle(
@@ -299,7 +299,7 @@ class DesktopProductDetailPageState extends State<DesktopProductDetailPage>
} }
Widget getImage(double width) { Widget getImage(double width) {
if (productDetail.images.length <= 0) { if (productDetail.images!.length <= 0) {
return Util.showImage( return Util.showImage(
productDetail.image, productDetail.image,
width: width, width: width,
@@ -346,7 +346,7 @@ class DesktopProductDetailPageState extends State<DesktopProductDetailPage>
Container( Container(
padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 5.0), padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 5.0),
child: Util.showImage( child: Util.showImage(
'https:${subproduct.product.image}', 'https:${subproduct.product!.image}',
width: 48, width: 48,
height: 48, height: 48,
fit: BoxFit.contain, fit: BoxFit.contain,
@@ -366,7 +366,7 @@ class DesktopProductDetailPageState extends State<DesktopProductDetailPage>
child: Container( child: Container(
padding: EdgeInsets.only(left: 12, top: 5), padding: EdgeInsets.only(left: 12, top: 5),
child: Text( child: Text(
subproduct.product.name, subproduct.product!.name,
style: TextStyle( style: TextStyle(
fontSize: 15.0, fontSize: 15.0,
), ),
@@ -377,7 +377,7 @@ class DesktopProductDetailPageState extends State<DesktopProductDetailPage>
width: 80, width: 80,
padding: EdgeInsets.only(left: 12, top: 5, right: 12), padding: EdgeInsets.only(left: 12, top: 5, right: 12),
child: Text( child: Text(
'${subproduct.product.price.toStringAsFixed(2)}', '${subproduct.product!.price!.toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 13, fontSize: 13,
decoration: TextDecoration.lineThrough, decoration: TextDecoration.lineThrough,
@@ -389,7 +389,7 @@ class DesktopProductDetailPageState extends State<DesktopProductDetailPage>
width: 60, width: 60,
padding: EdgeInsets.only(left: 12, top: 5, right: 12), padding: EdgeInsets.only(left: 12, top: 5, right: 12),
child: Text( child: Text(
'x${subproduct.quantity.toStringAsFixed(0)}', 'x${subproduct.quantity!.toStringAsFixed(0)}',
style: TextStyle( style: TextStyle(
fontSize: 13, fontSize: 13,
), ),
@@ -401,7 +401,7 @@ class DesktopProductDetailPageState extends State<DesktopProductDetailPage>
Container( Container(
padding: EdgeInsets.only(left: 12, top: 12, right: 12), padding: EdgeInsets.only(left: 12, top: 12, right: 12),
child: Text( child: Text(
'${subproduct.product.description}', '${subproduct.product!.description}',
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
color: Colors.black45, color: Colors.black45,
@@ -453,9 +453,9 @@ class DesktopProductDetailPageState extends State<DesktopProductDetailPage>
var pages = <Widget>[]; var pages = <Widget>[];
List<String> images = []; List<String> images = [];
images.add(productDetail.image); images.add(productDetail.image);
for (var i = 0; i < productDetail.images.length; i++) { for (var i = 0; i < productDetail.images!.length; i++) {
// print('>>https:' + productDetail.images[i].image); // print('>>https:' + productDetail.images[i].image);
images.add(productDetail.images[i].image); images.add(productDetail.images![i].image);
} }
for (var i = 0; i < images.length; i++) { for (var i = 0; i < images.length; i++) {

View File

@@ -109,7 +109,7 @@ class DesktopProductItemState extends State<DesktopProductItem> {
new Container( new Container(
child: widget.business.showMonthlySold ? child: widget.business.showMonthlySold ?
Text( Text(
S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)),
style: new TextStyle( style: new TextStyle(
fontSize: 9.0 fontSize: 9.0
), ),
@@ -193,7 +193,7 @@ class DesktopProductItemState extends State<DesktopProductItem> {
new Container( new Container(
child: widget.business.showMonthlySold ? child: widget.business.showMonthlySold ?
Text( Text(
S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)),
style: new TextStyle( style: new TextStyle(
fontSize: 9.0 fontSize: 9.0
), ),

View File

@@ -134,7 +134,7 @@ class DesktopRenewLicenseState extends State<DesktopRenewLicense> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).please_enter_group_number; return S.of(context).please_enter_group_number;
} }
return null; return null;

View File

@@ -26,10 +26,10 @@ class DesktopResetPasswordState extends State<DesktopResetPassword> {
final passwordController = TextEditingController(); final passwordController = TextEditingController();
final passwordAgainController = TextEditingController(); final passwordAgainController = TextEditingController();
bool passwordVisible; late bool passwordVisible;
bool passwordAgainVisible; late bool passwordAgainVisible;
bool canReset; late bool canReset;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;
@@ -93,7 +93,7 @@ class DesktopResetPasswordState extends State<DesktopResetPassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
return null; return null;
@@ -147,10 +147,10 @@ class DesktopResetPasswordState extends State<DesktopResetPassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
if (value.trim() != passwordController.text.trim()) { if (value!.trim() != passwordController.text.trim()) {
return S.of(context).password_is_not_match_password_again; return S.of(context).password_is_not_match_password_again;
} }
return null; return null;

View File

@@ -128,7 +128,7 @@ class DesktopSearchPlaceState extends State<DesktopSearchPlace> {
); );
if (result is DioError) { if (result is DioError) {
if (result.response != null) { if (result.response != null) {
throw RuntimeError(result.response.data['message']); throw RuntimeError(result.response!.data['message']);
} else { } else {
throw RuntimeError(result.message); throw RuntimeError(result.message);
} }

View File

@@ -26,10 +26,10 @@ class DesktopSetPasswordState extends State<DesktopSetPassword> {
final passwordController = TextEditingController(); final passwordController = TextEditingController();
final passwordAgainController = TextEditingController(); final passwordAgainController = TextEditingController();
bool passwordVisible; late bool passwordVisible;
bool passwordAgainVisible; late bool passwordAgainVisible;
bool canReset; late bool canReset;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;
@@ -93,7 +93,7 @@ class DesktopSetPasswordState extends State<DesktopSetPassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
return null; return null;
@@ -147,10 +147,10 @@ class DesktopSetPasswordState extends State<DesktopSetPassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
if (value.trim() != passwordController.text.trim()) { if (value!.trim() != passwordController.text.trim()) {
return S.of(context).password_is_not_match_password_again; return S.of(context).password_is_not_match_password_again;
} }
return null; return null;

View File

@@ -18,14 +18,14 @@ class DesktopShoppingCartWidget extends StatefulWidget {
} }
class DesktopShoppingCartWidgetState extends State<DesktopShoppingCartWidget> { class DesktopShoppingCartWidgetState extends State<DesktopShoppingCartWidget> {
CartInfo cartInfo; late CartInfo cartInfo;
double totalPrice = 0.0; double totalPrice = 0.0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
totalPrice = 0.0; totalPrice = 0.0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business); cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
if (cartInfo != null && cartInfo.businessInfo.id == widget.business.id) { if (cartInfo != null && cartInfo.businessInfo!.id == widget.business.id) {
totalPrice = cartInfo.getTotalPrice(); totalPrice = cartInfo.getTotalPrice();
} }
Row row = Row( Row row = Row(

View File

@@ -134,7 +134,7 @@ class DesktopStoreProductSearchState extends State<DesktopStoreProductSearch> {
); );
if (result is DioError) { if (result is DioError) {
if (result.response != null) { if (result.response != null) {
throw RuntimeError(result.response.data); throw RuntimeError(result.response!.data);
} else { } else {
throw RuntimeError(result.message); throw RuntimeError(result.message);
} }

View File

@@ -27,10 +27,10 @@ class DesktopUserProfile extends StatefulWidget {
} }
class DesktopUserProfileState extends State<DesktopUserProfile> { class DesktopUserProfileState extends State<DesktopUserProfile> {
User _user; late User _user;
bool _showProgress; late bool _showProgress;
double _progress; late double _progress;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;
@@ -253,7 +253,7 @@ class DesktopUserProfileState extends State<DesktopUserProfile> {
), ),
Container( Container(
child: Text( child: Text(
_user.mobile != null && _user.mobile.isNotEmpty ? Utils.safePhoneNumber(_user.mobile) : S.of(context).not_binding, _user.mobile != null && _user.mobile!.isNotEmpty ? Utils.safePhoneNumber(_user.mobile) : S.of(context).not_binding,
style: TextStyle( style: TextStyle(
color: Colors.grey, color: Colors.grey,
), ),
@@ -306,7 +306,7 @@ class DesktopUserProfileState extends State<DesktopUserProfile> {
), ),
Container( Container(
child: Text( child: Text(
_user.email != null && _user.email.isNotEmpty ? Utils.safePhoneNumber(_user.email) : S.of(context).not_binding, _user.email != null && _user.email!.isNotEmpty ? Utils.safePhoneNumber(_user.email) : S.of(context).not_binding,
style: TextStyle( style: TextStyle(
color: Colors.grey, color: Colors.grey,
), ),
@@ -425,7 +425,7 @@ class DesktopUserProfileState extends State<DesktopUserProfile> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).nickname_is_required; return S.of(context).nickname_is_required;
} }
return null; return null;

View File

@@ -28,7 +28,7 @@ class DesktopViewBlog extends StatefulWidget {
} }
class DesktopViewBlogState extends State<DesktopViewBlog> { class DesktopViewBlogState extends State<DesktopViewBlog> {
Blog blog; late Blog blog;
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;

View File

@@ -33,7 +33,7 @@ class DesktopViewTicket extends StatefulWidget {
class DesktopViewTicketState extends State<DesktopViewTicket> { class DesktopViewTicketState extends State<DesktopViewTicket> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
Ticket ticket; late Ticket ticket;
final issueMsgController = TextEditingController(); final issueMsgController = TextEditingController();
@@ -144,7 +144,7 @@ class DesktopViewTicketState extends State<DesktopViewTicket> {
), ),
autofocus: false, autofocus: false,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).this_field_is_required; return S.of(context).this_field_is_required;
} }
return null; return null;
@@ -240,7 +240,7 @@ class DesktopViewTicketState extends State<DesktopViewTicket> {
width: double.maxFinite, width: double.maxFinite,
padding: EdgeInsets.only(top: 8.0, left: 16.0, right: 16.0, bottom: 24.0), padding: EdgeInsets.only(top: 8.0, left: 16.0, right: 16.0, bottom: 24.0),
child: Text( child: Text(
'${ticket.issue.msg}', '${ticket.issue!.msg}',
style: TextStyle( style: TextStyle(
color: Colors.black54, color: Colors.black54,
fontSize: 14.0, fontSize: 14.0,
@@ -260,7 +260,7 @@ class DesktopViewTicketState extends State<DesktopViewTicket> {
padding: EdgeInsets.only(top: 16.0, bottom: 16.0, left: 16.0, right: 16.0), padding: EdgeInsets.only(top: 16.0, bottom: 16.0, left: 16.0, right: 16.0),
child: SingleChildScrollView( child: SingleChildScrollView(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
child: showGalleryImages(mainContext, ticket.issue.files), child: showGalleryImages(mainContext, ticket.issue!.files),
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border( border: Border(
@@ -291,7 +291,7 @@ class DesktopViewTicketState extends State<DesktopViewTicket> {
], ],
); );
if (ticket.followUps.length > 0) { if (ticket.followUps!.length > 0) {
ticketCol.children.add( ticketCol.children.add(
Container( Container(
width: double.maxFinite, width: double.maxFinite,
@@ -305,8 +305,8 @@ class DesktopViewTicketState extends State<DesktopViewTicket> {
), ),
), ),
); );
for (int i = 0; i < ticket.followUps.length; i++) { for (int i = 0; i < ticket.followUps!.length; i++) {
FollowUp followUp = ticket.followUps[i]; FollowUp followUp = ticket.followUps![i];
ticketCol.children.add( ticketCol.children.add(
Container( Container(
width: double.maxFinite, width: double.maxFinite,
@@ -423,7 +423,7 @@ class DesktopViewTicketState extends State<DesktopViewTicket> {
padding: EdgeInsets.only(left: 20.0, right: 20.0, top: 0.0, bottom: 30.0), padding: EdgeInsets.only(left: 20.0, right: 20.0, top: 0.0, bottom: 30.0),
child: TextLink( child: TextLink(
S.of(context).new_ticket, S.of(context).new_ticket,
'/new-ticket/${ticket.store.id}', '/new-ticket/${ticket.store!.id}',
), ),
) )
], ],
@@ -693,7 +693,7 @@ class DesktopViewTicketState extends State<DesktopViewTicket> {
child: Text(S.of(context).ok), child: Text(S.of(context).ok),
onPressed: () { onPressed: () {
Routes.router.navigateTo(context, Routes.router.navigateTo(context,
'/my-support/${ticket.store.id}', '/my-support/${ticket.store!.id}',
replace: true, replace: true,
); );
}, },

View File

@@ -90,7 +90,7 @@ class ProductItemState extends State<ProductItem> {
width: 110.0, width: 110.0,
height: 110.0, height: 110.0,
child: GestureDetector( child: GestureDetector(
child: onHover && widget.product.secondImagePath.isNotEmpty ? child: onHover && widget.product.secondImagePath!.isNotEmpty ?
Util.showImage('${widget.product.secondImagePath}', Util.showImage('${widget.product.secondImagePath}',
fit: BoxFit.fill, fit: BoxFit.fill,
) : ) :
@@ -143,7 +143,7 @@ class ProductItemState extends State<ProductItem> {
new Container( new Container(
child: widget.business.showMonthlySold ? child: widget.business.showMonthlySold ?
Text( Text(
S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)),
style: new TextStyle( style: new TextStyle(
fontSize: 9.0 fontSize: 9.0
), ),
@@ -176,7 +176,7 @@ class ProductItemState extends State<ProductItem> {
width: 110.0, width: 110.0,
height: 110.0, height: 110.0,
child: GestureDetector( child: GestureDetector(
child: onHover && widget.product.secondImagePath.isNotEmpty ? child: onHover && widget.product.secondImagePath!.isNotEmpty ?
Util.showImage('${widget.product.secondImagePath}', Util.showImage('${widget.product.secondImagePath}',
fit: BoxFit.fill, fit: BoxFit.fill,
) : ) :
@@ -231,7 +231,7 @@ class ProductItemState extends State<ProductItem> {
new Container( new Container(
child: widget.business.showMonthlySold ? child: widget.business.showMonthlySold ?
Text( Text(
S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)),
style: new TextStyle( style: new TextStyle(
fontSize: 9.0 fontSize: 9.0
), ),

View File

@@ -142,7 +142,7 @@ class ProductSearchState extends State<ProductSearch> {
); );
if (result is DioError) { if (result is DioError) {
if (result.response != null) { if (result.response != null) {
throw RuntimeError(result.response.data); throw RuntimeError(result.response!.data);
} else { } else {
throw RuntimeError(result.message); throw RuntimeError(result.message);
} }

View File

@@ -32,13 +32,13 @@ class Shop extends StatefulWidget {
} }
class ShopState extends State<Shop> { class ShopState extends State<Shop> {
Business _business; late Business _business;
PanelController panelController = PanelController(); PanelController panelController = PanelController();
SlidingUpPanel _slidUpShoppingCart; late SlidingUpPanel _slidUpShoppingCart;
GlobalKey endKey = GlobalKey(); GlobalKey endKey = GlobalKey();
List<CategoryProducts> _categoryProducts; late List<CategoryProducts> _categoryProducts;
bool displayProductByCategoryClick = false; bool displayProductByCategoryClick = false;
String displayProductByCategoryClickIndicator = ''; String displayProductByCategoryClickIndicator = '';
int categoryId = 0; int categoryId = 0;
@@ -261,7 +261,7 @@ class ShopState extends State<Shop> {
if (moreCategoryProducts.isEmpty) { if (moreCategoryProducts.isEmpty) {
_productCurrentPage = 0; _productCurrentPage = 0;
} else { } else {
if (moreCategoryProducts[0].products.length < Constants.ORDERS_PER_PAGE) { if (moreCategoryProducts[0].products!.length < Constants.ORDERS_PER_PAGE) {
_productCurrentPage = 0; _productCurrentPage = 0;
} }
} }

View File

@@ -28,7 +28,7 @@ class ShopBulletinState extends State<ShopBulletin> {
sideSpace = (MediaQuery.of(context).size.width - 1200) / 2; sideSpace = (MediaQuery.of(context).size.width - 1200) / 2;
} }
if (widget.business.bulletin != null && widget.business.bulletin.isNotEmpty) { if (widget.business.bulletin != null && widget.business.bulletin!.isNotEmpty) {
return Container( return Container(
margin: EdgeInsets.only(bottom: 12), margin: EdgeInsets.only(bottom: 12),
child: Row( child: Row(

View File

@@ -39,7 +39,7 @@ class ShopProductsState extends State<ShopProducts> {
int _categoryIndex = 0; int _categoryIndex = 0;
List<CategoryProducts> _categoryProducts = []; List<CategoryProducts> _categoryProducts = [];
Business _business; late Business _business;
double menuPosition = 0; double menuPosition = 0;
@@ -116,11 +116,11 @@ class ShopProductsState extends State<ShopProducts> {
int qtyInCategory = 0; int qtyInCategory = 0;
CartInfo cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, _business); CartInfo cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, _business);
if (cartInfo != null && if (cartInfo != null &&
cartInfo.businessInfo.id == _business.id && cartInfo.businessInfo!.id == _business.id &&
cartInfo.productList != null) { cartInfo.productList != null) {
for (var i = 0; i < cartInfo.productList.length; i++) { for (var i = 0; i < cartInfo.productList!.length; i++) {
if (cartInfo.productList[i].product.categoryId == cp.id) { if (cartInfo.productList![i].product!.categoryId == cp.id) {
qtyInCategory += cartInfo.productList[i].quantity.ceil(); qtyInCategory += cartInfo.productList![i].quantity!.ceil();
} }
} }
} }
@@ -205,7 +205,7 @@ class ShopProductsState extends State<ShopProducts> {
); );
for (int i = 0; i < _categoryProducts.length; i++) { for (int i = 0; i < _categoryProducts.length; i++) {
CategoryProducts cp = _categoryProducts[i]; CategoryProducts cp = _categoryProducts[i];
if (cp.products.length > 0) { if (cp.products!.length > 0) {
col.children.add(new Container( col.children.add(new Container(
height: _categoryDescHeight, height: _categoryDescHeight,
padding: new EdgeInsets.symmetric(horizontal: 10.0), padding: new EdgeInsets.symmetric(horizontal: 10.0),
@@ -239,7 +239,7 @@ class ShopProductsState extends State<ShopProducts> {
), ),
), ),
new Visibility( new Visibility(
visible: cp.description.isNotEmpty, visible: cp.description!.isNotEmpty,
child: new Text( child: new Text(
cp.description, cp.description,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
@@ -253,8 +253,8 @@ class ShopProductsState extends State<ShopProducts> {
], ],
))); )));
var it = cp.products.iterator; var it = cp.products!.iterator;
for (int i = 0; i < cp.products.length; i++) { for (int i = 0; i < cp.products!.length; i++) {
var r1 = Row( var r1 = Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [], children: [],
@@ -295,7 +295,7 @@ class ShopProductsState extends State<ShopProducts> {
), ),
); );
} else if (categoryId > 0) { } else if (categoryId > 0) {
if (cp.products.length < Constants.ORDERS_PER_PAGE) { if (cp.products!.length < Constants.ORDERS_PER_PAGE) {
col.children.add( col.children.add(
Container( Container(
padding: EdgeInsets.all(12.0), padding: EdgeInsets.all(12.0),
@@ -374,7 +374,7 @@ class ShopProductsState extends State<ShopProducts> {
.of(context) .of(context)
.end_of_the_list; .end_of_the_list;
} else { } else {
if (moreCategoryProducts[0].products.length < if (moreCategoryProducts[0].products!.length <
Constants.ORDERS_PER_PAGE) { Constants.ORDERS_PER_PAGE) {
displayProductByCategoryClickIndicator = S displayProductByCategoryClickIndicator = S
.of(context) .of(context)
@@ -388,7 +388,7 @@ class ShopProductsState extends State<ShopProducts> {
CategoryProducts currentCp = CategoryProducts currentCp =
getCategoryProductByCategoryId(categoryId); getCategoryProductByCategoryId(categoryId);
if (currentCp != null) { if (currentCp != null) {
currentCp.products.addAll(moreCategoryProducts[0].products); currentCp.products!.addAll(moreCategoryProducts[0].products);
} else { } else {
displayProductByCategoryClickIndicator = S displayProductByCategoryClickIndicator = S
.of(context) .of(context)
@@ -403,7 +403,7 @@ class ShopProductsState extends State<ShopProducts> {
int numCategoriesHasProducts() { int numCategoriesHasProducts() {
int num = 0; int num = 0;
for (CategoryProducts cp in _categoryProducts) { for (CategoryProducts cp in _categoryProducts) {
if (cp.products.length > 0) { if (cp.products!.length > 0) {
num += 1; num += 1;
} }
} }

View File

@@ -22,7 +22,7 @@ class ShopPromoteState extends State<ShopPromote> {
double sideSpace = 0; double sideSpace = 0;
double mainSpace = 1200; double mainSpace = 1200;
Business _business; late Business _business;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -90,7 +90,7 @@ class ShopPromoteState extends State<ShopPromote> {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[], children: <Widget>[],
); );
for (var i = 0; i < _business.promoProducts.length; i++) { for (var i = 0; i < _business.promoProducts!.length; i++) {
promotRow.children.add(Container( promotRow.children.add(Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
left: 10.0, left: 10.0,
@@ -129,17 +129,17 @@ class ShopPromoteState extends State<ShopPromote> {
GestureDetector( GestureDetector(
child: Container( child: Container(
child: Util.showImage( child: Util.showImage(
_business.promoProducts[i].imagePath, _business.promoProducts![i].imagePath,
width: 120.0, width: 120.0,
), ),
), ),
onTap: () { onTap: () {
_showProductDetail(_business.promoProducts[i]); _showProductDetail(_business.promoProducts![i]);
}, },
), ),
Container( Container(
child: Text( child: Text(
_business.promoProducts[i].name, _business.promoProducts![i].name,
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 14.0), style: TextStyle(fontSize: 14.0),
@@ -149,16 +149,16 @@ class ShopPromoteState extends State<ShopPromote> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
ShowPrice( ShowPrice(
_business.promoProducts[i].price, _business.promoProducts![i].price,
currencySign: '\$', currencySign: '\$',
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
smallFontSize: 15, smallFontSize: 15,
largeFontSize: 24, largeFontSize: 24,
regularPrice: _business.promoProducts[i].regularPrice, regularPrice: _business.promoProducts![i].regularPrice,
), ),
Container( Container(
child: AddRemoveButton( child: AddRemoveButton(
product: _business.promoProducts[i], product: _business.promoProducts![i],
business: _business, business: _business,
addOnly: true, addOnly: true,
), ),

View File

@@ -19,14 +19,14 @@ class ShoppingCartWidget extends StatefulWidget {
} }
class ShoppingCartWidgetState extends State<ShoppingCartWidget> { class ShoppingCartWidgetState extends State<ShoppingCartWidget> {
CartInfo cartInfo; late CartInfo cartInfo;
double totalPrice = 0.0; double totalPrice = 0.0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
totalPrice = 0.0; totalPrice = 0.0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business); cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
if (cartInfo != null && cartInfo.businessInfo.id == widget.business.id) { if (cartInfo != null && cartInfo.businessInfo!.id == widget.business.id) {
totalPrice = cartInfo.getTotalPrice(); totalPrice = cartInfo.getTotalPrice();
} }
Row row = Row( Row row = Row(

View File

@@ -40,7 +40,7 @@ class AddRemoveButton extends StatefulWidget {
} }
class AddRemoveButtonState extends State<AddRemoveButton> { class AddRemoveButtonState extends State<AddRemoveButton> {
int _qty; late int _qty;
var zeroColor = const Color(0xFFEFEFEF); var zeroColor = const Color(0xFFEFEFEF);
var qtyColor = const Color(0xFFFF6666); var qtyColor = const Color(0xFFFF6666);
var zeroFontColor = const Color(0xFF888888); var zeroFontColor = const Color(0xFF888888);
@@ -48,7 +48,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
var d = 1; var d = 1;
CartInfo cartInfo; late CartInfo cartInfo;
GlobalKey startKey = GlobalKey(); GlobalKey startKey = GlobalKey();
@@ -63,10 +63,10 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
_qty = 0; _qty = 0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business); cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
if (cartInfo != null) { if (cartInfo != null) {
for (var i = 0; i < cartInfo.productList.length; i++) { for (var i = 0; i < cartInfo.productList!.length; i++) {
if (cartInfo.productList[i].product.id == widget.product.id if (cartInfo.productList![i].product!.id == widget.product.id
&& cartInfo.productList[i].unitPrice == 0.0) { && cartInfo.productList![i].unitPrice == 0.0) {
_qty = cartInfo.productList[i].quantity.round(); _qty = cartInfo.productList![i].quantity!.round();
break; break;
} }
} }
@@ -78,7 +78,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
), ),
); );
} }
if (widget.product.leftNum <= 0) { if (widget.product.leftNum! <= 0) {
return Container( return Container(
padding: EdgeInsets.only(top: 0.0, bottom: 10.0, left: 8.0, right: 8.0), padding: EdgeInsets.only(top: 0.0, bottom: 10.0, left: 8.0, right: 8.0),
child: Text( child: Text(
@@ -104,9 +104,9 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
_qty = 0; _qty = 0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business); cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
if (cartInfo != null) { if (cartInfo != null) {
for (var i = 0; i < cartInfo.productList.length; i++) { for (var i = 0; i < cartInfo.productList!.length; i++) {
if (cartInfo.productList[i].product.id == widget.product.id) { if (cartInfo.productList![i].product!.id == widget.product.id) {
_qty = cartInfo.productList[i].quantity.round(); _qty = cartInfo.productList![i].quantity!.round();
break; break;
} }
} }
@@ -197,15 +197,15 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
_qty = 0; _qty = 0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business); cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
if (cartInfo != null) { if (cartInfo != null) {
for (var i = 0; i < cartInfo.productList.length; i++) { for (var i = 0; i < cartInfo.productList!.length; i++) {
if (cartInfo.productList[i].product.id == widget.product.id) { if (cartInfo.productList![i].product!.id == widget.product.id) {
_qty = cartInfo.productList[i].quantity.round(); _qty = cartInfo.productList![i].quantity!.round();
break; break;
} }
} }
} }
if (widget.product.productAttributes != null && if (widget.product.productAttributes != null &&
widget.product.productAttributes.length > 0 && widget.cartLineItemIndex == -1) { widget.product.productAttributes!.length > 0 && widget.cartLineItemIndex == -1) {
return new Row( return new Row(
key: startKey, key: startKey,
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
@@ -312,7 +312,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
void _addToCart(BuildContext context) { void _addToCart(BuildContext context) {
if (widget.cartLineItemIndex != -1) { if (widget.cartLineItemIndex != -1) {
if (cartInfo.productList[widget.cartLineItemIndex].quantity + 1.0 > widget.product.leftNum) { if (cartInfo.productList![widget.cartLineItemIndex].quantity! + 1.0 > widget.product.leftNum) {
Fluttertoast.showToast( Fluttertoast.showToast(
msg: S.of(context).product_insufficient, msg: S.of(context).product_insufficient,
toastLength: Toast.LENGTH_SHORT, toastLength: Toast.LENGTH_SHORT,
@@ -321,14 +321,14 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
textColor: Colors.white textColor: Colors.white
); );
} else { } else {
cartInfo.productList[widget.cartLineItemIndex].quantity += 1.0; cartInfo.productList![widget.cartLineItemIndex].quantity += 1.0;
Utils.addSubproductQty(cartInfo, cartInfo.productList[widget.cartLineItemIndex]); Utils.addSubproductQty(cartInfo, cartInfo.productList![widget.cartLineItemIndex]);
store.dispatch(UpdateCartInfo( store.dispatch(UpdateCartInfo(
Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo))); Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo)));
eventBus.fire(new OnCartInfoUpdated()); eventBus.fire(new OnCartInfoUpdated());
} }
} else { } else {
if (widget.product.productAttributes.length > 0) { if (widget.product.productAttributes!.length > 0) {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => MaterialPageRoute(builder: (context) =>
@@ -345,7 +345,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
void _removeFromCart(BuildContext context) { void _removeFromCart(BuildContext context) {
if (widget.cartLineItemIndex != -1) { if (widget.cartLineItemIndex != -1) {
if (cartInfo.productList[widget.cartLineItemIndex].quantity <= 1) { if (cartInfo.productList![widget.cartLineItemIndex].quantity! <= 1) {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
@@ -380,15 +380,15 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
} }
void _removeCartLineItem() { void _removeCartLineItem() {
if (cartInfo.productList[widget.cartLineItemIndex].quantity <= 1) { if (cartInfo.productList![widget.cartLineItemIndex].quantity! <= 1) {
String uuid = cartInfo.productList[widget.cartLineItemIndex].uuid; String uuid = cartInfo.productList![widget.cartLineItemIndex].uuid;
cartInfo.productList.removeAt(widget.cartLineItemIndex); cartInfo.productList!.removeAt(widget.cartLineItemIndex);
Utils.removeSubproduct(cartInfo, uuid); Utils.removeSubproduct(cartInfo, uuid);
} else { } else {
cartInfo.productList[widget.cartLineItemIndex].quantity -= 1; cartInfo.productList![widget.cartLineItemIndex].quantity -= 1;
Utils.addSubproductQty(cartInfo, cartInfo.productList[widget.cartLineItemIndex], remove: true); Utils.addSubproductQty(cartInfo, cartInfo.productList![widget.cartLineItemIndex], remove: true);
} }
if (cartInfo.productList.length <= 0) { if (cartInfo.productList!.length <= 0) {
store.dispatch(new UpdateCartInfo(Utils.removeCartInfoFromCartInfoList(store.state.cartInfos, cartInfo))); store.dispatch(new UpdateCartInfo(Utils.removeCartInfoFromCartInfoList(store.state.cartInfos, cartInfo)));
} else { } else {
store.dispatch(new UpdateCartInfo(Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo))); store.dispatch(new UpdateCartInfo(Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo)));

View File

@@ -5,8 +5,8 @@ import 'popup_animation_widget.dart';
class AnimationPointManager { class AnimationPointManager {
List<AnimatedWidget> list = []; List<AnimatedWidget> list = [];
static AnimationController controller1; static late AnimationController controller1;
static AnimationController controller2; static late AnimationController controller2;
Future<void> addParabolicAniamtion({ Future<void> addParabolicAniamtion({
@required TickerProvider vsync, @required TickerProvider vsync,
@@ -55,9 +55,9 @@ class AnimationPointManager {
@required GlobalKey stackKey, @required GlobalKey stackKey,
@required GlobalKey startKey, @required GlobalKey startKey,
@required Widget child, @required Widget child,
Duration duration, Duration? duration,
Offset popupOffset = Offset.zero, Offset popupOffset = Offset.zero,
AnimationStatusListener statusListener, AnimationStatusListener? statusListener,
}) async { }) async {
controller2 = createController(vsync, duration); controller2 = createController(vsync, duration);

View File

@@ -50,14 +50,14 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
new Text( new Text(
S.of(context).check_option_select_token(product.productAttributes[this.index].name), S.of(context).check_option_select_token(product.productAttributes![this.index].name),
style: new TextStyle( style: new TextStyle(
fontSize: 12.5, fontSize: 12.5,
), ),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
new Text( new Text(
product.productAttributes[this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional, product.productAttributes![this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional,
style: new TextStyle( style: new TextStyle(
fontSize: 10.0, fontSize: 10.0,
color: new Color(0xFF999999) color: new Color(0xFF999999)
@@ -95,20 +95,20 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
'adjust_amount': adjustAmount 'adjust_amount': adjustAmount
}; };
var cloneSelections = json.decode(json.encode(selections)); var cloneSelections = json.decode(json.encode(selections));
int idx = Utils.selectionsContains(cloneSelections, product.productAttributes[index].name, name); int idx = Utils.selectionsContains(cloneSelections, product.productAttributes![index].name, name);
if (idx != -1) { if (idx != -1) {
(cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).removeAt(idx); (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).removeAt(idx);
} else if (cloneSelections.containsKey(product.productAttributes[index].name.toUpperCase())) { } else if (cloneSelections.containsKey(product.productAttributes![index].name!.toUpperCase())) {
(cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).add(opt); (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).add(opt);
} else { } else {
cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt]; cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt];
} }
if (idx != -1 && (cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).length == 0) { if (idx != -1 && (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).length == 0) {
cloneSelections.remove(product.productAttributes[index].name.toUpperCase()); cloneSelections.remove(product.productAttributes![index].name!.toUpperCase());
} }
setOptionsStateDisabled(product.productAttributes[index].name, false); setOptionsStateDisabled(product.productAttributes![index].name, false);
setState(() { setState(() {
selections = cloneSelections; selections = cloneSelections;
@@ -121,20 +121,20 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
children: <Widget>[], children: <Widget>[],
); );
List<ProductOption> productOptions = product.productAttributes[index].productOptions; List<ProductOption> productOptions = product.productAttributes![index].productOptions;
if (!optionsState.containsKey(product.productAttributes[index].name)) { if (!optionsState.containsKey(product.productAttributes![index].name)) {
List<Map<String, dynamic>> optionState = []; List<Map<String, dynamic>> optionState = [];
for (var i = 0; i < productOptions.length; i++) { for (var i = 0; i < productOptions.length; i++) {
optionState.add({'name': product.productAttributes[index].productOptions[i].name, 'disabled': false, 'check': false}); optionState.add({'name': product.productAttributes![index].productOptions![i].name, 'disabled': false, 'check': false});
} }
optionsState[product.productAttributes[index].name] = optionState; optionsState[product.productAttributes![index].name] = optionState;
} }
if (selections.containsKey(product.productAttributes[index].name.toUpperCase())) { if (selections.containsKey(product.productAttributes![index].name!.toUpperCase())) {
Map<String, dynamic> attrExtraJson = Utils.stringToJson( Map<String, dynamic> attrExtraJson = Utils.stringToJson(
product.productAttributes[index].extra); product.productAttributes![index].extra);
if (attrExtraJson != null) { if (attrExtraJson != null) {
var selectLimitIfFieldEqualsTo = Rule.getRule( var selectLimitIfFieldEqualsTo = Rule.getRule(
attrExtraJson, Rule.RULE_SELECT_LIMIT_IF_FIELD_EQUALS_TO); attrExtraJson, Rule.RULE_SELECT_LIMIT_IF_FIELD_EQUALS_TO);
@@ -147,7 +147,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
int limitQty = selectLimitIfFieldEqualsTo1[Rule int limitQty = selectLimitIfFieldEqualsTo1[Rule
.RULE_KEY_FORCE_LIMITED]; .RULE_KEY_FORCE_LIMITED];
thisLimitQty = limitQty; thisLimitQty = limitQty;
if ((selections[product.productAttributes[index].name if ((selections[product.productAttributes![index].name
.toUpperCase()] as List).length >= limitQty) { .toUpperCase()] as List).length >= limitQty) {
disableOptionIfNotSelected(); disableOptionIfNotSelected();
} }
@@ -155,7 +155,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
if (selectLimitIfFieldEqualsTo1.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0])) { if (selectLimitIfFieldEqualsTo1.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0])) {
int limitQty = selectLimitIfFieldEqualsTo1[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0]]; int limitQty = selectLimitIfFieldEqualsTo1[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0]];
thisLimitQty = limitQty; thisLimitQty = limitQty;
if ((selections[product.productAttributes[index].name if ((selections[product.productAttributes![index].name
.toUpperCase()] as List).length >= limitQty) { .toUpperCase()] as List).length >= limitQty) {
disableOptionIfNotSelected(); disableOptionIfNotSelected();
} }
@@ -168,7 +168,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
int limitQty = selectLimitIfFieldEqualsTo[Rule int limitQty = selectLimitIfFieldEqualsTo[Rule
.RULE_KEY_FORCE_LIMITED]; .RULE_KEY_FORCE_LIMITED];
thisLimitQty = limitQty; thisLimitQty = limitQty;
if ((selections[product.productAttributes[index].name if ((selections[product.productAttributes![index].name
.toUpperCase()] as List).length >= limitQty) { .toUpperCase()] as List).length >= limitQty) {
disableOptionIfNotSelected(); disableOptionIfNotSelected();
} }
@@ -176,7 +176,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
if (selectLimitIfFieldEqualsTo.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0])) { if (selectLimitIfFieldEqualsTo.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0])) {
int limitQty = selectLimitIfFieldEqualsTo[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0]]; int limitQty = selectLimitIfFieldEqualsTo[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0]];
thisLimitQty = limitQty; thisLimitQty = limitQty;
if ((selections[product.productAttributes[index].name if ((selections[product.productAttributes![index].name
.toUpperCase()] as List).length >= limitQty) { .toUpperCase()] as List).length >= limitQty) {
disableOptionIfNotSelected(); disableOptionIfNotSelected();
} }
@@ -195,12 +195,12 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
Map<String, dynamic> multiItemRule = Rule.getRule(extraJson, Rule.RULE_ACTUAL_QTY_IS); Map<String, dynamic> multiItemRule = Rule.getRule(extraJson, Rule.RULE_ACTUAL_QTY_IS);
if (exclusiveRule != null) { if (exclusiveRule != null) {
if (thisLimitQty > 0 && !_checkOptionIsCheck(productOptions[i].name)) { if (thisLimitQty > 0 && !_checkOptionIsCheck(productOptions[i].name)) {
optionsState[product.productAttributes[index].name][i]['disabled'] = true; optionsState[product.productAttributes![index].name][i]['disabled'] = true;
} else { } else {
if (_checkOptionIsCheck(productOptions[i].name)) { if (_checkOptionIsCheck(productOptions[i].name)) {
setOptionsStateDisabled( setOptionsStateDisabled(
product.productAttributes[index].name, true); product.productAttributes![index].name, true);
optionsState[product.productAttributes[index] optionsState[product.productAttributes![index]
.name][i]['disabled'] = false; .name][i]['disabled'] = false;
break; break;
} }
@@ -208,12 +208,12 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
} }
if (multiItemRule != null) { if (multiItemRule != null) {
if (_checkOptionIsCheck(productOptions[i].name)) { if (_checkOptionIsCheck(productOptions[i].name)) {
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) { if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes![index].name!.toUpperCase()] as List).length) {
disableOptionIfNotSelected(); disableOptionIfNotSelected();
} }
} else { } else {
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) { if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes![index].name!.toUpperCase()] as List).length) {
optionsState[product.productAttributes[index] optionsState[product.productAttributes![index]
.name][i]['disabled'] = true; .name][i]['disabled'] = true;
} }
} }
@@ -222,26 +222,26 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
} }
} }
List<Map<String, dynamic>> optionState = optionsState[product.productAttributes[index].name]; List<Map<String, dynamic>> optionState = optionsState[product.productAttributes![index].name];
for (var i = 0; i < optionState.length; i++) { for (var i = 0; i < optionState.length; i++) {
Widget optionWidget = _getOptionCheck( Widget optionWidget = _getOptionCheck(
product.productAttributes[index].productOptions[i], optionState[i]['disabled'], i); product.productAttributes![index].productOptions![i], optionState[i]['disabled'], i);
row.children.add(optionWidget); row.children.add(optionWidget);
} }
return row; return row;
} }
void disableOptionIfNotSelected() { void disableOptionIfNotSelected() {
setOptionsStateDisabled(product.productAttributes[index].name, true); setOptionsStateDisabled(product.productAttributes![index].name, true);
for (var i = 0; i < optionsState[product.productAttributes[index].name].length; i++) { for (var i = 0; i < optionsState[product.productAttributes![index].name].length; i++) {
if (Utils.selectionsContains(selections, product.productAttributes[index].name, optionsState[product.productAttributes[index].name][i]['name']) != -1) { if (Utils.selectionsContains(selections, product.productAttributes![index].name, optionsState[product.productAttributes![index].name][i]['name']) != -1) {
optionsState[product.productAttributes[index].name][i]['disabled'] = false; optionsState[product.productAttributes![index].name][i]['disabled'] = false;
} }
} }
} }
bool _checkOptionIsCheck(String name) { bool _checkOptionIsCheck(String name) {
if (Utils.selectionsContains(selections, product.productAttributes[index].name, name) != -1) { if (Utils.selectionsContains(selections, product.productAttributes![index].name, name) != -1) {
return true; return true;
} }
return false; return false;
@@ -343,7 +343,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
new Text( new Text(
(productOption.adjustAmount + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount + extraAdjustAmount).toStringAsFixed(2)}' : '', (productOption.adjustAmount! + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount! + extraAdjustAmount).toStringAsFixed(2)}' : '',
style: new TextStyle( style: new TextStyle(
fontSize: 11.0, fontSize: 11.0,
color: check ? selectedTextColor : new Color(0xFFABABAB), color: check ? selectedTextColor : new Color(0xFFABABAB),
@@ -354,7 +354,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
), ),
), ),
onTap: () => disabled ? null : _onOptionTappedCallback( onTap: () => disabled ? null : _onOptionTappedCallback(
productOption.name, 0, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption), productOption.name, 0, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption),
); );
} }

View File

@@ -16,9 +16,9 @@ abstract class OptionsBase extends StatefulWidget {
} }
abstract class OptionsBaseState<Base extends OptionsBase> extends State<Base> { abstract class OptionsBaseState<Base extends OptionsBase> extends State<Base> {
Product product; late Product product;
Map<String, dynamic> selections; late Map<String, dynamic> selections;
int index; late int index;
final Color disabledBackgroundColor = new Color(0xFFBCBCBC); final Color disabledBackgroundColor = new Color(0xFFBCBCBC);

View File

@@ -41,14 +41,14 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
new Text( new Text(
S.of(context).check_option_select_token(product.productAttributes[this.index].name), S.of(context).check_option_select_token(product.productAttributes![this.index].name),
style: new TextStyle( style: new TextStyle(
fontSize: 12.5, fontSize: 12.5,
), ),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
new Text( new Text(
product.productAttributes[this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional, product.productAttributes![this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional,
style: new TextStyle( style: new TextStyle(
fontSize: 10.0, fontSize: 10.0,
color: new Color(0xFF999999) color: new Color(0xFF999999)
@@ -86,33 +86,33 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
'adjust_amount': adjustAmount 'adjust_amount': adjustAmount
}; };
var cloneSelections = json.decode(json.encode(selections)); var cloneSelections = json.decode(json.encode(selections));
int idx = Utils.selectionsContains(cloneSelections, product.productAttributes[index].name, name); int idx = Utils.selectionsContains(cloneSelections, product.productAttributes![index].name, name);
if (idx != -1) { if (idx != -1) {
if (quantity == 1) { if (quantity == 1) {
cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'] += 1; cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'] += 1;
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity']; optionsState[product.productAttributes![index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'];
} else { } else {
if (cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'] - 1 > 0) { if (cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'] - 1 > 0) {
cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'] -= 1; cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'] -= 1;
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity']; optionsState[product.productAttributes![index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'];
} else { } else {
(cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).removeAt(idx); (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).removeAt(idx);
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = 0; optionsState[product.productAttributes![index].name][optIndex]['quantity'] = 0;
} }
} }
} else if (cloneSelections.containsKey(product.productAttributes[index].name.toUpperCase())) { } else if (cloneSelections.containsKey(product.productAttributes![index].name!.toUpperCase())) {
(cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).add(opt); (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).add(opt);
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = 1; optionsState[product.productAttributes![index].name][optIndex]['quantity'] = 1;
} else { } else {
cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt]; cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt];
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = 1; optionsState[product.productAttributes![index].name][optIndex]['quantity'] = 1;
} }
if (idx != -1 && (cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).length == 0) { if (idx != -1 && (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).length == 0) {
cloneSelections.remove(product.productAttributes[index].name.toUpperCase()); cloneSelections.remove(product.productAttributes![index].name!.toUpperCase());
} }
setOptionsStateDisabled(product.productAttributes[index].name, false); setOptionsStateDisabled(product.productAttributes![index].name, false);
setState(() { setState(() {
selections = cloneSelections; selections = cloneSelections;
@@ -125,24 +125,24 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
children: <Widget>[], children: <Widget>[],
); );
List<ProductOption> productOptions = product.productAttributes[index].productOptions; List<ProductOption> productOptions = product.productAttributes![index].productOptions;
if (!optionsState.containsKey(product.productAttributes[index].name)) { if (!optionsState.containsKey(product.productAttributes![index].name)) {
List<Map<String, dynamic>> optionState = []; List<Map<String, dynamic>> optionState = [];
for (var i = 0; i < productOptions.length; i++) { for (var i = 0; i < productOptions.length; i++) {
int qty = 0; int qty = 0;
int idx = Utils.selectionsContains(selections, product.productAttributes[index].name, productOptions[i].name); int idx = Utils.selectionsContains(selections, product.productAttributes![index].name, productOptions[i].name);
if (idx != -1) { if (idx != -1) {
qty = selections[product.productAttributes[index].name.toUpperCase()][idx]['quantity']; qty = selections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'];
} }
optionState.add({'name': product.productAttributes[index].productOptions[i].name, 'disabled': false, 'quantity': qty, 'check': false}); optionState.add({'name': product.productAttributes![index].productOptions![i].name, 'disabled': false, 'quantity': qty, 'check': false});
} }
optionsState[product.productAttributes[index].name] = optionState; optionsState[product.productAttributes![index].name] = optionState;
} }
if (selections.containsKey(product.productAttributes[index].name.toUpperCase())) { if (selections.containsKey(product.productAttributes![index].name!.toUpperCase())) {
Map<String, dynamic> attrExtraJson = Utils.stringToJson( Map<String, dynamic> attrExtraJson = Utils.stringToJson(
product.productAttributes[index].extra); product.productAttributes![index].extra);
if (attrExtraJson != null) { if (attrExtraJson != null) {
var selectLimitIfFieldEqualsTo = Rule.getRule( var selectLimitIfFieldEqualsTo = Rule.getRule(
attrExtraJson, Rule.RULE_SELECT_LIMIT_IF_FIELD_EQUALS_TO); attrExtraJson, Rule.RULE_SELECT_LIMIT_IF_FIELD_EQUALS_TO);
@@ -155,7 +155,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
int limitQty = selectLimitIfFieldEqualsTo1[Rule int limitQty = selectLimitIfFieldEqualsTo1[Rule
.RULE_KEY_FORCE_LIMITED]; .RULE_KEY_FORCE_LIMITED];
thisLimitQty = limitQty; thisLimitQty = limitQty;
if ((selections[product.productAttributes[index].name if ((selections[product.productAttributes![index].name
.toUpperCase()] as List).length >= limitQty) { .toUpperCase()] as List).length >= limitQty) {
disableOptionIfNotSelected(); disableOptionIfNotSelected();
} }
@@ -163,7 +163,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
if (selectLimitIfFieldEqualsTo1.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0])) { if (selectLimitIfFieldEqualsTo1.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0])) {
int limitQty = selectLimitIfFieldEqualsTo1[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0]]; int limitQty = selectLimitIfFieldEqualsTo1[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0]];
thisLimitQty = limitQty; thisLimitQty = limitQty;
if ((selections[product.productAttributes[index].name if ((selections[product.productAttributes![index].name
.toUpperCase()] as List).length >= limitQty) { .toUpperCase()] as List).length >= limitQty) {
disableOptionIfNotSelected(); disableOptionIfNotSelected();
} }
@@ -176,7 +176,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
int limitQty = selectLimitIfFieldEqualsTo[Rule int limitQty = selectLimitIfFieldEqualsTo[Rule
.RULE_KEY_FORCE_LIMITED]; .RULE_KEY_FORCE_LIMITED];
thisLimitQty = limitQty; thisLimitQty = limitQty;
if ((selections[product.productAttributes[index].name if ((selections[product.productAttributes![index].name
.toUpperCase()] as List).length >= limitQty) { .toUpperCase()] as List).length >= limitQty) {
disableOptionIfNotSelected(); disableOptionIfNotSelected();
} }
@@ -184,7 +184,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
if (selectLimitIfFieldEqualsTo.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0])) { if (selectLimitIfFieldEqualsTo.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0])) {
int limitQty = selectLimitIfFieldEqualsTo[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0]]; int limitQty = selectLimitIfFieldEqualsTo[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0]];
thisLimitQty = limitQty; thisLimitQty = limitQty;
if ((selections[product.productAttributes[index].name if ((selections[product.productAttributes![index].name
.toUpperCase()] as List).length >= limitQty) { .toUpperCase()] as List).length >= limitQty) {
disableOptionIfNotSelected(); disableOptionIfNotSelected();
} }
@@ -203,12 +203,12 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
Map<String, dynamic> multiItemRule = Rule.getRule(extraJson, Rule.RULE_ACTUAL_QTY_IS); Map<String, dynamic> multiItemRule = Rule.getRule(extraJson, Rule.RULE_ACTUAL_QTY_IS);
if (exclusiveRule != null) { if (exclusiveRule != null) {
if (thisLimitQty > 0 && !_checkOptionIsCheck(productOptions[i].name)) { if (thisLimitQty > 0 && !_checkOptionIsCheck(productOptions[i].name)) {
optionsState[product.productAttributes[index].name][i]['disabled'] = true; optionsState[product.productAttributes![index].name][i]['disabled'] = true;
} else { } else {
if (_checkOptionIsCheck(productOptions[i].name)) { if (_checkOptionIsCheck(productOptions[i].name)) {
setOptionsStateDisabled( setOptionsStateDisabled(
product.productAttributes[index].name, true); product.productAttributes![index].name, true);
optionsState[product.productAttributes[index] optionsState[product.productAttributes![index]
.name][i]['disabled'] = false; .name][i]['disabled'] = false;
break; break;
} }
@@ -216,12 +216,12 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
} }
if (multiItemRule != null) { if (multiItemRule != null) {
if (_checkOptionIsCheck(productOptions[i].name)) { if (_checkOptionIsCheck(productOptions[i].name)) {
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) { if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes![index].name!.toUpperCase()] as List).length) {
disableOptionIfNotSelected(); disableOptionIfNotSelected();
} }
} else { } else {
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) { if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes![index].name!.toUpperCase()] as List).length) {
optionsState[product.productAttributes[index] optionsState[product.productAttributes![index]
.name][i]['disabled'] = true; .name][i]['disabled'] = true;
} }
} }
@@ -230,26 +230,26 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
} }
} }
List<Map<String, dynamic>> optionState = optionsState[product.productAttributes[index].name]; List<Map<String, dynamic>> optionState = optionsState[product.productAttributes![index].name];
for (var i = 0; i < optionState.length; i++) { for (var i = 0; i < optionState.length; i++) {
Widget optionWidget = _getOptionQty( Widget optionWidget = _getOptionQty(
product.productAttributes[index].productOptions[i], optionState[i]['disabled'], optionState[i]['quantity'], i); product.productAttributes![index].productOptions![i], optionState[i]['disabled'], optionState[i]['quantity'], i);
row.children.add(optionWidget); row.children.add(optionWidget);
} }
return row; return row;
} }
void disableOptionIfNotSelected() { void disableOptionIfNotSelected() {
setOptionsStateDisabled(product.productAttributes[index].name, true); setOptionsStateDisabled(product.productAttributes![index].name, true);
for (var i = 0; i < optionsState[product.productAttributes[index].name].length; i++) { for (var i = 0; i < optionsState[product.productAttributes![index].name].length; i++) {
if (Utils.selectionsContains(selections, product.productAttributes[index].name, optionsState[product.productAttributes[index].name][i]['name']) != -1) { if (Utils.selectionsContains(selections, product.productAttributes![index].name, optionsState[product.productAttributes![index].name][i]['name']) != -1) {
optionsState[product.productAttributes[index].name][i]['disabled'] = false; optionsState[product.productAttributes![index].name][i]['disabled'] = false;
} }
} }
} }
bool _checkOptionIsCheck(String name) { bool _checkOptionIsCheck(String name) {
if (Utils.selectionsContains(selections, product.productAttributes[index].name, name) != -1) { if (Utils.selectionsContains(selections, product.productAttributes![index].name, name) != -1) {
return true; return true;
} }
return false; return false;
@@ -361,7 +361,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
new Text( new Text(
(productOption.adjustAmount + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount + extraAdjustAmount).toStringAsFixed(2)}' : '', (productOption.adjustAmount! + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount! + extraAdjustAmount).toStringAsFixed(2)}' : '',
style: new TextStyle( style: new TextStyle(
fontSize: 11.0, fontSize: 11.0,
color: check ? selectedTextColor : new Color(0xFFABABAB), color: check ? selectedTextColor : new Color(0xFFABABAB),
@@ -372,7 +372,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
), ),
), ),
onTap: () => disabled ? null : _onOptionTappedCallback( onTap: () => disabled ? null : _onOptionTappedCallback(
productOption.name, 1, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption), productOption.name, 1, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption),
), ),
new Container( new Container(
width: 100.0, width: 100.0,
@@ -406,7 +406,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
), ),
), ),
onTap: () => disabled ? null : _onOptionTappedCallback( onTap: () => disabled ? null : _onOptionTappedCallback(
productOption.name, 1, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption), productOption.name, 1, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption),
), ),
), ),
new Expanded( new Expanded(
@@ -420,7 +420,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
), ),
), ),
onTap: () => (disabled || quantity == 0) ? null : _onOptionTappedCallback( onTap: () => (disabled || quantity == 0) ? null : _onOptionTappedCallback(
productOption.name, -1, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption), productOption.name, -1, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption),
), ),
), ),
], ],

View File

@@ -40,14 +40,14 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
new Text( new Text(
S.of(context).radio_option_select_token(product.productAttributes[this.index].name), S.of(context).radio_option_select_token(product.productAttributes![this.index].name),
style: new TextStyle( style: new TextStyle(
fontSize: 12.5, fontSize: 12.5,
), ),
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 ? 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)
@@ -85,14 +85,14 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
'adjust_amount': adjustAmount 'adjust_amount': adjustAmount
}; };
var cloneSelections = json.decode(json.encode(selections)); var cloneSelections = json.decode(json.encode(selections));
if (product.productAttributes[index].required) { if (product.productAttributes![index].required) {
cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt]; cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt];
} else { } else {
if (cloneSelections.containsKey(product.productAttributes[index].name.toUpperCase()) if (cloneSelections.containsKey(product.productAttributes![index].name!.toUpperCase())
&& Utils.equalsIgnoreCase(cloneSelections[product.productAttributes[index].name.toUpperCase()][0]['name'], name)) { && Utils.equalsIgnoreCase(cloneSelections[product.productAttributes![index].name!.toUpperCase()][0]['name'], name)) {
cloneSelections.remove(product.productAttributes[index].name.toUpperCase()); cloneSelections.remove(product.productAttributes![index].name!.toUpperCase());
} else { } else {
cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt]; cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt];
} }
} }
@@ -102,7 +102,7 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
extraJson, Rule.RULE_EXCLUSIVE_SELECTION); extraJson, Rule.RULE_EXCLUSIVE_SELECTION);
if (exclusiveRule != null) { if (exclusiveRule != null) {
if (_checkOptionIsCheck(productOption.name)) { if (_checkOptionIsCheck(productOption.name)) {
setOptionsStateDisabled(product.productAttributes[index].name, false); setOptionsStateDisabled(product.productAttributes![index].name, false);
} }
} }
} }
@@ -118,14 +118,14 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
children: <Widget>[], children: <Widget>[],
); );
List<ProductOption> productOptions = product.productAttributes[index].productOptions; List<ProductOption> productOptions = product.productAttributes![index].productOptions;
if (!optionsState.containsKey(product.productAttributes[index].name)) { if (!optionsState.containsKey(product.productAttributes![index].name)) {
List<Map<String, dynamic>> optionState = []; List<Map<String, dynamic>> optionState = [];
for (var i = 0; i < productOptions.length; i++) { for (var i = 0; i < productOptions.length; i++) {
optionState.add({'name': product.productAttributes[index].productOptions[i].name, 'disabled': false, 'check': false}); optionState.add({'name': product.productAttributes![index].productOptions![i].name, 'disabled': false, 'check': false});
} }
optionsState[product.productAttributes[index].name] = optionState; optionsState[product.productAttributes![index].name] = optionState;
} }
for (var i = 0; i < productOptions.length; i++) { for (var i = 0; i < productOptions.length; i++) {
@@ -135,25 +135,25 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
extraJson, Rule.RULE_EXCLUSIVE_SELECTION); extraJson, Rule.RULE_EXCLUSIVE_SELECTION);
if (exclusiveRule != null) { if (exclusiveRule != null) {
if (_checkOptionIsCheck(productOptions[i].name)) { if (_checkOptionIsCheck(productOptions[i].name)) {
setOptionsStateDisabled(product.productAttributes[index].name, true); setOptionsStateDisabled(product.productAttributes![index].name, true);
optionsState[product.productAttributes[index].name][i]['disabled'] = false; optionsState[product.productAttributes![index].name][i]['disabled'] = false;
break; break;
} }
} }
} }
} }
List<Map<String, dynamic>> optionState = optionsState[product.productAttributes[index].name]; List<Map<String, dynamic>> optionState = optionsState[product.productAttributes![index].name];
for (var i = 0; i < optionState.length; i++) { for (var i = 0; i < optionState.length; i++) {
Widget optionWidget = _getOptionRadio( Widget optionWidget = _getOptionRadio(
product.productAttributes[index].productOptions[i], optionState[i]['disabled'], i); product.productAttributes![index].productOptions![i], optionState[i]['disabled'], i);
row.children.add(optionWidget); row.children.add(optionWidget);
} }
return row; return row;
} }
bool _checkOptionIsCheck(String name) { bool _checkOptionIsCheck(String name) {
if (Utils.selectionsContains(selections, product.productAttributes[index].name, name) != -1) { if (Utils.selectionsContains(selections, product.productAttributes![index].name, name) != -1) {
return true; return true;
} }
return false; return false;
@@ -255,7 +255,7 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
new Text( new Text(
(productOption.adjustAmount + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount + extraAdjustAmount).toStringAsFixed(2)}' : '', (productOption.adjustAmount! + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount! + extraAdjustAmount).toStringAsFixed(2)}' : '',
style: new TextStyle( style: new TextStyle(
fontSize: 11.0, fontSize: 11.0,
color: check ? selectedTextColor : new Color(0xFFABABAB), color: check ? selectedTextColor : new Color(0xFFABABAB),
@@ -266,7 +266,7 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
), ),
), ),
onTap: () => disabled ? null : _onOptionTappedCallback( onTap: () => disabled ? null : _onOptionTappedCallback(
productOption.name, 0, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption), productOption.name, 0, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption),
); );
} }

View File

@@ -6,8 +6,8 @@ import 'style.dart';
class Carousel extends StatefulWidget { class Carousel extends StatefulWidget {
Carousel({ Carousel({
double height = 200.0, double height = 200.0,
List<Widget> pages, List<Widget>? pages,
bool autoPlay, bool? autoPlay,
Duration duration = const Duration(seconds: 2), Duration duration = const Duration(seconds: 2),
Duration animationDuration = const Duration(milliseconds: 1000), Duration animationDuration = const Duration(milliseconds: 1000),
}) })
@@ -30,7 +30,7 @@ class Carousel extends StatefulWidget {
class CarouselState extends State<Carousel> { class CarouselState extends State<Carousel> {
final _pageController = new PageController(); final _pageController = new PageController();
Timer _timer; late Timer _timer;
int _currentPage = 0; int _currentPage = 0;
bool reverse = false; bool reverse = false;
GlobalKey<IndicatorState> _indicatorStateKey = new GlobalKey(); GlobalKey<IndicatorState> _indicatorStateKey = new GlobalKey();
@@ -80,7 +80,7 @@ class CarouselState extends State<Carousel> {
children: widget.pages, children: widget.pages,
onPageChanged: (index) { onPageChanged: (index) {
_currentPage = index; _currentPage = index;
_indicatorStateKey.currentState.changeIndex(index); _indicatorStateKey.currentState!.changeIndex(index);
}, },
), ),
), ),
@@ -102,7 +102,7 @@ class CarouselState extends State<Carousel> {
} }
class Indicator extends StatefulWidget { class Indicator extends StatefulWidget {
Indicator({Key? key, int count}) Indicator({Key? key, int? count})
: count = count, : count = count,
super(key: key); super(key: key);

View File

@@ -65,7 +65,7 @@ class ETransferPay extends StatelessWidget {
fontSize: 15, color: Colors.black54), fontSize: 15, color: Colors.black54),
), ),
Text( Text(
'\$${order.totalPrice.toStringAsFixed(2)}', '\$${order.totalPrice!.toStringAsFixed(2)}',
style: const TextStyle( style: const TextStyle(
fontSize: 28, fontSize: 28,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,

View File

@@ -11,7 +11,7 @@ class ParabolicAnimationWidget extends AnimatedWidget {
final Offset startAdjustOffset; final Offset startAdjustOffset;
final Offset endAdjustOffset; final Offset endAdjustOffset;
ParabolicAnimationWidget({ late ParabolicAnimationWidget({
@required Animation<double> animation, @required Animation<double> animation,
@required this.stackKey, @required this.stackKey,
@required this.startKey, @required this.startKey,
@@ -66,17 +66,17 @@ class ParabolicAnimationWidget extends AnimatedWidget {
void _calPoints() { void _calPoints() {
if (_startOffset == null) { if (_startOffset == null) {
RenderBox stackBox = stackKey.currentContext.findRenderObject(); RenderBox stackBox = stackKey.currentContext!.findRenderObject();
Offset stackBoxOffset = stackBox.globalToLocal(Offset.zero); Offset stackBoxOffset = stackBox.globalToLocal(Offset.zero);
EdgeInsets startMargin = _margin(startKey); EdgeInsets startMargin = _margin(startKey);
RenderBox startBox = startKey.currentContext.findRenderObject(); RenderBox startBox = startKey.currentContext!.findRenderObject();
_startOffset = startBox.localToGlobal(Offset( _startOffset = startBox.localToGlobal(Offset(
startMargin.left + startAdjustOffset.dx, startMargin.left + startAdjustOffset.dx,
stackBoxOffset.dy + startMargin.top + startAdjustOffset.dy)); stackBoxOffset.dy + startMargin.top + startAdjustOffset.dy));
EdgeInsets endMargin = _margin(endKey); EdgeInsets endMargin = _margin(endKey);
RenderBox endBox = endKey.currentContext.findRenderObject(); RenderBox endBox = endKey.currentContext!.findRenderObject();
_endOffset = endBox.localToGlobal(Offset( _endOffset = endBox.localToGlobal(Offset(
endMargin.left + endAdjustOffset.dx, endMargin.left + endAdjustOffset.dx,
stackBoxOffset.dy + endMargin.top + endAdjustOffset.dy)); stackBoxOffset.dy + endMargin.top + endAdjustOffset.dy));
@@ -84,7 +84,7 @@ class ParabolicAnimationWidget extends AnimatedWidget {
} }
EdgeInsets _margin(GlobalKey key) { EdgeInsets _margin(GlobalKey key) {
final Widget widget = key.currentContext.widget; final Widget widget = key.currentContext!.widget;
EdgeInsets margin = (widget is Container) ? widget.margin : EdgeInsets.zero; EdgeInsets margin = (widget is Container) ? widget.margin : EdgeInsets.zero;
return margin ?? EdgeInsets.zero; return margin ?? EdgeInsets.zero;
} }

View File

@@ -33,8 +33,8 @@ class PaymentVerificationCodeDialogState extends State<PaymentVerificationCodeDi
String getCodeText = ''; String getCodeText = '';
String paymentCodeEncrypt = ''; String paymentCodeEncrypt = '';
String verifyMethod; late String verifyMethod;
String verifyName; late String verifyName;
final TextEditingController _pinPutController = TextEditingController(); final TextEditingController _pinPutController = TextEditingController();
final FocusNode _pinPutFocusNode = FocusNode(); final FocusNode _pinPutFocusNode = FocusNode();

View File

@@ -9,7 +9,7 @@ class PopupAnimationWidget extends AnimatedWidget {
final Offset popupOffset; final Offset popupOffset;
final Animation<double> animation; final Animation<double> animation;
PopupAnimationWidget({ late PopupAnimationWidget({
@required this.animation, @required this.animation,
@required this.stackKey, @required this.stackKey,
@required this.startKey, @required this.startKey,
@@ -49,11 +49,11 @@ class PopupAnimationWidget extends AnimatedWidget {
void _calAnimation() { void _calAnimation() {
if (_startOffset == null) { if (_startOffset == null) {
final RenderBox stackBox = stackKey.currentContext.findRenderObject(); final RenderBox stackBox = stackKey.currentContext!.findRenderObject();
final Offset stackBoxOffset = stackBox.globalToLocal(Offset.zero); final Offset stackBoxOffset = stackBox.globalToLocal(Offset.zero);
final EdgeInsets startMargin = _margin(startKey); final EdgeInsets startMargin = _margin(startKey);
final RenderBox startBox = startKey.currentContext.findRenderObject(); final RenderBox startBox = startKey.currentContext!.findRenderObject();
_startOffset = startBox.localToGlobal(Offset( _startOffset = startBox.localToGlobal(Offset(
startMargin.left + popupOffset.dx, startMargin.left + popupOffset.dx,
@@ -62,7 +62,7 @@ class PopupAnimationWidget extends AnimatedWidget {
} }
EdgeInsets _margin(GlobalKey key) { EdgeInsets _margin(GlobalKey key) {
final Widget widget = key.currentContext.widget; final Widget widget = key.currentContext!.widget;
final EdgeInsets margin = final EdgeInsets margin =
(widget is Container) ? widget.margin : EdgeInsets.zero; (widget is Container) ? widget.margin : EdgeInsets.zero;
return margin ?? EdgeInsets.zero; return margin ?? EdgeInsets.zero;

View File

@@ -211,9 +211,9 @@ class SlidingUpPanel extends StatefulWidget {
class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProviderStateMixin{ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProviderStateMixin{
AnimationController _ac; late AnimationController _ac;
ScrollController _sc; late ScrollController _sc;
bool _scrollingEnabled = false; bool _scrollingEnabled = false;
VelocityTracker _vt = VelocityTracker.withKind(PointerDeviceKind.touch); VelocityTracker _vt = VelocityTracker.withKind(PointerDeviceKind.touch);
@@ -390,7 +390,7 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
// and a listener if panelBuilder is used. // and a listener if panelBuilder is used.
// this is because the listener is designed only for use with linking the scrolling of // this is because the listener is designed only for use with linking the scrolling of
// panels and using it for panels that don't want to linked scrolling yields odd results // panels and using it for panels that don't want to linked scrolling yields odd results
Widget _gestureHandler({Widget child}){ Widget _gestureHandler({Widget? child}){
if (!widget.isDraggable) return child; if (!widget.isDraggable) return child;
if (widget.panel != null){ if (widget.panel != null){
@@ -552,14 +552,14 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
//animate the panel position to value - must //animate the panel position to value - must
//be between 0.0 and 1.0 //be between 0.0 and 1.0
Future<void> _animatePanelToPosition(double value, {Duration duration, Curve curve = Curves.linear}){ Future<void> _animatePanelToPosition(double value, {Duration? duration, Curve curve = Curves.linear}){
assert(0.0 <= value && value <= 1.0); assert(0.0 <= value && value <= 1.0);
return _ac.animateTo(value, duration: duration, curve: curve); return _ac.animateTo(value, duration: duration, curve: curve);
} }
//animate the panel position to the snap point //animate the panel position to the snap point
//REQUIRES that widget.snapPoint != null //REQUIRES that widget.snapPoint != null
Future<void> _animatePanelToSnapPoint({Duration duration, Curve curve = Curves.linear}){ Future<void> _animatePanelToSnapPoint({Duration? duration, Curve curve = Curves.linear}){
assert(widget.snapPoint != null); assert(widget.snapPoint != null);
return _ac.animateTo(widget.snapPoint, duration: duration, curve: curve); return _ac.animateTo(widget.snapPoint, duration: duration, curve: curve);
} }
@@ -602,7 +602,7 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
class PanelController{ class PanelController{
_SlidingUpPanelState _panelState; late _SlidingUpPanelState _panelState;
void _addState(_SlidingUpPanelState panelState){ void _addState(_SlidingUpPanelState panelState){
this._panelState = panelState; this._panelState = panelState;
@@ -644,7 +644,7 @@ class PanelController{
/// where 0.0 is fully collapsed and 1.0 is completely open. /// where 0.0 is fully collapsed and 1.0 is completely open.
/// (optional) duration specifies the time for the animation to complete /// (optional) duration specifies the time for the animation to complete
/// (optional) curve specifies the easing behavior of the animation. /// (optional) curve specifies the easing behavior of the animation.
Future<void> animatePanelToPosition(double value, {Duration duration, Curve curve = Curves.linear}){ Future<void> animatePanelToPosition(double value, {Duration? duration, Curve curve = Curves.linear}){
assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
assert(0.0 <= value && value <= 1.0); assert(0.0 <= value && value <= 1.0);
return _panelState._animatePanelToPosition(value, duration: duration, curve: curve); return _panelState._animatePanelToPosition(value, duration: duration, curve: curve);
@@ -654,7 +654,7 @@ class PanelController{
/// Requires that the SlidingUpPanel snapPoint property is not null /// Requires that the SlidingUpPanel snapPoint property is not null
/// (optional) duration specifies the time for the animation to complete /// (optional) duration specifies the time for the animation to complete
/// (optional) curve specifies the easing behavior of the animation. /// (optional) curve specifies the easing behavior of the animation.
Future<void> animatePanelToSnapPoint({Duration duration, Curve curve = Curves.linear}){ Future<void> animatePanelToSnapPoint({Duration? duration, Curve curve = Curves.linear}){
assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
assert(_panelState.widget.snapPoint != null, "SlidingUpPanel snapPoint property must not be null"); assert(_panelState.widget.snapPoint != null, "SlidingUpPanel snapPoint property must not be null");
return _panelState._animatePanelToSnapPoint(duration: duration, curve: curve); return _panelState._animatePanelToSnapPoint(duration: duration, curve: curve);

View File

@@ -30,12 +30,12 @@ class CreateOnlineStore1State extends State<CreateOnlineStore1> {
bool canSubmit = false; bool canSubmit = false;
List<dynamic> stores = []; List<dynamic> stores = [];
Map<String, dynamic> service; late Map<String, dynamic> service;
dynamic selectedStore; dynamic selectedStore;
Group group; late Group group;
String selectedDomain; late String selectedDomain;
List<dynamic> domainResult = []; List<dynamic> domainResult = [];
@override @override
@@ -231,7 +231,7 @@ class CreateOnlineStore1State extends State<CreateOnlineStore1> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).domains_separated_comma; return S.of(context).domains_separated_comma;
} }
return null; return null;

View File

@@ -33,18 +33,18 @@ class MobileAttributeSelection extends StatefulWidget {
} }
class MobileAttributeSelectionState extends State<MobileAttributeSelection> { class MobileAttributeSelectionState extends State<MobileAttributeSelection> {
Product product; late Product product;
int index; late int index;
TextButton previousButton; late TextButton previousButton;
TextButton nextButton; late TextButton nextButton;
bool previousButtonEnable; late bool previousButtonEnable;
bool nextButtonEnable; late bool nextButtonEnable;
String productDesc; late String productDesc;
double productPrice; late double productPrice;
String nextText; late String nextText;
String finishText; late String finishText;
Map<String, dynamic> selections = new Map(); Map<String, dynamic> selections = new Map();
@@ -118,31 +118,31 @@ class MobileAttributeSelectionState extends State<MobileAttributeSelection> {
extendDescription.add(key + ': ' + opt.join(', ')); extendDescription.add(key + ': ' + opt.join(', '));
}); });
ProductAttribute pa = product.productAttributes[index]; ProductAttribute pa = product.productAttributes![index];
if (pa.required && Utils.selectionsNotEmptyAt(selections, pa.name)) { if (pa.required && Utils.selectionsNotEmptyAt(selections, pa.name)) {
setState(() { setState(() {
nextButtonEnable = true; nextButtonEnable = true;
productDesc = product.description + ', ' + extendDescription.join('; '); productDesc = product.description! + ', ' + extendDescription.join('; ');
productPrice = product.price + extendPrice; productPrice = product.price! + extendPrice;
}); });
} else if (!pa.required){ } else if (!pa.required){
setState(() { setState(() {
nextButtonEnable = true; nextButtonEnable = true;
productDesc = product.description + ', ' + extendDescription.join('; '); productDesc = product.description! + ', ' + extendDescription.join('; ');
productPrice = product.price + extendPrice; productPrice = product.price! + extendPrice;
}); });
} else { } else {
setState(() { setState(() {
nextButtonEnable = false; nextButtonEnable = false;
productDesc = product.description + ', ' + extendDescription.join('; '); productDesc = product.description! + ', ' + extendDescription.join('; ');
productPrice = product.price + extendPrice; productPrice = product.price! + extendPrice;
}); });
} }
}); });
} }
bool _checkCanGoNext() { bool _checkCanGoNext() {
ProductAttribute pa = product.productAttributes[index]; ProductAttribute pa = product.productAttributes![index];
if (pa.required && Utils.selectionsNotEmptyAt(selections, pa.name)) { if (pa.required && Utils.selectionsNotEmptyAt(selections, pa.name)) {
return true; return true;
} else if (!pa.required){ } else if (!pa.required){
@@ -167,7 +167,7 @@ class MobileAttributeSelectionState extends State<MobileAttributeSelection> {
nextButton = TextButton( nextButton = TextButton(
onPressed: nextButtonEnable ? _goNext : null, onPressed: nextButtonEnable ? _goNext : null,
child: new Text( child: new Text(
product.productAttributes.length > index + 1 ? nextText : finishText product.productAttributes!.length > index + 1 ? nextText : finishText
), ),
); );
@@ -239,7 +239,7 @@ class MobileAttributeSelectionState extends State<MobileAttributeSelection> {
Widget _getOptionsView() { Widget _getOptionsView() {
Widget optionsView; Widget optionsView;
ProductAttribute productAttribute = product.productAttributes[index]; ProductAttribute productAttribute = product.productAttributes![index];
if (productAttribute.byQuantity) { if (productAttribute.byQuantity) {
optionsView = new QtyOptions(product: product, index: index, selections: selections); optionsView = new QtyOptions(product: product, index: index, selections: selections);
} else { } else {
@@ -254,13 +254,13 @@ class MobileAttributeSelectionState extends State<MobileAttributeSelection> {
} }
void _goNext() { void _goNext() {
if (index + 1 < product.productAttributes.length) { if (index + 1 < product.productAttributes!.length) {
setState(() { setState(() {
index = index + 1; index = index + 1;
previousButtonEnable = index >= 1; previousButtonEnable = index >= 1;
nextButtonEnable = _checkCanGoNext(); nextButtonEnable = _checkCanGoNext();
}); });
} else if (product.productAttributes.length == index + 1) { } else if (product.productAttributes!.length == index + 1) {
eventBus.fire(new OnProductWillAddToCart(product, selections, productPrice, productDesc, widget.business, buttonKey: widget.startKey)); eventBus.fire(new OnProductWillAddToCart(product, selections, productPrice, productDesc, widget.business, buttonKey: widget.startKey));
Navigator.pop(context); Navigator.pop(context);
} }

View File

@@ -28,7 +28,7 @@ class MobileBlog extends StatefulWidget {
} }
class MobileBlogState extends State<MobileBlog> { class MobileBlogState extends State<MobileBlog> {
List<Blog> blogs; late List<Blog> blogs;
int _page = 1; int _page = 1;
int _pageCount = 1; int _pageCount = 1;

View File

@@ -20,7 +20,7 @@ class MobileBuyService extends StatefulWidget {
class MobileBuyServiceState extends State<MobileBuyService> { class MobileBuyServiceState extends State<MobileBuyService> {
List<KeyValue> plans = []; List<KeyValue> plans = [];
KeyValue selectedPlan; late KeyValue selectedPlan;
double price = 0.0; double price = 0.0;
double tax = 0.0; double tax = 0.0;
double paymentAmount = 0.0; double paymentAmount = 0.0;

View File

@@ -31,9 +31,9 @@ class MobileChangeMobileOrEmailState extends State<MobileChangeMobileOrEmail> {
bool usernameEnable = true; bool usernameEnable = true;
final codeController = TextEditingController(); final codeController = TextEditingController();
bool enableGetCode; late bool enableGetCode;
String getCodeText; late String getCodeText;
bool canRegister; late bool canRegister;
var countDownListener; var countDownListener;
@@ -94,7 +94,7 @@ class MobileChangeMobileOrEmailState extends State<MobileChangeMobileOrEmail> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
if (widget.isMobile) { if (widget.isMobile) {
return S return S
.of(context) .of(context)
@@ -105,10 +105,10 @@ class MobileChangeMobileOrEmailState extends State<MobileChangeMobileOrEmail> {
.email_is_required; .email_is_required;
} }
} }
if (widget.isMobile && value.trim() == store.state.user.mobile) { if (widget.isMobile && value!.trim() == store.state.user!.mobile) {
return S.of(context).the_mobile_number_is_same_as_current; return S.of(context).the_mobile_number_is_same_as_current;
} }
if (!widget.isMobile && value.trim() == store.state.user.email) { if (!widget.isMobile && value!.trim() == store.state.user!.email) {
return S.of(context).the_email_is_same_as_current; return S.of(context).the_email_is_same_as_current;
} }
return null; return null;
@@ -191,7 +191,7 @@ class MobileChangeMobileOrEmailState extends State<MobileChangeMobileOrEmail> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).verification_code_is_required; return S.of(context).verification_code_is_required;
} }
return null; return null;
@@ -269,7 +269,7 @@ class MobileChangeMobileOrEmailState extends State<MobileChangeMobileOrEmail> {
}, },
isFormData: true, isFormData: true,
body: { body: {
'id': store.state.user.id, 'id': store.state.user!.id,
'mobile': usernameController.text.trim(), 'mobile': usernameController.text.trim(),
'code': codeController.text.trim(), 'code': codeController.text.trim(),
}, },
@@ -281,8 +281,8 @@ class MobileChangeMobileOrEmailState extends State<MobileChangeMobileOrEmail> {
void getCodeTapped() { void getCodeTapped() {
if (usernameController.text.isNotEmpty && if (usernameController.text.isNotEmpty &&
((widget.isMobile && usernameController.text.trim() != store.state.user.mobile) || ((widget.isMobile && usernameController.text.trim() != store.state.user!.mobile) ||
(!widget.isMobile && usernameController.text.trim() != store.state.user.email))) { (!widget.isMobile && usernameController.text.trim() != store.state.user!.email))) {
HttpUtil.httpPost('v1/users', (response) { HttpUtil.httpPost('v1/users', (response) {
Fluttertoast.showToast( Fluttertoast.showToast(
msg: S.of(context).verification_code_sent, msg: S.of(context).verification_code_sent,
@@ -303,7 +303,7 @@ class MobileChangeMobileOrEmailState extends State<MobileChangeMobileOrEmail> {
'action': 'change_mobile_email_send_code' 'action': 'change_mobile_email_send_code'
}, },
body: { body: {
'id': store.state.user.id, 'id': store.state.user!.id,
'mobile': usernameController.text, 'mobile': usernameController.text,
}, },
isFormData: true, isFormData: true,
@@ -321,9 +321,9 @@ class MobileChangeMobileOrEmailState extends State<MobileChangeMobileOrEmail> {
errorMsg = S.of(context).mobile_is_required; errorMsg = S.of(context).mobile_is_required;
} else if (!widget.isMobile && usernameController.text.trim().isEmpty) { } else if (!widget.isMobile && usernameController.text.trim().isEmpty) {
errorMsg = S.of(context).email_is_required; errorMsg = S.of(context).email_is_required;
} else if (widget.isMobile && usernameController.text.trim() == store.state.user.mobile) { } else if (widget.isMobile && usernameController.text.trim() == store.state.user!.mobile) {
errorMsg = S.of(context).the_mobile_number_is_same_as_current; errorMsg = S.of(context).the_mobile_number_is_same_as_current;
} else if (!widget.isMobile && usernameController.text.trim() == store.state.user.email) { } else if (!widget.isMobile && usernameController.text.trim() == store.state.user!.email) {
errorMsg = S.of(context).the_email_is_same_as_current; errorMsg = S.of(context).the_email_is_same_as_current;
} }
Fluttertoast.showToast( Fluttertoast.showToast(

View File

@@ -22,10 +22,10 @@ class MobileChangePasswordState extends State<MobileChangePassword> {
final passwordController = TextEditingController(); final passwordController = TextEditingController();
final passwordAgainController = TextEditingController(); final passwordAgainController = TextEditingController();
bool passwordVisible; late bool passwordVisible;
bool passwordAgainVisible; late bool passwordAgainVisible;
bool canReset; late bool canReset;
@override @override
void initState() { void initState() {
@@ -88,7 +88,7 @@ class MobileChangePasswordState extends State<MobileChangePassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).current_password_is_required; return S.of(context).current_password_is_required;
} }
return null; return null;
@@ -142,7 +142,7 @@ class MobileChangePasswordState extends State<MobileChangePassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
return null; return null;
@@ -196,10 +196,10 @@ class MobileChangePasswordState extends State<MobileChangePassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
if (value.trim() != passwordController.text.trim()) { if (value!.trim() != passwordController.text.trim()) {
return S.of(context).password_is_not_match_password_again; return S.of(context).password_is_not_match_password_again;
} }
return null; return null;
@@ -276,7 +276,7 @@ class MobileChangePasswordState extends State<MobileChangePassword> {
}, },
isFormData: true, isFormData: true,
body: { body: {
'id': store.state.user.id, 'id': store.state.user!.id,
'old_password': oldPasswordController.text.trim(), 'old_password': oldPasswordController.text.trim(),
'password': passwordController.text.trim(), 'password': passwordController.text.trim(),
} }

View File

@@ -45,17 +45,17 @@ class MobileCheckout extends StatefulWidget {
} }
class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
CartInfo cartInfo; late CartInfo cartInfo;
Address shipAddress; late Address shipAddress;
bool canSubmit; late bool canSubmit;
List<ErrorMessage> errorMessages; late List<ErrorMessage> errorMessages;
List<BookingTime> bookingTimeList; late List<BookingTime> bookingTimeList;
List<BookingDateTime> bookingDateTimeList; late List<BookingDateTime> bookingDateTimeList;
List<PaymentPlatform> paymentPlatforms; late List<PaymentPlatform> paymentPlatforms;
TextValue durationInTraffic; late TextValue durationInTraffic;
int selectedCoupon; late int selectedCoupon;
double couponDiscountAmount = 0; double couponDiscountAmount = 0;
List<Coupon> coupons; late List<Coupon> coupons;
int peopleCount = 2; int peopleCount = 2;
@@ -63,25 +63,25 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
String orderRemark = ''; String orderRemark = '';
int deliveryMethodIndex = 0; int deliveryMethodIndex = 0;
String deliveryMethod; late String deliveryMethod;
List<ShippingRate> shippingRates = []; List<ShippingRate> shippingRates = [];
ShippingRate selectedShippingRate; late ShippingRate selectedShippingRate;
List<String> shippingMethodLabels = []; List<String> shippingMethodLabels = [];
List<IconData> shippingMethodIcons = []; List<IconData> shippingMethodIcons = [];
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
int bookingDateIndex; late int bookingDateIndex;
int bookingTimeIndex; late int bookingTimeIndex;
int paymentPlatformIndex; late int paymentPlatformIndex;
GlobalKey slidingUpPanelKey = GlobalKey(); GlobalKey slidingUpPanelKey = GlobalKey();
SlidingUpPanel slidingUpPanel; late SlidingUpPanel slidingUpPanel;
PanelController panelController = PanelController(); PanelController panelController = PanelController();
Widget panel; late Widget panel;
double subtotal; late double subtotal;
TextEditingController newCouponController = TextEditingController(); TextEditingController newCouponController = TextEditingController();
@@ -102,7 +102,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
); );
} }
if (cartInfo.businessInfo.deliveryPickup == false && cartInfo.businessInfo.deliveryCanadaPost == false && cartInfo.businessInfo.deliveryStoreDelivery == false) { if (cartInfo.businessInfo!.deliveryPickup == false && cartInfo.businessInfo!.deliveryCanadaPost == false && cartInfo.businessInfo!.deliveryStoreDelivery == false) {
return Scaffold( return Scaffold(
body: Container( body: Container(
child: Center( child: Center(
@@ -197,13 +197,13 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
'\$${(cartInfo.totalPrice - couponDiscountAmount).toStringAsFixed(2)}', '\$${(cartInfo.totalPrice! - couponDiscountAmount).toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 20.0, fontSize: 20.0,
color: Colors.white, color: Colors.white,
), ),
), ),
cartInfo.businessInfo.isPublic ? SizedBox.shrink() : Container( cartInfo.businessInfo!.isPublic ? 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);
print('aaa: $deliveryTimeInSeconds'); print('aaa: $deliveryTimeInSeconds');
DateTime now = DateTime.now(); DateTime now = DateTime.now();
var formatter = DateFormat('H:mm'); var formatter = DateFormat('H:mm');
@@ -341,7 +341,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
); );
switch (position) { switch (position) {
case 0: case 0:
if (cartInfo.businessInfo.deliveryPickup) { if (cartInfo.businessInfo!.deliveryPickup) {
return Container( return Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 16.0, bottom: 16.0, left: 16.0, right: 16.0), top: 16.0, bottom: 16.0, left: 16.0, right: 16.0),
@@ -355,8 +355,8 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
), ),
child: Container( child: Container(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: store.state.deviceId != null && store.state.deviceId.isNotEmpty ? ( child: store.state.deviceId != null && store.state.deviceId!.isNotEmpty ? (
store.state.tableNumber != null && store.state.tableNumber.isNotEmpty ? store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty ?
peopleCountSelection : peopleCountSelection :
SizedBox.shrink() SizedBox.shrink()
) : Center(child: toggleSwitch,), ) : Center(child: toggleSwitch,),
@@ -369,8 +369,8 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
} }
break; break;
case 1: case 1:
if (store.state.deviceId != null && store.state.deviceId.isNotEmpty || if (store.state.deviceId != null && store.state.deviceId!.isNotEmpty ||
store.state.tableNumber != null && store.state.tableNumber.isNotEmpty) { store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty) {
return SizedBox.shrink(); return SizedBox.shrink();
} }
if (deliveryMethod == 'pickup') { if (deliveryMethod == 'pickup') {
@@ -389,7 +389,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
Container( Container(
margin: EdgeInsets.only(top: 10.0), margin: EdgeInsets.only(top: 10.0),
child: Text( child: Text(
cartInfo.businessInfo.name, cartInfo.businessInfo!.name,
style: TextStyle( style: TextStyle(
fontSize: 17.0, fontSize: 17.0,
), ),
@@ -398,7 +398,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
Container( Container(
margin: EdgeInsets.only(top: 5.0), margin: EdgeInsets.only(top: 5.0),
child: Text( child: Text(
cartInfo.businessInfo.address.addressLine1, cartInfo.businessInfo!.address!.addressLine1,
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
color: Colors.black45, color: Colors.black45,
@@ -406,9 +406,9 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
), ),
), ),
Container( Container(
child: cartInfo.businessInfo.address.addressLine2 != null child: cartInfo.businessInfo!.address!.addressLine2 != null
&& cartInfo.businessInfo.address.addressLine2.length > 0 ? && cartInfo.businessInfo!.address!.addressLine2!.length > 0 ?
Text(cartInfo.businessInfo.address.addressLine2, Text(cartInfo.businessInfo!.address!.addressLine2,
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
color: Colors.black45, color: Colors.black45,
@@ -417,7 +417,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
), ),
Container( Container(
child: Text( child: Text(
'${cartInfo.businessInfo.address.city}, ${cartInfo.businessInfo.address.state}, ${cartInfo.businessInfo.address.zip}', '${cartInfo.businessInfo!.address!.city}, ${cartInfo.businessInfo!.address!.state}, ${cartInfo.businessInfo!.address!.zip}',
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
color: Colors.black45, color: Colors.black45,
@@ -427,7 +427,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
Container( Container(
margin: EdgeInsets.only(top: 5.0), margin: EdgeInsets.only(top: 5.0),
child: Text( child: Text(
'Tel: ${cartInfo.businessInfo.phone}', 'Tel: ${cartInfo.businessInfo!.phone}',
style: TextStyle( style: TextStyle(
fontSize: 15.0, fontSize: 15.0,
color: Colors.black54, color: Colors.black54,
@@ -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,
@@ -504,13 +504,13 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
), ),
), ),
onTap: () { onTap: () {
Routes.router.navigateTo(context, '/my-addresses/${cartInfo.businessInfo.id}', replace: true); Routes.router.navigateTo(context, '/my-addresses/${cartInfo.businessInfo!.id}', replace: true);
}, },
); );
break; break;
case 2: case 2:
if (deliveryMethod == 'pickup' || store.state.deviceId != null && store.state.deviceId.isNotEmpty || if (deliveryMethod == 'pickup' || store.state.deviceId != null && store.state.deviceId!.isNotEmpty ||
store.state.tableNumber != null && store.state.tableNumber.isNotEmpty) { store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty) {
return SizedBox.shrink(); return SizedBox.shrink();
} }
if (deliveryMethod == 'canada-post') { if (deliveryMethod == 'canada-post') {
@@ -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,
@@ -583,7 +583,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
}, },
); );
} }
if (!cartInfo.businessInfo.instanceDelivery) { if (!cartInfo.businessInfo!.instanceDelivery) {
return Container( return Container(
padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 0.0, bottom: 16.0), padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 0.0, bottom: 16.0),
child: Text(S.of(context).no_instance_delivery_desc), child: Text(S.of(context).no_instance_delivery_desc),
@@ -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(
@@ -712,7 +712,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
width: double.infinity, width: double.infinity,
padding: EdgeInsets.only(bottom: 10.0), padding: EdgeInsets.only(bottom: 10.0),
child: Text( child: Text(
cartInfo.businessInfo.name, cartInfo.businessInfo!.name,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontSize: 16.0, fontSize: 16.0,
@@ -731,9 +731,9 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
subtotal = 0.0; subtotal = 0.0;
for (var i = 0; i < cartInfo.productList.length; i++) { for (var i = 0; i < cartInfo.productList!.length; i++) {
subtotal += cartInfo.productList[i].totalPrice; subtotal += cartInfo.productList![i].totalPrice;
column.children.add(lineItem(cartInfo.productList[i])); column.children.add(lineItem(cartInfo.productList![i]));
} }
column.children.add(GestureDetector( column.children.add(GestureDetector(
child: Container( child: Container(
@@ -826,8 +826,8 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
), ),
)); ));
if (cartInfo.extraFeeList.length > 0) { if (cartInfo.extraFeeList!.length > 0) {
for (var i = 0; i < cartInfo.extraFeeList.length; i++) { for (var i = 0; i < cartInfo.extraFeeList!.length; i++) {
column.children.add(Container( column.children.add(Container(
padding: EdgeInsets.only(bottom: 16.0), padding: EdgeInsets.only(bottom: 16.0),
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
@@ -838,7 +838,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
Container( Container(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
S.of(context).extra_fee_token(cartInfo.extraFeeList[i].name, cartInfo.extraFeeList[i].rate), S.of(context).extra_fee_token(cartInfo.extraFeeList![i].name, cartInfo.extraFeeList![i].rate),
style: TextStyle( style: TextStyle(
color: Colors.grey, color: Colors.grey,
), ),
@@ -848,7 +848,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
width: 100.0, width: 100.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${cartInfo.extraFeeList[i].price.toStringAsFixed(2)}' '${cartInfo.extraFeeList![i].price!.toStringAsFixed(2)}'
), ),
), ),
], ],
@@ -876,7 +876,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
width: 100.0, width: 100.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${(cartInfo.totalPrice - couponDiscountAmount).toStringAsFixed(2)}', '${(cartInfo.totalPrice! - couponDiscountAmount).toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 19.0, fontSize: 19.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -974,7 +974,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
children: <Widget>[ children: <Widget>[
Container( Container(
padding: EdgeInsets.all(5.0), padding: EdgeInsets.all(5.0),
child: Util.showImage('${cartLineItem.product.imagePath}', child: Util.showImage('${cartLineItem.product!.imagePath}',
width: 40.0, width: 40.0,
height: 40.0, height: 40.0,
fit: BoxFit.fill, fit: BoxFit.fill,
@@ -1011,14 +1011,14 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
margin: EdgeInsets.only(right: 10.0), margin: EdgeInsets.only(right: 10.0),
child: Text( child: Text(
'x${cartLineItem.quantity.round()}', 'x${cartLineItem.quantity!.round()}',
), ),
), ),
Container( Container(
width: 60.0, width: 60.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${cartLineItem.totalPrice.toStringAsFixed(2)}', '${cartLineItem.totalPrice!.toStringAsFixed(2)}',
), ),
), ),
], ],
@@ -1074,7 +1074,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
shippingRates = (response.data['shipping_rates'] as List).map((e) => ShippingRate.fromJson(e)).toList(); shippingRates = (response.data['shipping_rates'] as List).map((e) => ShippingRate.fromJson(e)).toList();
selectedShippingRate = (response.data['selected_shipping_rate'] as String).length > 0 ? ShippingRate.fromJson(json.decode(response.data['selected_shipping_rate'])) : null; selectedShippingRate = (response.data['selected_shipping_rate'] as String).length > 0 ? ShippingRate.fromJson(json.decode(response.data['selected_shipping_rate'])) : null;
int i = 0; int i = 0;
if (cartInfo.businessInfo.deliveryStoreDelivery) { if (cartInfo.businessInfo!.deliveryStoreDelivery) {
shippingMethodLabels.add(S.of(context).delivery); shippingMethodLabels.add(S.of(context).delivery);
shippingMethodIcons.add(Icons.directions_car); shippingMethodIcons.add(Icons.directions_car);
if (deliveryMethod == 'store-delivery') { if (deliveryMethod == 'store-delivery') {
@@ -1082,7 +1082,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
} }
i++; i++;
} }
if (cartInfo.businessInfo.deliveryCanadaPost) { if (cartInfo.businessInfo!.deliveryCanadaPost) {
shippingMethodLabels.add(S.of(context).canada_post); shippingMethodLabels.add(S.of(context).canada_post);
shippingMethodIcons.add(Icons.local_shipping); shippingMethodIcons.add(Icons.local_shipping);
if (deliveryMethod == 'canada-post') { if (deliveryMethod == 'canada-post') {
@@ -1090,7 +1090,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
} }
i++; i++;
} }
if (cartInfo.businessInfo.deliveryPickup) { if (cartInfo.businessInfo!.deliveryPickup) {
shippingMethodLabels.add(S.of(context).pickup); shippingMethodLabels.add(S.of(context).pickup);
shippingMethodIcons.add(Icons.store); shippingMethodIcons.add(Icons.store);
if (deliveryMethod == 'pickup') { if (deliveryMethod == 'pickup') {
@@ -1310,14 +1310,14 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
Expanded( Expanded(
child: SizedBox.expand( child: SizedBox.expand(
child: ListView.builder( child: ListView.builder(
itemCount: bookingDateTimeList[bookingDateIndex].bookTimes.length, itemCount: bookingDateTimeList[bookingDateIndex].bookTimes!.length,
itemBuilder: (BuildContext context, int position) { itemBuilder: (BuildContext context, int position) {
BookingDateTime bookingDateTime = bookingDateTimeList[bookingDateIndex]; BookingDateTime bookingDateTime = bookingDateTimeList[bookingDateIndex];
return GestureDetector( return GestureDetector(
child: Container( child: Container(
padding: EdgeInsets.only(left: 12.0, right: 12.0, top: 12.0, bottom: 12.0), padding: EdgeInsets.only(left: 12.0, right: 12.0, top: 12.0, bottom: 12.0),
child: Text( child: Text(
bookingDateTime.bookTimes[position].viewTime, bookingDateTime.bookTimes![position].viewTime,
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border( border: Border(
@@ -1442,16 +1442,16 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
itemBuilder: (BuildContext context, int position) { itemBuilder: (BuildContext context, int position) {
PaymentPlatform paymentPlatform = paymentPlatforms[position]; PaymentPlatform paymentPlatform = paymentPlatforms[position];
if (paymentPlatform.code == Constants.PAYMENT_METHOD_CODE_SQUARE && if (paymentPlatform.code == Constants.PAYMENT_METHOD_CODE_SQUARE &&
(paymentPlatform.squareAppId == null || paymentPlatform.squareAppId.isEmpty) && (paymentPlatform.squareAppId == null || paymentPlatform.squareAppId!.isEmpty) &&
(paymentPlatform.squareAccessToken == null || paymentPlatform.squareAccessToken.isEmpty) && (paymentPlatform.squareAccessToken == null || paymentPlatform.squareAccessToken!.isEmpty) &&
(paymentPlatform.squareLocationId == null || paymentPlatform.squareLocationId.isEmpty) (paymentPlatform.squareLocationId == null || paymentPlatform.squareLocationId!.isEmpty)
) { ) {
return SizedBox.shrink(); return SizedBox.shrink();
} }
if (paymentPlatform.code == Constants.PAYMENT_METHOD_CODE_CHASE && if (paymentPlatform.code == Constants.PAYMENT_METHOD_CODE_CHASE &&
(paymentPlatform.xLogin == null || paymentPlatform.xLogin.isEmpty) && (paymentPlatform.xLogin == null || paymentPlatform.xLogin!.isEmpty) &&
(paymentPlatform.transactionKey == null || paymentPlatform.transactionKey.isEmpty) && (paymentPlatform.transactionKey == null || paymentPlatform.transactionKey!.isEmpty) &&
(paymentPlatform.responseKey == null || paymentPlatform.responseKey.isEmpty) (paymentPlatform.responseKey == null || paymentPlatform.responseKey!.isEmpty)
) { ) {
return SizedBox.shrink(); return SizedBox.shrink();
} }
@@ -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(
@@ -1857,7 +1857,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
), ),
Container( Container(
child: Text( child: Text(
coupon.minAmount > 0 ? coupon.minAmount! > 0 ?
S.of(context).min_order_amount_token( S.of(context).min_order_amount_token(
coupon.minAmount) : coupon.minAmount) :
S.of(context) S.of(context)
@@ -1917,7 +1917,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [], children: [],
); );
if (cartInfo.businessInfo.quickInputs.length > 0) { if (cartInfo.businessInfo!.quickInputs!.length > 0) {
Wrap w = Wrap( Wrap w = Wrap(
children: [], children: [],
); );
@@ -1931,8 +1931,8 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
), ),
), ),
)); ));
for (int i = 0; i < cartInfo.businessInfo.quickInputs.length; i++) { for (int i = 0; i < cartInfo.businessInfo!.quickInputs!.length; i++) {
String qi = cartInfo.businessInfo.quickInputs[i].value; String qi = cartInfo.businessInfo!.quickInputs![i].value;
w.children.add(TextButton( w.children.add(TextButton(
child: Text( child: Text(
qi, qi,
@@ -2112,7 +2112,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
child: Container( child: Container(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${shippingRate.price.toStringAsFixed(2)}', '${shippingRate.price!.toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 16.0, fontSize: 16.0,
color: Colors.black38, color: Colors.black38,
@@ -2203,7 +2203,7 @@ class MobileCheckoutState extends State<MobileCheckout> with SingleTickerProvide
: ( : (
(bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ? (bookingTimeList.length == 0 && bookingDateTimeList.length == 0) ?
0 : 0 :
bookingDateTimeList[bookingDateIndex].bookTimes[bookingTimeIndex] bookingDateTimeList[bookingDateIndex].bookTimes![bookingTimeIndex]
.unixTime .unixTime
), ),
'delivery': deliveryMethod, 'delivery': deliveryMethod,

View File

@@ -29,7 +29,7 @@ class MobileContactUsState extends State<MobileContactUs> {
String mapUrl = 'https://goo.gl/maps/M365MF5AW35n9ij67'; String mapUrl = 'https://goo.gl/maps/M365MF5AW35n9ij67';
Completer<GoogleMapController> _controller = Completer(); Completer<GoogleMapController> _controller = Completer();
LatLng _lastMapPosition; late LatLng _lastMapPosition;
final Set<Marker> _markers = {}; final Set<Marker> _markers = {};
final Set<Polyline> _polyLine = {}; final Set<Polyline> _polyLine = {};
@@ -239,16 +239,16 @@ class MobileContactUsState extends State<MobileContactUs> {
Container( Container(
padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4),
child: Text( child: Text(
'${widget.business.address.addressLine1}', '${widget.business.address!.addressLine1}',
), ),
) )
); );
if (widget.business.address.addressLine2 != null && widget.business.address.addressLine2.isNotEmpty) { if (widget.business.address!.addressLine2 != null && widget.business.address!.addressLine2!.isNotEmpty) {
col.children.add( col.children.add(
Container( Container(
padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4),
child: Text( child: Text(
'${widget.business.address.addressLine2}', '${widget.business.address!.addressLine2}',
), ),
) )
); );
@@ -257,7 +257,7 @@ class MobileContactUsState extends State<MobileContactUs> {
Container( Container(
padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4),
child: Text( child: Text(
'${widget.business.address.city}, ${widget.business.address.state}', '${widget.business.address!.city}, ${widget.business.address!.state}',
), ),
) )
); );
@@ -265,7 +265,7 @@ class MobileContactUsState extends State<MobileContactUs> {
Container( Container(
padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4), padding: EdgeInsets.only(left: 16, right: 16, top: 4, bottom: 4),
child: Text( child: Text(
'${widget.business.address.country}, ${widget.business.address.zip}', '${widget.business.address!.country}, ${widget.business.address!.zip}',
), ),
) )
); );
@@ -273,8 +273,8 @@ class MobileContactUsState extends State<MobileContactUs> {
_markers.clear(); _markers.clear();
_markers.add(Marker( _markers.add(Marker(
markerId: MarkerId('shop_position'), markerId: MarkerId('shop_position'),
position: LatLng(double.parse(widget.business.address.lat), position: LatLng(double.parse(widget.business.address!.lat),
double.parse(widget.business.address.lng)), double.parse(widget.business.address!.lng)),
infoWindow: InfoWindow( infoWindow: InfoWindow(
title: S title: S
.of(context) .of(context)
@@ -290,8 +290,8 @@ class MobileContactUsState extends State<MobileContactUs> {
onMapCreated: _onMapCreated, onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition( initialCameraPosition: CameraPosition(
target: LatLng( target: LatLng(
double.parse(widget.business.address.lat), double.parse(widget.business.address!.lat),
double.parse(widget.business.address.lng)), double.parse(widget.business.address!.lng)),
zoom: 14.0, zoom: 14.0,
), ),
onCameraMove: _onCameraMove, onCameraMove: _onCameraMove,

View File

@@ -24,7 +24,7 @@ class MobileCoupons extends StatefulWidget {
} }
class MobileCouponsState extends State<MobileCoupons> { class MobileCouponsState extends State<MobileCoupons> {
List<Coupon> coupons; late List<Coupon> coupons;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -97,7 +97,7 @@ class MobileCouponsState extends State<MobileCoupons> {
Container( Container(
padding: EdgeInsets.only(right: 5.0), padding: EdgeInsets.only(right: 5.0),
child: coupon.store != null ? child: coupon.store != null ?
Util.showImage('${coupon.store.picUrl}', Util.showImage('${coupon.store!.picUrl}',
fit: BoxFit.fill, fit: BoxFit.fill,
width: 40.0, width: 40.0,
) : ) :
@@ -114,7 +114,7 @@ class MobileCouponsState extends State<MobileCoupons> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( Text(
coupon.store != null ? coupon.store.name : S.of(context).general_coupon, coupon.store != null ? coupon.store!.name : S.of(context).general_coupon,
style: TextStyle( style: TextStyle(
fontSize: 20.0, fontSize: 20.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -198,7 +198,7 @@ class MobileCouponsState extends State<MobileCoupons> {
), ),
Container( Container(
child: Text( child: Text(
coupon.minAmount > 0 ? coupon.minAmount! > 0 ?
S.of(context).available_for_order_over_token(coupon.minAmount) : S.of(context).available_for_order_over_token(coupon.minAmount) :
S.of(context).no_restriction, S.of(context).no_restriction,
style: TextStyle( style: TextStyle(
@@ -236,7 +236,7 @@ class MobileCouponsState extends State<MobileCoupons> {
children: <Widget>[ children: <Widget>[
Container( Container(
child: Text( child: Text(
coupon.expirationDate == null || coupon.expirationDate.length == 0 ? coupon.expirationDate == null || coupon.expirationDate!.length == 0 ?
S.of(context).no_expiration : S.of(context).no_expiration :
S.of(context).expiration_date_token(coupon.expirationDate), S.of(context).expiration_date_token(coupon.expirationDate),
style: TextStyle( style: TextStyle(
@@ -261,7 +261,7 @@ class MobileCouponsState extends State<MobileCoupons> {
), ),
onPressed: () { onPressed: () {
if (coupon.store != null) { if (coupon.store != null) {
Routes.router.navigateTo(context, '/shop/${coupon.store.id}/na/na/na'); Routes.router.navigateTo(context, '/shop/${coupon.store!.id}/na/na/na');
} else { } else {
Routes.router.navigateTo(context, '/businesses'); Routes.router.navigateTo(context, '/businesses');
} }

View File

@@ -43,12 +43,12 @@ class MobileEditAddressState extends State<MobileEditAddress> {
final emailController = TextEditingController(); final emailController = TextEditingController();
final faxController = TextEditingController(); final faxController = TextEditingController();
String country; late String country;
Gender _selectedGender; late Gender _selectedGender;
String _selectedProvince; late String _selectedProvince;
bool showLoading; late bool showLoading;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -366,7 +366,7 @@ class MobileEditAddressState extends State<MobileEditAddress> {
.email, .email,
), ),
validator: (String? value) { validator: (String? value) {
if (value.isNotEmpty && !EmailValidator.validate(value)) { if (value!.isNotEmpty && !EmailValidator.validate(value)) {
return S return S
.of(context) .of(context)
.email_is_not_valid; .email_is_not_valid;

View File

@@ -28,9 +28,9 @@ class MobileForgotPasswordState extends State<MobileForgotPassword> {
bool usernameEnable = true; bool usernameEnable = true;
final codeController = TextEditingController(); final codeController = TextEditingController();
bool enableGetCode; late bool enableGetCode;
String getCodeText; late String getCodeText;
bool canRegister; late bool canRegister;
var countDownListener; var countDownListener;
@@ -91,7 +91,7 @@ class MobileForgotPasswordState extends State<MobileForgotPassword> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).mobile_or_email_is_required; return S.of(context).mobile_or_email_is_required;
} }
return null; return null;
@@ -174,7 +174,7 @@ class MobileForgotPasswordState extends State<MobileForgotPassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).verification_code_is_required; return S.of(context).verification_code_is_required;
} }
return null; return null;

View File

@@ -26,9 +26,9 @@ class MobileLoginState extends State<MobileLogin> {
final usernameController = TextEditingController(); final usernameController = TextEditingController();
final passwordController = TextEditingController(); final passwordController = TextEditingController();
bool passwordVisible; late bool passwordVisible;
bool onSubmitting; late bool onSubmitting;
@override @override
void initState() { void initState() {
@@ -104,7 +104,7 @@ class MobileLoginState extends State<MobileLogin> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).this_field_is_required; return S.of(context).this_field_is_required;
} }
return null; return null;
@@ -144,7 +144,7 @@ class MobileLoginState extends State<MobileLogin> {
), ),
obscureText: passwordVisible, obscureText: passwordVisible,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
return null; return null;

View File

@@ -20,9 +20,9 @@ import '../../utils/util_web.dart'
if (dart.library.io) '../../utils/util_io.dart'; if (dart.library.io) '../../utils/util_io.dart';
import '../../utils/utils.dart'; import '../../utils/utils.dart';
MediaQueryData mediaQuery; late MediaQueryData mediaQuery;
double statusBarHeight; late double statusBarHeight;
double screenHeight; late double screenHeight;
class MobileMe extends StatefulWidget { class MobileMe extends StatefulWidget {
final Key? key; final Key? key;
@@ -36,18 +36,18 @@ class MobileMe extends StatefulWidget {
} }
class MobileMeState extends State<MobileMe> { class MobileMeState extends State<MobileMe> {
int userId; late int userId;
String accessToken; late String accessToken;
bool isLoading; late bool isLoading;
User _user; late User _user;
ShopScrollCoordinator _shopCoordinator; late ShopScrollCoordinator _shopCoordinator;
ShopScrollController _pageScrollController; late ShopScrollController _pageScrollController;
final double _sliverAppBarInitHeight = 165.0; final double _sliverAppBarInitHeight = 165.0;
final double _appBarHeight = 85.0; final double _appBarHeight = 85.0;
ShopScrollController _listScrollController1; late ShopScrollController _listScrollController1;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -88,7 +88,7 @@ class MobileMeState extends State<MobileMe> {
children: <Widget>[ children: <Widget>[
Container( Container(
margin: EdgeInsets.only(right: 5.0), margin: EdgeInsets.only(right: 5.0),
child: _user != null && _user.avatarUrl.isNotEmpty child: _user != null && _user.avatarUrl!.isNotEmpty
? Util.showImage( ? Util.showImage(
'https:${_user.avatarUrl}', 'https:${_user.avatarUrl}',
width: 60, width: 60,
@@ -219,7 +219,7 @@ class MobileMeState extends State<MobileMe> {
Container( Container(
child: Text( child: Text(
_user != null _user != null
? '${_user.wallet.toStringAsFixed(2)}' ? '${_user.wallet!.toStringAsFixed(2)}'
: '0.00', : '0.00',
style: TextStyle( style: TextStyle(
fontSize: 24.0, fontSize: 24.0,
@@ -671,7 +671,7 @@ class MobileMeState extends State<MobileMe> {
), ),
onTap: () { onTap: () {
if (_user != null) { if (_user != null) {
if (_user.email == null || _user.email.isEmpty) { if (_user.email == null || _user.email!.isEmpty) {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {

View File

@@ -27,7 +27,7 @@ class MobileMyAddresses extends StatefulWidget {
} }
class MobileMyAddressesState extends State<MobileMyAddresses> { class MobileMyAddressesState extends State<MobileMyAddresses> {
List<Address> addresses; late List<Address> addresses;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@@ -28,7 +28,7 @@ class MobileMySupport extends StatefulWidget {
} }
class MobileMySupportState extends State<MobileMySupport> { class MobileMySupportState extends State<MobileMySupport> {
List<Ticket> tickets; late List<Ticket> tickets;
int _page = 1; int _page = 1;
int _pageCount = 1; int _pageCount = 1;
@@ -179,7 +179,7 @@ class MobileMySupportState extends State<MobileMySupport> {
children: <Widget>[ children: <Widget>[
Container( Container(
child: Text( child: Text(
ticket.issue.msg, ticket.issue!.msg,
style: TextStyle( style: TextStyle(
fontSize: 19.0, fontSize: 19.0,
), ),
@@ -208,7 +208,7 @@ class MobileMySupportState extends State<MobileMySupport> {
) : ) :
SizedBox.shrink(), SizedBox.shrink(),
Text( Text(
S.of(context).followups_token(ticket.followUps.length), S.of(context).followups_token(ticket.followUps!.length),
style: TextStyle( style: TextStyle(
fontSize: 15.0, fontSize: 15.0,
color: Colors.black87, color: Colors.black87,

View File

@@ -36,9 +36,9 @@ class MobileNewAddressState extends State<MobileNewAddress> {
final faxController = TextEditingController(); final faxController = TextEditingController();
String country = 'CA'; String country = 'CA';
Gender _selectedGender; late Gender _selectedGender;
String _selectedProvince; late String _selectedProvince;
List<String> provinces = <String>[ List<String> provinces = <String>[
'Ontario', 'Ontario',
@@ -97,7 +97,7 @@ class MobileNewAddressState extends State<MobileNewAddress> {
labelText: S.of(context).contact_name, labelText: S.of(context).contact_name,
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).contact_name_is_required; return S.of(context).contact_name_is_required;
} }
return null; return null;
@@ -141,7 +141,7 @@ class MobileNewAddressState extends State<MobileNewAddress> {
labelText: S.of(context).mobile_phone_number, labelText: S.of(context).mobile_phone_number,
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).mobile_phone_number_is_required; return S.of(context).mobile_phone_number_is_required;
} }
return null; return null;
@@ -166,7 +166,7 @@ class MobileNewAddressState extends State<MobileNewAddress> {
labelText: S.of(context).street_line_1, labelText: S.of(context).street_line_1,
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).street_line_1_is_required; return S.of(context).street_line_1_is_required;
} }
return null; return null;
@@ -210,7 +210,7 @@ class MobileNewAddressState extends State<MobileNewAddress> {
labelText: S.of(context).city, labelText: S.of(context).city,
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).city_is_required; return S.of(context).city_is_required;
} }
return null; return null;
@@ -256,7 +256,7 @@ class MobileNewAddressState extends State<MobileNewAddress> {
labelText: S.of(context).postal_code, labelText: S.of(context).postal_code,
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).postal_code_is_required; return S.of(context).postal_code_is_required;
} }
return null; return null;
@@ -291,7 +291,7 @@ class MobileNewAddressState extends State<MobileNewAddress> {
labelText: S.of(context).email, labelText: S.of(context).email,
), ),
validator: (String? value) { validator: (String? value) {
if (value.isNotEmpty && !EmailValidator.validate(value)) { if (value!.isNotEmpty && !EmailValidator.validate(value)) {
return S.of(context).email_is_not_valid; return S.of(context).email_is_not_valid;
} }
return null; return null;
@@ -354,8 +354,8 @@ class MobileNewAddressState extends State<MobileNewAddress> {
cityController.text = widget.locatedAddress.city; cityController.text = widget.locatedAddress.city;
postalCodeController.text = widget.locatedAddress.postalCode; postalCodeController.text = widget.locatedAddress.postalCode;
streetLine1Controller.text = (widget.locatedAddress.streetNumber != null streetLine1Controller.text = (widget.locatedAddress.streetNumber != null
&& widget.locatedAddress.streetNumber.isNotEmpty && widget.locatedAddress.streetNumber!.isNotEmpty
? widget.locatedAddress.streetNumber + ' ' : '') ? widget.locatedAddress.streetNumber! + ' ' : '')
+ widget.locatedAddress.streetName; + widget.locatedAddress.streetName;
} else { } else {
_selectedProvince = 'Ontario'; _selectedProvince = 'Ontario';

View File

@@ -31,13 +31,13 @@ class MobileNewComment extends StatefulWidget {
} }
class MobileNewCommentState extends State<MobileNewComment> { class MobileNewCommentState extends State<MobileNewComment> {
Comment comment; late Comment comment;
bool _showProgress; late bool _showProgress;
double _progress; late double _progress;
double rating; late double rating;
bool isSubmitting = false; bool isSubmitting = false;
@@ -167,7 +167,7 @@ class MobileNewCommentState extends State<MobileNewComment> {
children: <Widget>[], children: <Widget>[],
); );
if (comment != null && comment.images.length > 0) { if (comment != null && comment.images!.length > 0) {
for (ProductImage image in comment.images) { for (ProductImage image in comment.images) {
row.children.add( row.children.add(
Container( Container(
@@ -239,7 +239,7 @@ class MobileNewCommentState extends State<MobileNewComment> {
child: Icon( child: Icon(
Icons.add, Icons.add,
size: 60.0, size: 60.0,
color: comment == null || comment.images.length < 3 ? Colors.lightBlue : Colors.black12, color: comment == null || comment.images!.length < 3 ? Colors.lightBlue : Colors.black12,
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white70, color: Colors.white70,
@@ -264,7 +264,7 @@ class MobileNewCommentState extends State<MobileNewComment> {
), ),
), ),
onTap: () { onTap: () {
if (comment == null || comment.images.length < 3) { if (comment == null || comment.images!.length < 3) {
showDialog( showDialog(
context: mainContext, context: mainContext,
barrierDismissible: true, barrierDismissible: true,

View File

@@ -111,7 +111,7 @@ class MobileNewTicketState extends State<MobileNewTicket> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).this_field_is_required; return S.of(context).this_field_is_required;
} }
return null; return null;

View File

@@ -28,9 +28,9 @@ class MobileNewUserState extends State<MobileNewUser> {
bool usernameEnable = true; bool usernameEnable = true;
final codeController = TextEditingController(); final codeController = TextEditingController();
bool enableGetCode; late bool enableGetCode;
String getCodeText; late String getCodeText;
bool canRegister; late bool canRegister;
var countDownListener; var countDownListener;
@@ -88,7 +88,7 @@ class MobileNewUserState extends State<MobileNewUser> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).mobile_or_email_is_required; return S.of(context).mobile_or_email_is_required;
} }
return null; return null;
@@ -171,7 +171,7 @@ class MobileNewUserState extends State<MobileNewUser> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).verification_code_is_required; return S.of(context).verification_code_is_required;
} }
return null; return null;

View File

@@ -37,18 +37,18 @@ class MobileOrderDetail extends StatefulWidget {
} }
class MobileOrderDetailState extends State<MobileOrderDetail> { class MobileOrderDetailState extends State<MobileOrderDetail> {
Order order; late Order order;
LatLng _lastMapPosition; late LatLng _lastMapPosition;
LatLng customerLatLng; late LatLng customerLatLng;
LatLng deliveryLatLng; late LatLng deliveryLatLng;
LatLng storeLatLng; late LatLng storeLatLng;
final Set<Marker> _markers = {}; final Set<Marker> _markers = {};
final Set<Polyline> _polyLine = {}; final Set<Polyline> _polyLine = {};
BitmapDescriptor homeIcon; late BitmapDescriptor homeIcon;
BitmapDescriptor deliveryIcon; late BitmapDescriptor deliveryIcon;
BitmapDescriptor shopIcon; late BitmapDescriptor shopIcon;
Completer<GoogleMapController> _controller = Completer(); Completer<GoogleMapController> _controller = Completer();
@@ -123,7 +123,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
width: double.infinity, width: double.infinity,
padding: EdgeInsets.only(top: 0.0, bottom: 16.0), padding: EdgeInsets.only(top: 0.0, bottom: 16.0),
child: Text( child: Text(
order.cartInfo.businessInfo.name, order.cartInfo!.businessInfo!.name,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
@@ -154,7 +154,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
Icons.phone, Icons.phone,
), ),
onTap: () { onTap: () {
Utils.launchURL('tel:${order.businessInfo.phone}'); Utils.launchURL('tel:${order.businessInfo!.phone}');
}, },
), ),
), ),
@@ -170,8 +170,8 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
onMapCreated: _onMapCreated, onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition( initialCameraPosition: CameraPosition(
target: LatLng( target: LatLng(
double.parse(order.shippingAddress.lat), double.parse(order.shippingAddress!.lat),
double.parse(order.shippingAddress.lng)), double.parse(order.shippingAddress!.lng)),
zoom: 11.0, zoom: 11.0,
), ),
onCameraMove: _onCameraMove, onCameraMove: _onCameraMove,
@@ -182,14 +182,14 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
].toSet(), ].toSet(),
), ),
)); ));
if (order.deliveryDistance != null && order.deliveryDistance.distance != null) { if (order.deliveryDistance != null && order.deliveryDistance!.distance != null) {
col.children.add(Container( col.children.add(Container(
padding: EdgeInsets.only(top: 6.0, bottom: 6.0), padding: EdgeInsets.only(top: 6.0, bottom: 6.0),
margin: EdgeInsets.only(bottom: 6.0), margin: EdgeInsets.only(bottom: 6.0),
child: Text( child: Text(
S.of(context).delivery_distance_token( S.of(context).delivery_distance_token(
order.deliveryDistance.distance.text, order.deliveryDistance!.distance!.text,
order.deliveryDistance.duration.text order.deliveryDistance!.duration!.text
), ),
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -205,7 +205,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
} }
} }
for (CartLineItem lineItem in order.cartInfo.productList) { for (CartLineItem lineItem in order.cartInfo!.productList) {
col.children.add(Container( col.children.add(Container(
padding: EdgeInsets.only(top: 16.0, bottom: 0.0), padding: EdgeInsets.only(top: 16.0, bottom: 0.0),
@@ -213,7 +213,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Util.showImage('${lineItem.product.imagePath}', Util.showImage('${lineItem.product!.imagePath}',
width: 40.0, width: 40.0,
height: 40.0, height: 40.0,
fit: BoxFit.fill, fit: BoxFit.fill,
@@ -251,7 +251,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
width: 30.0, width: 30.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'x${lineItem.quantity.round()}', 'x${lineItem.quantity!.round()}',
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
), ),
@@ -313,8 +313,8 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
], ],
), ),
); );
for (var i = 0; i < order.cartInfo.extraFeeList.length; i++) { for (var i = 0; i < order.cartInfo!.extraFeeList!.length; i++) {
ExtraFee extraFee = order.cartInfo.extraFeeList[i]; ExtraFee extraFee = order.cartInfo!.extraFeeList![i];
col.children.add( col.children.add(
Row( Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
@@ -338,7 +338,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
width: 100.0, width: 100.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${extraFee.price.toStringAsFixed(2)}', '${extraFee.price!.toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 15.0, fontSize: 15.0,
), ),
@@ -371,7 +371,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
width: 100.0, width: 100.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${order.totalPrice.toStringAsFixed(2)}', '${order.totalPrice!.toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 18.0, fontSize: 18.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -481,7 +481,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
margin: EdgeInsets.only(top: 10.0, bottom: 10.0), margin: EdgeInsets.only(top: 10.0, bottom: 10.0),
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'${order.cartInfo.businessInfo.fullAddress}', '${order.cartInfo!.businessInfo!.fullAddress}',
style: TextStyle( style: TextStyle(
color: Colors.black38, color: Colors.black38,
), ),
@@ -908,19 +908,19 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Container( Container(
child: fulfillment.shippingMethod.isNotEmpty && fulfillment.trackingNumber != null && fulfillment.trackingNumber.isNotEmpty ? child: fulfillment.shippingMethod!.isNotEmpty && fulfillment.trackingNumber != null && fulfillment.trackingNumber!.isNotEmpty ?
Text( Text(
'${fulfillment.shippingMethod} ${fulfillment.trackingNumber}', '${fulfillment.shippingMethod} ${fulfillment.trackingNumber}',
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
maxLines: 1, maxLines: 1,
) : (fulfillment.shippingMethod.isNotEmpty ? Text( ) : (fulfillment.shippingMethod!.isNotEmpty ? Text(
'${fulfillment.shippingMethod}', '${fulfillment.shippingMethod}',
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
maxLines: 1, maxLines: 1,
) : SizedBox.shrink()), ) : SizedBox.shrink()),
), ),
Container( Container(
child: fulfillment.note != null && fulfillment.note.isNotEmpty ? child: fulfillment.note != null && fulfillment.note!.isNotEmpty ?
Text( Text(
'${fulfillment.note}', '${fulfillment.note}',
style: TextStyle( style: TextStyle(
@@ -1060,12 +1060,12 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
if (!kIsWeb) { if (!kIsWeb) {
if (order.shippingMethod == 'store-delivery' && order.status != Constants.STATUS_COMPLETE && order.status != Constants.STATUS_CANCELLED) { if (order.shippingMethod == 'store-delivery' && order.status != Constants.STATUS_COMPLETE && order.status != Constants.STATUS_CANCELLED) {
storeLatLng = LatLng(double.parse(order.businessInfo.address.lat), storeLatLng = LatLng(double.parse(order.businessInfo!.address!.lat),
double.parse(order.businessInfo.address.lng)); double.parse(order.businessInfo!.address!.lng));
customerLatLng = LatLng(double.parse(order.shippingAddress.lat), customerLatLng = LatLng(double.parse(order.shippingAddress!.lat),
double.parse(order.shippingAddress.lng)); double.parse(order.shippingAddress!.lng));
deliveryLatLng = deliveryLatLng =
LatLng(order.shipperPosition.lat, order.shipperPosition.lng); LatLng(order.shipperPosition!.lat, order.shipperPosition!.lng);
_polyLine.clear(); _polyLine.clear();
_polyLine.add( _polyLine.add(
@@ -1078,7 +1078,7 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
], ],
width: 3, width: 3,
points: [ points: [
order.shipperPosition.lat != 0.0 ? deliveryLatLng : storeLatLng, order.shipperPosition!.lat != 0.0 ? deliveryLatLng : storeLatLng,
customerLatLng, customerLatLng,
] ]
) )
@@ -1103,12 +1103,12 @@ class MobileOrderDetailState extends State<MobileOrderDetail> {
title: S title: S
.of(context) .of(context)
.customer, .customer,
snippet: order.shippingAddress.addressLine1, snippet: order.shippingAddress!.addressLine1,
), ),
icon: homeIcon, icon: homeIcon,
)); ));
if (order.shipperPosition.lat != 0.0 && if (order.shipperPosition!.lat != 0.0 &&
order.shipperPosition.lng != 0.0) { order.shipperPosition!.lng != 0.0) {
_markers.add(Marker( _markers.add(Marker(
markerId: MarkerId('shipper_position'), markerId: MarkerId('shipper_position'),
position: deliveryLatLng, position: deliveryLatLng,

View File

@@ -152,7 +152,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
row.children.add(Expanded( row.children.add(Expanded(
child: Container( child: Container(
child: Text( child: Text(
order.cartInfo.productList[0].name, order.cartInfo!.productList![0].name,
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
), ),
@@ -161,7 +161,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
), ),
), ),
)); ));
if (order.cartInfo.productList.length > 1) { if (order.cartInfo!.productList!.length > 1) {
row.children.add(Container( row.children.add(Container(
child: Text( child: Text(
S.of(context).and_more_item_token(Utils.getProductLineInOrder(order.cartInfo)), S.of(context).and_more_item_token(Utils.getProductLineInOrder(order.cartInfo)),
@@ -176,7 +176,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
width: 80.0, width: 80.0,
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Text( child: Text(
'\$${order.totalPrice.toStringAsFixed(2)}', '\$${order.totalPrice!.toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 16.0, fontSize: 16.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -291,7 +291,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Container( Container(
child: Util.showImage('${order.cartInfo.businessInfo.picUrl}', child: Util.showImage('${order.cartInfo!.businessInfo!.picUrl}',
width: 32.0, width: 32.0,
height: 32.0, height: 32.0,
fit: BoxFit.fill, fit: BoxFit.fill,
@@ -307,7 +307,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
children: <Widget>[ children: <Widget>[
Container( Container(
child: Text( child: Text(
'${order.cartInfo.businessInfo.name}', '${order.cartInfo!.businessInfo!.name}',
style: TextStyle( style: TextStyle(
fontSize: 20.0, fontSize: 20.0,
), ),

View File

@@ -30,9 +30,9 @@ class MobilePayNow extends StatefulWidget {
} }
class MobilePayNowState extends State<MobilePayNow> { class MobilePayNowState extends State<MobilePayNow> {
Order order; late Order order;
List<PaymentPlatform> paymentPlatforms; late List<PaymentPlatform> paymentPlatforms;
User _user; late User _user;
@override @override
@@ -74,7 +74,7 @@ class MobilePayNowState extends State<MobilePayNow> {
), ),
), ),
Text( Text(
'\$${order.totalPrice.toStringAsFixed(2)}', '\$${order.totalPrice!.toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 24.0, fontSize: 24.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@@ -91,7 +91,7 @@ class MobilePayNowState extends State<MobilePayNow> {
) )
), ),
), ),
store.state.deviceId != null && store.state.deviceId.isNotEmpty || store.state.tableNumber != null && store.state.tableNumber.isNotEmpty ? store.state.deviceId != null && store.state.deviceId!.isNotEmpty || store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty ?
GestureDetector( GestureDetector(
child: Container( child: Container(
padding: EdgeInsets.only(top: 20.0, bottom: 20.0, left: 16.0, right: 16.0), padding: EdgeInsets.only(top: 20.0, bottom: 20.0, left: 16.0, right: 16.0),

View File

@@ -23,10 +23,10 @@ import '../../widgets/general/add_remove_button.dart';
import '../../widgets/general/carousel.dart'; import '../../widgets/general/carousel.dart';
import '../../widgets/general/show_price.dart'; import '../../widgets/general/show_price.dart';
MediaQueryData mediaQuery; late MediaQueryData mediaQuery;
double statusBarHeight; late double statusBarHeight;
double screenHeight; late double screenHeight;
double screenWidth; late double screenWidth;
class MobileProductDetailPage extends StatefulWidget { class MobileProductDetailPage extends StatefulWidget {
final Business business; final Business business;
@@ -44,18 +44,18 @@ class MobileProductDetailPage extends StatefulWidget {
class MobileProductDetailPageState extends State<MobileProductDetailPage> class MobileProductDetailPageState extends State<MobileProductDetailPage>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
ShopScrollCoordinator _shopCoordinator; late ShopScrollCoordinator _shopCoordinator;
ShopScrollController _pageScrollController; late ShopScrollController _pageScrollController;
TabController _tabController; late TabController _tabController;
double _sliverAppBarInitHeight; late double _sliverAppBarInitHeight;
double _sliverAppBarMaxHeight; late double _sliverAppBarMaxHeight;
final double _tabBarHeight = 50; final double _tabBarHeight = 50;
ProductDetail productDetail; late ProductDetail productDetail;
bool refresh; late bool refresh;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -204,7 +204,7 @@ class MobileProductDetailPageState extends State<MobileProductDetailPage>
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
(productDetail.subproducts.length > 0) ? (productDetail.subproducts!.length > 0) ?
subProducts(productDetail.subproducts) : subProducts(productDetail.subproducts) :
SizedBox.shrink(), SizedBox.shrink(),
Container( Container(
@@ -219,7 +219,7 @@ class MobileProductDetailPageState extends State<MobileProductDetailPage>
Container( Container(
padding: EdgeInsets.only(left: 10.0, right: 10.0), padding: EdgeInsets.only(left: 10.0, right: 10.0),
child: (productDetail.description2 != null && child: (productDetail.description2 != null &&
!productDetail.description2.isEmpty) !productDetail.description2!.isEmpty)
? Text( ? Text(
'${productDetail.description2}', '${productDetail.description2}',
style: TextStyle( style: TextStyle(
@@ -343,7 +343,7 @@ class MobileProductDetailPageState extends State<MobileProductDetailPage>
Container( Container(
padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 5.0), padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 5.0),
child: Util.showImage( child: Util.showImage(
'https:${subproduct.product.image}', 'https:${subproduct.product!.image}',
width: 48, width: 48,
height: 48, height: 48,
fit: BoxFit.contain, fit: BoxFit.contain,
@@ -363,7 +363,7 @@ class MobileProductDetailPageState extends State<MobileProductDetailPage>
child: Container( child: Container(
padding: EdgeInsets.only(left: 12, top: 5), padding: EdgeInsets.only(left: 12, top: 5),
child: Text( child: Text(
subproduct.product.name, subproduct.product!.name,
style: TextStyle( style: TextStyle(
fontSize: 15.0, fontSize: 15.0,
), ),
@@ -374,7 +374,7 @@ class MobileProductDetailPageState extends State<MobileProductDetailPage>
width: 80, width: 80,
padding: EdgeInsets.only(left: 12, top: 5, right: 12), padding: EdgeInsets.only(left: 12, top: 5, right: 12),
child: Text( child: Text(
'${subproduct.product.price.toStringAsFixed(2)}', '${subproduct.product!.price!.toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
fontSize: 13, fontSize: 13,
decoration: TextDecoration.lineThrough, decoration: TextDecoration.lineThrough,
@@ -386,7 +386,7 @@ class MobileProductDetailPageState extends State<MobileProductDetailPage>
width: 60, width: 60,
padding: EdgeInsets.only(left: 12, top: 5, right: 12), padding: EdgeInsets.only(left: 12, top: 5, right: 12),
child: Text( child: Text(
'x${subproduct.quantity.toStringAsFixed(0)}', 'x${subproduct.quantity!.toStringAsFixed(0)}',
style: TextStyle( style: TextStyle(
fontSize: 13, fontSize: 13,
), ),
@@ -398,7 +398,7 @@ class MobileProductDetailPageState extends State<MobileProductDetailPage>
Container( Container(
padding: EdgeInsets.only(left: 12, top: 12, right: 12), padding: EdgeInsets.only(left: 12, top: 12, right: 12),
child: Text( child: Text(
'${subproduct.product.description}', '${subproduct.product!.description}',
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
color: Colors.black45, color: Colors.black45,
@@ -419,9 +419,9 @@ class MobileProductDetailPageState extends State<MobileProductDetailPage>
var pages = <Widget>[]; var pages = <Widget>[];
List<String> images = []; List<String> images = [];
images.add(productDetail.image); images.add(productDetail.image);
for (var i = 0; i < productDetail.images.length; i++) { for (var i = 0; i < productDetail.images!.length; i++) {
// print('>>https:' + productDetail.images[i].image); // print('>>https:' + productDetail.images[i].image);
images.add(productDetail.images[i].image); images.add(productDetail.images![i].image);
} }
for (var i = 0; i < images.length; i++) { for (var i = 0; i < images.length; i++) {

View File

@@ -98,7 +98,7 @@ class MobileProductItemState extends State<MobileProductItem> {
new Container( new Container(
child: widget.business.showMonthlySold ? child: widget.business.showMonthlySold ?
Text( Text(
S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)),
style: new TextStyle( style: new TextStyle(
fontSize: 9.0 fontSize: 9.0
), ),

View File

@@ -97,7 +97,7 @@ class MobileRenewLicenseState extends State<MobileRenewLicense> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).please_enter_group_number; return S.of(context).please_enter_group_number;
} }
return null; return null;

View File

@@ -104,7 +104,7 @@ class MobileRenewMiniOfficeState extends State<MobileRenewMiniOffice> {
); );
} }
Widget buildLine(String name, String value, {double nameSize, double valueSize}) { Widget buildLine(String name, String value, {double? nameSize, double? valueSize}) {
Row row = Row( Row row = Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,

View File

@@ -27,10 +27,10 @@ class MobileResetPasswordState extends State<MobileResetPassword> {
final passwordController = TextEditingController(); final passwordController = TextEditingController();
final passwordAgainController = TextEditingController(); final passwordAgainController = TextEditingController();
bool passwordVisible; late bool passwordVisible;
bool passwordAgainVisible; late bool passwordAgainVisible;
bool canReset; late bool canReset;
@override @override
void initState() { void initState() {
@@ -105,7 +105,7 @@ class MobileResetPasswordState extends State<MobileResetPassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
return null; return null;
@@ -159,10 +159,10 @@ class MobileResetPasswordState extends State<MobileResetPassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
if (value.trim() != passwordController.text.trim()) { if (value!.trim() != passwordController.text.trim()) {
return S.of(context).password_is_not_match_password_again; return S.of(context).password_is_not_match_password_again;
} }
return null; return null;

View File

@@ -107,7 +107,7 @@ class MobileSearchPlaceState extends State<MobileSearchPlace> {
); );
if (result is DioError) { if (result is DioError) {
if (result.response != null) { if (result.response != null) {
throw RuntimeError(result.response.data['message']); throw RuntimeError(result.response!.data['message']);
} else { } else {
throw RuntimeError(result.message); throw RuntimeError(result.message);
} }

View File

@@ -28,10 +28,10 @@ class MobileSetPasswordState extends State<MobileSetPassword> {
final passwordController = TextEditingController(); final passwordController = TextEditingController();
final passwordAgainController = TextEditingController(); final passwordAgainController = TextEditingController();
bool passwordVisible; late bool passwordVisible;
bool passwordAgainVisible; late bool passwordAgainVisible;
bool canReset; late bool canReset;
@override @override
void initState() { void initState() {
@@ -106,7 +106,7 @@ class MobileSetPasswordState extends State<MobileSetPassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
return null; return null;
@@ -160,10 +160,10 @@ class MobileSetPasswordState extends State<MobileSetPassword> {
fontSize: 18.0 fontSize: 18.0
), ),
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).password_is_required; return S.of(context).password_is_required;
} }
if (value.trim() != passwordController.text.trim()) { if (value!.trim() != passwordController.text.trim()) {
return S.of(context).password_is_not_match_password_again; return S.of(context).password_is_not_match_password_again;
} }
return null; return null;

View File

@@ -105,7 +105,7 @@ class MobileStoreProductSearchState extends State<MobileStoreProductSearch> {
); );
if (result is DioError) { if (result is DioError) {
if (result.response != null) { if (result.response != null) {
throw RuntimeError(result.response.data); throw RuntimeError(result.response!.data);
} else { } else {
throw RuntimeError(result.message); throw RuntimeError(result.message);
} }

View File

@@ -27,10 +27,10 @@ class MobileUserProfile extends StatefulWidget {
} }
class MobileUserProfileState extends State<MobileUserProfile> { class MobileUserProfileState extends State<MobileUserProfile> {
User _user; late User _user;
bool _showProgress; late bool _showProgress;
double _progress; late double _progress;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -229,7 +229,7 @@ class MobileUserProfileState extends State<MobileUserProfile> {
), ),
Container( Container(
child: Text( child: Text(
_user.mobile != null && _user.mobile.isNotEmpty ? Utils.safePhoneNumber(_user.mobile) : S.of(context).not_binding, _user.mobile != null && _user.mobile!.isNotEmpty ? Utils.safePhoneNumber(_user.mobile) : S.of(context).not_binding,
style: TextStyle( style: TextStyle(
color: Colors.grey, color: Colors.grey,
), ),
@@ -282,7 +282,7 @@ class MobileUserProfileState extends State<MobileUserProfile> {
), ),
Container( Container(
child: Text( child: Text(
_user.email != null && _user.email.isNotEmpty ? Utils.safePhoneNumber(_user.email) : S.of(context).not_binding, _user.email != null && _user.email!.isNotEmpty ? Utils.safePhoneNumber(_user.email) : S.of(context).not_binding,
style: TextStyle( style: TextStyle(
color: Colors.grey, color: Colors.grey,
), ),
@@ -393,7 +393,7 @@ class MobileUserProfileState extends State<MobileUserProfile> {
), ),
autofocus: true, autofocus: true,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).nickname_is_required; return S.of(context).nickname_is_required;
} }
return null; return null;

View File

@@ -28,7 +28,7 @@ class MobileViewBlog extends StatefulWidget {
} }
class MobileViewBlogState extends State<MobileViewBlog> { class MobileViewBlogState extends State<MobileViewBlog> {
Blog blog; late Blog blog;
@override @override
void initState() { void initState() {

View File

@@ -34,7 +34,7 @@ class MobileViewTicket extends StatefulWidget {
class MobileViewTicketState extends State<MobileViewTicket> { class MobileViewTicketState extends State<MobileViewTicket> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
Ticket ticket; late Ticket ticket;
final issueMsgController = TextEditingController(); final issueMsgController = TextEditingController();
@@ -123,7 +123,7 @@ class MobileViewTicketState extends State<MobileViewTicket> {
width: double.maxFinite, width: double.maxFinite,
padding: EdgeInsets.only(top: 8.0, left: 16.0, right: 16.0, bottom: 24.0), padding: EdgeInsets.only(top: 8.0, left: 16.0, right: 16.0, bottom: 24.0),
child: Text( child: Text(
'${ticket.issue.msg}', '${ticket.issue!.msg}',
style: TextStyle( style: TextStyle(
color: Colors.black54, color: Colors.black54,
fontSize: 14.0, fontSize: 14.0,
@@ -141,7 +141,7 @@ class MobileViewTicketState extends State<MobileViewTicket> {
Container( Container(
width: double.maxFinite, width: double.maxFinite,
padding: EdgeInsets.only(top: 16.0, bottom: 16.0, left: 16.0, right: 16.0), padding: EdgeInsets.only(top: 16.0, bottom: 16.0, left: 16.0, right: 16.0),
child: showGalleryImages(mainContext, ticket.issue.files), child: showGalleryImages(mainContext, ticket.issue!.files),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border( border: Border(
bottom: BorderSide( bottom: BorderSide(
@@ -171,7 +171,7 @@ class MobileViewTicketState extends State<MobileViewTicket> {
], ],
); );
if (ticket.followUps.length > 0) { if (ticket.followUps!.length > 0) {
view.children.add( view.children.add(
Container( Container(
width: double.maxFinite, width: double.maxFinite,
@@ -185,8 +185,8 @@ class MobileViewTicketState extends State<MobileViewTicket> {
), ),
), ),
); );
for (int i = 0; i < ticket.followUps.length; i++) { for (int i = 0; i < ticket.followUps!.length; i++) {
FollowUp followUp = ticket.followUps[i]; FollowUp followUp = ticket.followUps![i];
view.children.add( view.children.add(
Container( Container(
width: double.maxFinite, width: double.maxFinite,
@@ -294,7 +294,7 @@ class MobileViewTicketState extends State<MobileViewTicket> {
), ),
autofocus: false, autofocus: false,
validator: (String? value) { validator: (String? value) {
if (value.trim().isEmpty) { if (value!.trim().isEmpty) {
return S.of(context).this_field_is_required; return S.of(context).this_field_is_required;
} }
return null; return null;
@@ -353,7 +353,7 @@ class MobileViewTicketState extends State<MobileViewTicket> {
), ),
); );
if (ticket.followUps.length > 0) { if (ticket.followUps!.length > 0) {
view.children.add( view.children.add(
Container( Container(
width: double.maxFinite, width: double.maxFinite,
@@ -393,7 +393,7 @@ class MobileViewTicketState extends State<MobileViewTicket> {
padding: EdgeInsets.only(left: 20.0, right: 20.0, top: 0.0, bottom: 30.0), padding: EdgeInsets.only(left: 20.0, right: 20.0, top: 0.0, bottom: 30.0),
child: TextLink( child: TextLink(
S.of(context).new_ticket, S.of(context).new_ticket,
'/new-ticket/${ticket.store.id}', '/new-ticket/${ticket.store!.id}',
), ),
), ),
); );
@@ -690,7 +690,7 @@ class MobileViewTicketState extends State<MobileViewTicket> {
child: Text(S.of(context).ok), child: Text(S.of(context).ok),
onPressed: () { onPressed: () {
Routes.router.navigateTo(context, Routes.router.navigateTo(context,
'/my-support/${ticket.store.id}', '/my-support/${ticket.store!.id}',
replace: true, replace: true,
); );
}, },

View File

@@ -64,7 +64,7 @@ class ProductItemState extends State<ProductItem> {
width: widget.imageWidth, width: widget.imageWidth,
height: widget.imageWidth, height: widget.imageWidth,
child: GestureDetector( child: GestureDetector(
child: onHover && widget.product.secondImagePath.isNotEmpty ? child: onHover && widget.product.secondImagePath!.isNotEmpty ?
Util.showImage('${widget.product.secondImagePath}', Util.showImage('${widget.product.secondImagePath}',
fit: BoxFit.fill, fit: BoxFit.fill,
) : ) :
@@ -127,7 +127,7 @@ class ProductItemState extends State<ProductItem> {
new Container( new Container(
child: widget.business.showMonthlySold ? child: widget.business.showMonthlySold ?
Text( Text(
S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)),
style: new TextStyle( style: new TextStyle(
fontSize: 9.0 fontSize: 9.0
), ),
@@ -157,7 +157,7 @@ class ProductItemState extends State<ProductItem> {
width: widget.imageWidth, width: widget.imageWidth,
height: widget.imageWidth, height: widget.imageWidth,
child: GestureDetector( child: GestureDetector(
child: onHover && widget.product.secondImagePath.isNotEmpty ? child: onHover && widget.product.secondImagePath!.isNotEmpty ?
Util.showImage('${widget.product.secondImagePath}', Util.showImage('${widget.product.secondImagePath}',
fit: BoxFit.fill, fit: BoxFit.fill,
) : ) :
@@ -212,7 +212,7 @@ class ProductItemState extends State<ProductItem> {
new Container( new Container(
child: widget.business.showMonthlySold ? child: widget.business.showMonthlySold ?
Text( Text(
S.of(context).sold_per_month_token(widget.product.monthSales.toStringAsFixed(0)), S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)),
style: new TextStyle( style: new TextStyle(
fontSize: 9.0 fontSize: 9.0
), ),

View File

@@ -113,7 +113,7 @@ class ProductSearchState extends State<ProductSearch> {
); );
if (result is DioError) { if (result is DioError) {
if (result.response != null) { if (result.response != null) {
throw RuntimeError(result.response.data); throw RuntimeError(result.response!.data);
} else { } else {
throw RuntimeError(result.message); throw RuntimeError(result.message);
} }

View File

@@ -37,10 +37,10 @@ import 'product_item.dart';
import 'product_search.dart'; import 'product_search.dart';
import 'shopping_cart_bar.dart'; import 'shopping_cart_bar.dart';
MediaQueryData mediaQuery; late MediaQueryData mediaQuery;
double statusBarHeight; late double statusBarHeight;
double screenWidth; late double screenWidth;
double screenHeight; late double screenHeight;
class Shop extends StatefulWidget { class Shop extends StatefulWidget {
final int businessId; final int businessId;
@@ -56,10 +56,10 @@ class ShopState extends State<Shop>
GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
Business _business; late Business _business;
List<CategoryProducts> _categoryProducts; late List<CategoryProducts> _categoryProducts;
List<Product> _featuredProducts; late List<Product> _featuredProducts;
List<Product> _hotSaleProducts; late List<Product> _hotSaleProducts;
List<dynamic> _prompts = []; List<dynamic> _prompts = [];
bool checkCloseFlag = false; bool checkCloseFlag = false;
@@ -79,22 +79,22 @@ class ShopState extends State<Shop>
bool refresh = false; bool refresh = false;
ShopScrollCoordinator _shopCoordinator; late ShopScrollCoordinator _shopCoordinator;
ShopScrollController _pageScrollController; late ShopScrollController _pageScrollController;
TabController _tabController; late TabController _tabController;
final double _sliverAppBarInitHeight = 150.0; final double _sliverAppBarInitHeight = 150.0;
final double _tabBarHeight = 50.0; final double _tabBarHeight = 50.0;
double _sliverAppBarMaxHeight; late double _sliverAppBarMaxHeight;
ShopScrollController _listScrollController1; late ShopScrollController _listScrollController1;
ShopScrollController _listScrollController2; late ShopScrollController _listScrollController2;
ShopScrollController _listScrollController3; late ShopScrollController _listScrollController3;
AnimationPointManager _animationPointManager = AnimationPointManager(); AnimationPointManager _animationPointManager = AnimationPointManager();
GlobalKey stackKey = GlobalKey(); GlobalKey stackKey = GlobalKey();
GlobalKey endKey = GlobalKey(); GlobalKey endKey = GlobalKey();
List<Comment> comments; late List<Comment> comments;
int _commentPage = 1; int _commentPage = 1;
int _commentPageCount = 1; int _commentPageCount = 1;
bool _commentLoadingFinish = false; bool _commentLoadingFinish = false;
@@ -102,13 +102,13 @@ class ShopState extends State<Shop>
RefreshController(initialRefresh: true); RefreshController(initialRefresh: true);
PanelController panelController = PanelController(); PanelController panelController = PanelController();
SlidingUpPanel _slidUpShoppingCart; late SlidingUpPanel _slidUpShoppingCart;
SliverPersistentHeader promotHeader; late SliverPersistentHeader promotHeader;
bool _animationFinish = true; bool _animationFinish = true;
Carousel slidingGellery; late Carousel slidingGellery;
// StreamSubscription onProductWillAddToCartSubscription; // StreamSubscription onProductWillAddToCartSubscription;
// StreamSubscription onProductWillRemoveFromCartSubscription; // StreamSubscription onProductWillRemoveFromCartSubscription;
@@ -247,7 +247,7 @@ class ShopState extends State<Shop>
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[], children: <Widget>[],
); );
for (var i = 0; i < _business.promoProducts.length; i++) { for (var i = 0; i < _business.promoProducts!.length; i++) {
promotRow.children.add(Container( promotRow.children.add(Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
left: 10.0, left: 10.0,
@@ -286,17 +286,17 @@ class ShopState extends State<Shop>
GestureDetector( GestureDetector(
child: Container( child: Container(
child: Util.showImage( child: Util.showImage(
_business.promoProducts[i].imagePath, _business.promoProducts![i].imagePath,
width: 110.0, width: 110.0,
), ),
), ),
onTap: () { onTap: () {
_showProductDetail(_business.promoProducts[i]); _showProductDetail(_business.promoProducts![i]);
}, },
), ),
Container( Container(
child: Text( child: Text(
_business.promoProducts[i].name, _business.promoProducts![i].name,
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 14.0), style: TextStyle(fontSize: 14.0),
@@ -306,13 +306,13 @@ class ShopState extends State<Shop>
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
ShowPrice( ShowPrice(
_business.promoProducts[i].price, _business.promoProducts![i].price,
currencySign: '\$', currencySign: '\$',
regularPrice: _business.promoProducts[i].regularPrice, regularPrice: _business.promoProducts![i].regularPrice,
), ),
Container( Container(
child: AddRemoveButton( child: AddRemoveButton(
product: _business.promoProducts[i], product: _business.promoProducts![i],
business: _business, business: _business,
addOnly: true, addOnly: true,
), ),
@@ -581,7 +581,7 @@ class ShopState extends State<Shop>
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[], children: <Widget>[],
); );
if (comment.images.length > 0) { if (comment.images!.length > 0) {
for (ProductImage image in comment.images) { for (ProductImage image in comment.images) {
imageRow.children.add( imageRow.children.add(
GestureDetector( GestureDetector(
@@ -609,7 +609,7 @@ class ShopState extends State<Shop>
} }
Widget replyWidget = SizedBox.shrink(); Widget replyWidget = SizedBox.shrink();
if (comment.replyFromStore != null && if (comment.replyFromStore != null &&
comment.replyFromStore.isNotEmpty) { comment.replyFromStore!.isNotEmpty) {
replyWidget = Container( replyWidget = Container(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
@@ -681,7 +681,7 @@ class ShopState extends State<Shop>
Container( Container(
child: SmoothStarRating( child: SmoothStarRating(
starCount: 5, starCount: 5,
rating: comment.rating.toDouble(), rating: comment.rating!.toDouble(),
size: 12.0, size: 12.0,
filledIconData: Icons.star, filledIconData: Icons.star,
color: Colors.green, color: Colors.green,
@@ -772,18 +772,18 @@ class ShopState extends State<Shop>
children: <Widget>[], children: <Widget>[],
); );
addressColumn.children.add(new Text( addressColumn.children.add(new Text(
_business.address.addressLine1 + _business.address!.addressLine1! +
(_business.address.addressLine2.isNotEmpty (_business.address!.addressLine2!.isNotEmpty
? ' ' + _business.address.addressLine2 ? ' ' + _business.address!.addressLine2
: ''), : ''),
style: new TextStyle(fontSize: 13.0, color: const Color(0xFFEEEEEE)), style: new TextStyle(fontSize: 13.0, color: const Color(0xFFEEEEEE)),
)); ));
addressColumn.children.add(new Text( addressColumn.children.add(new Text(
_business.address.city + _business.address!.city! +
', ' + ', ' +
_business.address.state + _business.address!.state +
', ' + ', ' +
_business.address.zip, _business.address!.zip,
style: new TextStyle(fontSize: 13.0, color: const Color(0xFFEEEEEE)), style: new TextStyle(fontSize: 13.0, color: const Color(0xFFEEEEEE)),
)); ));
@@ -800,16 +800,16 @@ class ShopState extends State<Shop>
color: Colors.white, color: Colors.white,
)); ));
distanceRow.children.add(new Text( distanceRow.children.add(new Text(
_business.distanceInfo.distance != null _business.distanceInfo!.distance != null
? _business.distanceInfo.distance.text ? _business.distanceInfo!.distance!.text
: '***' + ' / ', : '***' + ' / ',
style: new TextStyle(color: const Color(0xFFEEEEEE), fontSize: 13.0), style: new TextStyle(color: const Color(0xFFEEEEEE), fontSize: 13.0),
)); ));
var duration = Duration( var duration = Duration(
seconds: (_business.distanceInfo.duration != null seconds: (_business.distanceInfo!.duration != null
? _business.distanceInfo.duration.value ? _business.distanceInfo!.duration!.value
: 30) + : 30)! +
_business.shippingTime * 60); _business.shippingTime! * 60);
var hours = duration.inHours.remainder(60); var hours = duration.inHours.remainder(60);
var minutes = duration.inMinutes.remainder(60); var minutes = duration.inMinutes.remainder(60);
distanceRow.children.add(new Text( distanceRow.children.add(new Text(
@@ -910,9 +910,9 @@ class ShopState extends State<Shop>
color: Colors.white, color: Colors.white,
), ),
new Text( new Text(
_business.openingTime[0].openTime + _business.openingTime![0].openTime! +
':00 - ' + ':00 - ' +
_business.openingTime[0].closeTime + _business.openingTime![0].closeTime +
':00', ':00',
style: new TextStyle( style: new TextStyle(
fontSize: 13.0, color: const Color(0xFFEEEEEE)), fontSize: 13.0, color: const Color(0xFFEEEEEE)),
@@ -941,7 +941,7 @@ class ShopState extends State<Shop>
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
_business.bulletin.isNotEmpty ? Row( _business.bulletin!.isNotEmpty ? Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Container( Container(
@@ -956,7 +956,7 @@ class ShopState extends State<Shop>
width: mediaQuery.size.width - 30.0, width: mediaQuery.size.width - 30.0,
padding: EdgeInsets.only(right: 10.0, bottom: 10.0), padding: EdgeInsets.only(right: 10.0, bottom: 10.0),
child: new Text( child: new Text(
_business.bulletin.isEmpty ? '' : _business.bulletin, _business.bulletin!.isEmpty ? '' : _business.bulletin,
softWrap: true, softWrap: true,
style: new TextStyle( style: new TextStyle(
fontSize: 12.0, color: const Color(0xFFDDDDDD)), fontSize: 12.0, color: const Color(0xFFDDDDDD)),
@@ -965,7 +965,7 @@ class ShopState extends State<Shop>
), ),
], ],
) : SizedBox.shrink(), ) : SizedBox.shrink(),
_business.description.isNotEmpty ? Column( _business.description!.isNotEmpty ? Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@@ -1009,7 +1009,7 @@ class ShopState extends State<Shop>
padding: EdgeInsets.only(left: 10.0, right: 10.0, bottom: 10.0), padding: EdgeInsets.only(left: 10.0, right: 10.0, bottom: 10.0),
child: slidingGellery, child: slidingGellery,
) : SizedBox.shrink(), ) : SizedBox.shrink(),
_business.policy.isNotEmpty ? Column( _business.policy!.isNotEmpty ? Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@@ -1098,11 +1098,11 @@ class ShopState extends State<Shop>
List<Widget> _buildBanners(BuildContext context) { List<Widget> _buildBanners(BuildContext context) {
var pages = <Widget>[]; var pages = <Widget>[];
for (var i = 0; i < _business.slideImages.length; i++) { for (var i = 0; i < _business.slideImages!.length; i++) {
pages.add(new GestureDetector( pages.add(new GestureDetector(
child: new Container( child: new Container(
child: Util.showImage( child: Util.showImage(
_business.slideImages[i].imageUrl, _business.slideImages![i].imageUrl,
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
), ),
@@ -1139,11 +1139,11 @@ class ShopState extends State<Shop>
CartInfo cartInfo = CartInfo cartInfo =
Utils.getCartInfoByBusiness(store.state.cartInfos, _business); Utils.getCartInfoByBusiness(store.state.cartInfos, _business);
if (cartInfo != null && if (cartInfo != null &&
cartInfo.businessInfo.id == _business.id && cartInfo.businessInfo!.id == _business.id &&
cartInfo.productList != null) { cartInfo.productList != null) {
for (var i = 0; i < cartInfo.productList.length; i++) { for (var i = 0; i < cartInfo.productList!.length; i++) {
if (cartInfo.productList[i].product.categoryId == cp.id) { if (cartInfo.productList![i].product!.categoryId == cp.id) {
qtyInCategory += cartInfo.productList[i].quantity.round(); qtyInCategory += cartInfo.productList![i].quantity!.round();
} }
} }
} }
@@ -1213,7 +1213,7 @@ class ShopState extends State<Shop>
} }
void _selectCategory(int index) { void _selectCategory(int index) {
if (displayProductByCategoryClick && _categoryProducts[index].id > 0) { if (displayProductByCategoryClick && _categoryProducts[index].id! > 0) {
categoryId = _categoryProducts[index].id; categoryId = _categoryProducts[index].id;
loadProducts(); loadProducts();
return; return;
@@ -1221,7 +1221,7 @@ class ShopState extends State<Shop>
double height = 0.0; double height = 0.0;
for (int i = 0; i < index; ++i) { for (int i = 0; i < index; ++i) {
height += _categoryDescHeight + height += _categoryDescHeight +
_categoryProducts[i].products.length * _productHeight; _categoryProducts[i].products!.length * _productHeight;
} }
if (height > _listScrollController1.position.maxScrollExtent) { if (height > _listScrollController1.position.maxScrollExtent) {
height = _listScrollController1.position.maxScrollExtent; height = _listScrollController1.position.maxScrollExtent;
@@ -1237,7 +1237,7 @@ class ShopState extends State<Shop>
_categoryIndexChange = false; _categoryIndexChange = false;
}); });
print( print(
'height: $height, index: $index, ${_categoryProducts[0].products.length}'); 'height: $height, index: $index, ${_categoryProducts[0].products!.length}');
if (mounted) { if (mounted) {
setState(() { setState(() {
_categoryIndex = index; _categoryIndex = index;
@@ -1272,7 +1272,7 @@ class ShopState extends State<Shop>
if (height > 0) { if (height > 0) {
for (int i = 0; i < _categoryProducts.length; ++i) { for (int i = 0; i < _categoryProducts.length; ++i) {
double categoryHeight = _categoryDescHeight + double categoryHeight = _categoryDescHeight +
_categoryProducts[i].products.length * _productHeight; _categoryProducts[i].products!.length * _productHeight;
if (height >= cHeight && height < cHeight + categoryHeight) { if (height >= cHeight && height < cHeight + categoryHeight) {
return i; return i;
} }
@@ -1311,7 +1311,7 @@ class ShopState extends State<Shop>
int numCategoriesHasProducts() { int numCategoriesHasProducts() {
int num = 0; int num = 0;
for (CategoryProducts cp in _categoryProducts) { for (CategoryProducts cp in _categoryProducts) {
if (cp.products.length > 0) { if (cp.products!.length > 0) {
num += 1; num += 1;
} }
} }
@@ -1362,7 +1362,7 @@ class ShopState extends State<Shop>
}); });
} }
if (cp.products.length == 0) { if (cp.products!.length == 0) {
return SizedBox.shrink(); return SizedBox.shrink();
} }
@@ -1403,7 +1403,7 @@ class ShopState extends State<Shop>
), ),
), ),
new Visibility( new Visibility(
visible: cp.description.isNotEmpty, visible: cp.description!.isNotEmpty,
child: new Text( child: new Text(
cp.description, cp.description,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
@@ -1448,7 +1448,7 @@ class ShopState extends State<Shop>
), ),
); );
} else { } else {
if (cp.products.length < Constants.ORDERS_PER_PAGE) { if (cp.products!.length < Constants.ORDERS_PER_PAGE) {
col.children.add( col.children.add(
Container( Container(
padding: EdgeInsets.all(12.0), padding: EdgeInsets.all(12.0),
@@ -1620,7 +1620,7 @@ class ShopState extends State<Shop>
displayProductByCategoryClickIndicator = displayProductByCategoryClickIndicator =
S.of(context).end_of_the_list; S.of(context).end_of_the_list;
} else { } else {
if (moreCategoryProducts[0].products.length < Constants.ORDERS_PER_PAGE) { if (moreCategoryProducts[0].products!.length < Constants.ORDERS_PER_PAGE) {
_productCurrentPage = 0; _productCurrentPage = 0;
displayProductByCategoryClickIndicator = displayProductByCategoryClickIndicator =
S.of(context).end_of_the_list; S.of(context).end_of_the_list;
@@ -1631,7 +1631,7 @@ class ShopState extends State<Shop>
CategoryProducts currentCp = CategoryProducts currentCp =
getCategoryProductByCategoryId(categoryId); getCategoryProductByCategoryId(categoryId);
if (currentCp != null) { if (currentCp != null) {
currentCp.products.addAll(moreCategoryProducts[0].products); currentCp.products!.addAll(moreCategoryProducts[0].products);
} else { } else {
_productCurrentPage = 0; _productCurrentPage = 0;
displayProductByCategoryClickIndicator = displayProductByCategoryClickIndicator =
@@ -1653,16 +1653,16 @@ class ShopState extends State<Shop>
} }
CartLineItem _newCartLineItem( CartLineItem _newCartLineItem(
{int id, {int? id,
double price, double? price,
Product product, Product? product,
String name, String? name,
String description, String? description,
double quantity}) { double? quantity}) {
CartLineItem lineItem = CartLineItem(); CartLineItem lineItem = CartLineItem();
lineItem.unitPrice = price; lineItem.unitPrice = price;
lineItem.product = product; lineItem.product = product;
lineItem.name = product.name; lineItem.name = product!.name;
lineItem.description = description; lineItem.description = description;
lineItem.quantity = quantity; lineItem.quantity = quantity;
return lineItem; return lineItem;

View File

@@ -35,21 +35,21 @@ class ShoppingCartBar extends StatefulWidget {
} }
class ShoppingCartBarState extends State<ShoppingCartBar> { class ShoppingCartBarState extends State<ShoppingCartBar> {
CartInfo cartInfo; late CartInfo cartInfo;
double totalPrice = 0.0; double totalPrice = 0.0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
totalPrice = 0.0; totalPrice = 0.0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business); cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
if (cartInfo != null && cartInfo.businessInfo.id == widget.business.id) { if (cartInfo != null && cartInfo.businessInfo!.id == widget.business.id) {
totalPrice = cartInfo.getTotalPrice(); totalPrice = cartInfo.getTotalPrice();
} }
Widget cartContent; Widget cartContent;
if (cartInfo == null || (cartInfo.businessInfo.id != widget.business.id) if (cartInfo == null || (cartInfo.businessInfo!.id != widget.business.id)
|| (totalPrice == 0.0 && cartInfo.productList.length == 0)) { || (totalPrice == 0.0 && cartInfo.productList!.length == 0)) {
cartContent = Center( cartContent = Center(
child: Container( child: Container(
padding: EdgeInsets.all(20.0), padding: EdgeInsets.all(20.0),
@@ -92,8 +92,8 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
}, },
), ),
); );
for (var i = 0; i < cartInfo.productList.length; i++) { for (var i = 0; i < cartInfo.productList!.length; i++) {
(cartContent as Column).children.add(cartLineItem(cartInfo.productList[i], i)); (cartContent as Column).children.add(cartLineItem(cartInfo.productList![i], i));
} }
} }
@@ -134,7 +134,7 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
], ],
), ),
new Text( new Text(
S.of(context).delivery_fee(widget.business.shippingFee.toStringAsFixed(2)), S.of(context).delivery_fee(widget.business.shippingFee!.toStringAsFixed(2)),
style: new TextStyle( style: new TextStyle(
fontSize: 9.0, fontSize: 9.0,
color: Style.backgroundColor, color: Style.backgroundColor,
@@ -149,10 +149,10 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
child: GestureDetector( child: GestureDetector(
child: Container( child: Container(
padding: EdgeInsets.all(10.0), padding: EdgeInsets.all(10.0),
color: widget.business.minPrice - totalPrice >= 0 ? new Color(0xFF535356) : Colors.lightGreen, color: widget.business.minPrice! - totalPrice >= 0 ? new Color(0xFF535356) : Colors.lightGreen,
child: Center( child: Center(
child: Text( child: Text(
widget.business.minPrice - totalPrice >= 0 ? S.of(context).order_more((widget.business.minPrice - totalPrice).toStringAsFixed(2)) : S.of(context).checkout, widget.business.minPrice! - totalPrice >= 0 ? S.of(context).order_more((widget.business.minPrice! - totalPrice).toStringAsFixed(2)) : S.of(context).checkout,
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
color: Style.backgroundColor, color: Style.backgroundColor,
@@ -160,7 +160,7 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
), ),
), ),
), ),
onTap: widget.business.minPrice >= totalPrice ? null : () { onTap: widget.business.minPrice! >= totalPrice ? null : () {
if (store.state.user != null) { if (store.state.user != null) {
Routes.router.navigateTo(context, '/checkout/${widget.business.id}'); Routes.router.navigateTo(context, '/checkout/${widget.business.id}');
} else { } else {
@@ -255,7 +255,7 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
widget.hasPicture ? Container( widget.hasPicture ? Container(
padding: EdgeInsets.all(6.0), padding: EdgeInsets.all(6.0),
child: Util.showImage( child: Util.showImage(
'${item.product.imagePath}', '${item.product!.imagePath}',
width: 80, width: 80,
height: 80, height: 80,
fit: BoxFit.cover, fit: BoxFit.cover,
@@ -300,7 +300,7 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
children: <Widget>[ children: <Widget>[
Container( Container(
child: Text( child: Text(
'${item.totalPrice.toStringAsFixed(2)}', '${item.totalPrice!.toStringAsFixed(2)}',
style: TextStyle( style: TextStyle(
color: Colors.redAccent, color: Colors.redAccent,
fontSize: 14.0, fontSize: 14.0,

175
tools/nullfix.py Normal file
View File

@@ -0,0 +1,175 @@
#!/usr/bin/env python3
"""
nullfix.py — dart analyze 驱动的空安全批量修复(保守、带语法损坏自检)。
处理的规则(全部由 analyzer 位置驱动,逐轮迭代):
1. unchecked_use_of_nullable_value -> 在接收者后插 '!'(属性/方法/[]/运算符)
2. not_initialized_non_nullable_instance_field / _variable
-> 字段/变量改为可空(在类型后插 '?'),跳过 return/this./关键词行
3. missing_default_value_for_parameter
-> 参数改为可空(类型后插 '?'),跳过 field-formal this.x
不处理(需语义判断): argument_type_not_assignable / invalid_assignment
(这两类留给后续:多为 nullable 传给非空形参,常伴随 1/2 解决后自动减少)
每轮结束检测 expected_token / missing_identifier语法损坏有则中止。
用法: python3 tools/nullfix.py [file] [--max-rounds N]
"""
import re, subprocess, sys, os
ROUNDS = 40
args=[]
i=0
while i<len(sys.argv):
a=sys.argv[i]
if a=='--max-rounds': ROUNDS=int(sys.argv[i+1]); i+=2; continue
if not a.endswith('nullfix.py'): args.append(a)
i+=1
TARGET = args[0] if args else None
ERR = re.compile(r'\s+error\s+-\s+([\w/.\-]+):(\d+):(\d+)\s+-\s+(.*?)\s+-\s+([a-z_]+)\s*$')
PROP = re.compile(r"The property '([^']+)'")
METH = re.compile(r"The method '([^']+)'")
OPR = re.compile(r"The operator '([^']+)'")
NAME = re.compile(r"'([^']+)'")
KEYWORDS = {'return','throw','await','yield','break','continue','assert','new','const',
'final','var','late','switch','case','default','if','else','for','while',
'do','try','catch','finally','in','is','as','super','this'}
def analyze():
out = subprocess.run(['dart','analyze','lib'], capture_output=True, text=True).stdout
errs=[]; corruption=0
for ln in out.splitlines():
if 'expected_token' in ln or 'missing_identifier' in ln:
corruption += 1
m = ERR.match(ln)
if m:
p,l,c,msg,r=m.groups(); errs.append((p,int(l),int(c),msg,r))
if TARGET:
t=TARGET.replace('lib/','')
errs=[e for e in errs if e[0].endswith(t)]
return errs, corruption, out
def classify_use(msg):
m=PROP.search(msg)
if m: return (m.group(1),'prop')
m=METH.search(msg)
if m: return (None,'index') if m.group(1)=='[]' else (m.group(1),'meth')
m=OPR.search(msg)
if m: return (m.group(1),'op')
return None
def find_name_col(line, name, col0):
"""在 line 上找 name 的出现,返回最接近 col0 的起始 index找不到 None。"""
best=None
for mm in re.finditer(r'(?<![\w])'+re.escape(name)+r'(?!\w)', line):
d=abs(mm.start()-col0)
if best is None or d<best[0]: best=(d,mm.start())
return best[1] if best else None
def insert_bang(line, col0, name, kind):
if kind in ('prop','meth') and name:
pat = re.compile(r'(?<!!)\.' + re.escape(name) + r'\b')
best=None
for mm in pat.finditer(line):
d=abs(mm.start()-col0)
if best is None or d<best[0]: best=(d,mm)
if not best: return None
idx=best[1].start(); j=idx-1
if j<0: return None
if line[j]=='!': return None
if not (line[j].isalnum() or line[j] in '_)?]'): return None
return line[:idx]+'!'+line[idx:]
if kind=='index':
best=None
for i,ch in enumerate(line):
if ch=='[':
d=abs(i-col0)
if best is None or d<best[0]: best=(d,i)
if not best: return None
idx=best[1]; j=idx-1
if j<0 or line[j]=='!': return None
if line[j].isalnum() or line[j] in '_)?]': return line[:idx]+'!'+line[idx:]
return None
if kind=='op':
for mm in re.finditer(re.escape(name), line):
idx=mm.start(); j=idx-1
while j>=0 and line[j]==' ': j-=1
if j<0 or line[j]=='!': continue
if line[j].isalnum() or line[j] in '_)?]': return line[:j+1]+'!'+line[j+1:]
return None
return None
def insert_late(line):
stripped=line.strip()
if not stripped or stripped.startswith('late '): return None
head=stripped.split(';')[0]
if '?' in head or '=' in head: return None # 已可空/已初始化
indent=line[:len(line)-len(stripped)]
if stripped.startswith('static '): return indent+'static late '+stripped[len('static '):]
if stripped.startswith('external '): return indent+'external late '+stripped[len('external '):]
return indent+'late '+stripped
def insert_nullable_before_name(line, name, col0):
"""'Type name' 改为 'Type? name'。跳过 field-formal(this.)、关键词行。"""
stripped=line.strip()
first=stripped.split(' ')[0] if stripped else ''
if first.rstrip(')').rstrip('(') in KEYWORDS: return None
idx=find_name_col(line, name, col0)
if idx is None: return None
# name 前一个非空字符
j=idx-1
while j>=0 and line[j] in ' \t': j-=1
if j<0: return None
if line[j]=='.': return None # field-formal this.name
if line[j]=='?': return None # 已可空
# j 应是类型末尾(字母/>/)/]
if not (line[j].isalnum() or line[j] in '_>]?)'): return None
return line[:j+1]+'?'+line[j+1:]
def apply_round(errs):
changed=0; files={}
def get(path):
if path not in files:
files[path]=open('lib/'+path).read().split('\n')
return files[path]
def flush():
for p,ls in files.items():
open('lib/'+p,'w').write('\n'.join(ls))
for path,line,col,msg,rule in errs:
if not os.path.exists('lib/'+path): continue
L=get(path)
if line>len(L): continue
old=L[line-1]; new=old
if rule=='unchecked_use_of_nullable_value':
cls=classify_use(msg)
if cls: new=insert_bang(old, col-1, cls[0], cls[1])
elif rule=='missing_default_value_for_parameter':
nm=NAME.search(msg)
if nm: new=insert_nullable_before_name(old, nm.group(1), col-1)
elif rule in ('not_initialized_non_nullable_instance_field','not_initialized_non_nullable_variable'):
new=insert_late(old)
if new and new!=old:
L[line-1]=new; changed+=1
flush()
return changed
rounds=0
while rounds<ROUNDS:
errs,corruption,_=analyze()
if corruption:
print(f'!! 检测到 {corruption} 处语法损坏,中止。请 git diff 检查。'); sys.exit(2)
if not errs: print('无错误,完成。'); break
c=apply_round(errs)
rounds+=1
print(f'{rounds} 轮:修复 {c} 处(剩余 error {len(errs)}')
if c==0:
print('本轮无新增修复,剩余需人工/IDE 处理:')
from collections import Counter
cnt=Counter(e[4] for e in errs)
for r,n in cnt.most_common(8): print(f' {n:4d} {r}')
break
errs,corruption,_=analyze()
print(f'\n=== 完成。剩余 error: {len(errs)} | 语法损坏: {corruption} ===')