phase3: nullable fields/methods, casts, ?.call, pinput/YoutubePlayer v5, buttonColor, dead-code removal. 72->16
This commit is contained in:
@@ -35,7 +35,7 @@ class CreateOnlineStore1State extends State<CreateOnlineStore1> {
|
||||
|
||||
late Group group;
|
||||
|
||||
late String selectedDomain;
|
||||
String? selectedDomain;
|
||||
List<dynamic> domainResult = [];
|
||||
|
||||
@override
|
||||
|
||||
@@ -28,7 +28,7 @@ class MobileBlog extends StatefulWidget {
|
||||
}
|
||||
|
||||
class MobileBlogState extends State<MobileBlog> {
|
||||
late List<Blog> blogs;
|
||||
List<Blog>? blogs;
|
||||
|
||||
int _page = 1;
|
||||
int _pageCount = 1;
|
||||
@@ -41,7 +41,7 @@ class MobileBlogState extends State<MobileBlog> {
|
||||
void _onRefresh() {
|
||||
_page = 1;
|
||||
if (blogs != null) {
|
||||
blogs.clear();
|
||||
blogs!.clear();
|
||||
} else {
|
||||
blogs = [];
|
||||
}
|
||||
@@ -82,7 +82,7 @@ class MobileBlogState extends State<MobileBlog> {
|
||||
enablePullUp: true,
|
||||
header: WaterDropHeader(),
|
||||
footer: CustomFooter(
|
||||
builder: (BuildContext context, LoadStatus mode){
|
||||
builder: (BuildContext context, LoadStatus? mode){
|
||||
Widget footer;
|
||||
if(mode == LoadStatus.idle) {
|
||||
footer = Text(S.of(context).pull_up_to_load_more);
|
||||
@@ -123,9 +123,9 @@ class MobileBlogState extends State<MobileBlog> {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: blogs.length <= 1 ? 1 : blogs.length,
|
||||
itemCount: blogs!.length <= 1 ? 1 : blogs!.length,
|
||||
itemBuilder: (BuildContext context, int i) {
|
||||
if (blogs.length <= 0) {
|
||||
if (blogs!.length <= 0) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Center(
|
||||
@@ -133,7 +133,7 @@ class MobileBlogState extends State<MobileBlog> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Blog blog = blogs[i];
|
||||
Blog blog = blogs![i];
|
||||
|
||||
Widget w = Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 16.0),
|
||||
@@ -243,7 +243,7 @@ class MobileBlogState extends State<MobileBlog> {
|
||||
if (blogs == null) {
|
||||
blogs = [];
|
||||
}
|
||||
blogs.addAll((value['blogs'] as List).map((e) => Blog.fromJson(e)).toList());
|
||||
blogs!.addAll((value['blogs'] as List).map((e) => Blog.fromJson(e)).toList());
|
||||
});
|
||||
}
|
||||
}).catchError((error) {
|
||||
|
||||
@@ -24,7 +24,7 @@ class MobileCoupons extends StatefulWidget {
|
||||
}
|
||||
|
||||
class MobileCouponsState extends State<MobileCoupons> {
|
||||
late List<Coupon> coupons;
|
||||
List<Coupon>? coupons;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -54,10 +54,10 @@ class MobileCouponsState extends State<MobileCoupons> {
|
||||
),
|
||||
),
|
||||
body: ListView.builder(
|
||||
itemCount: coupons.length > 0 ? coupons.length : 1,
|
||||
itemCount: coupons!.length > 0 ? coupons!.length : 1,
|
||||
itemBuilder: (BuildContext context, int position) {
|
||||
if (coupons.length > 0) {
|
||||
Coupon coupon = coupons[position];
|
||||
if (coupons!.length > 0) {
|
||||
Coupon coupon = coupons![position];
|
||||
return Container(
|
||||
color: Colors.black12,
|
||||
child: couponWidget(coupon),
|
||||
|
||||
@@ -94,7 +94,7 @@ class MobileiGoShowLearnMoreState extends State<MobileiGoShowLearnMore> {
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
child: YoutubePlayerIFrame(
|
||||
child: YoutubePlayer(
|
||||
controller: _controller,
|
||||
aspectRatio: 2 / 1,
|
||||
),
|
||||
|
||||
@@ -40,7 +40,7 @@ class MobileMeState extends State<MobileMe> {
|
||||
late String accessToken;
|
||||
|
||||
late bool isLoading;
|
||||
late User _user;
|
||||
User? _user;
|
||||
|
||||
late ShopScrollCoordinator _shopCoordinator;
|
||||
late ShopScrollController _pageScrollController;
|
||||
@@ -88,9 +88,9 @@ class MobileMeState extends State<MobileMe> {
|
||||
children: <Widget>[
|
||||
Container(
|
||||
margin: EdgeInsets.only(right: 5.0),
|
||||
child: _user != null && _user.avatarUrl!.isNotEmpty
|
||||
child: _user != null && _user!.avatarUrl!.isNotEmpty
|
||||
? Util.showImage(
|
||||
'https:${_user.avatarUrl}',
|
||||
'https:${_user!.avatarUrl}',
|
||||
width: 60,
|
||||
height: 60,
|
||||
fit: BoxFit.fill,
|
||||
@@ -116,7 +116,7 @@ class MobileMeState extends State<MobileMe> {
|
||||
Container(
|
||||
child: Text(
|
||||
_user != null
|
||||
? _user.nickname
|
||||
? _user!.nickname!
|
||||
: S.of(context).please_login,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
@@ -142,7 +142,7 @@ class MobileMeState extends State<MobileMe> {
|
||||
Container(
|
||||
child: Text(
|
||||
_user != null
|
||||
? Utils.safePhoneNumber(_user.mobile!)
|
||||
? Utils.safePhoneNumber(_user!.mobile!)
|
||||
: '',
|
||||
style: TextStyle(
|
||||
color:
|
||||
@@ -219,7 +219,7 @@ class MobileMeState extends State<MobileMe> {
|
||||
Container(
|
||||
child: Text(
|
||||
_user != null
|
||||
? '${_user.wallet!.toStringAsFixed(2)}'
|
||||
? '${_user!.wallet!.toStringAsFixed(2)}'
|
||||
: '0.00',
|
||||
style: TextStyle(
|
||||
fontSize: 24.0,
|
||||
@@ -262,7 +262,7 @@ class MobileMeState extends State<MobileMe> {
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: Text(
|
||||
_user != null ? '${_user.coupon}' : '0',
|
||||
_user != null ? '${_user!.coupon}' : '0',
|
||||
style: TextStyle(
|
||||
fontSize: 24.0,
|
||||
color: Colors.orangeAccent,
|
||||
@@ -296,7 +296,7 @@ class MobileMeState extends State<MobileMe> {
|
||||
onTap: () {
|
||||
if (_user != null) {
|
||||
Routes.router
|
||||
.navigateTo(context, '/coupons/${_user.id}');
|
||||
.navigateTo(context, '/coupons/${_user!.id}');
|
||||
} else {
|
||||
_pleaseLoginToast();
|
||||
}
|
||||
@@ -312,7 +312,7 @@ class MobileMeState extends State<MobileMe> {
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: Text(
|
||||
_user != null ? '${_user.points}' : '0',
|
||||
_user != null ? '${_user!.points}' : '0',
|
||||
style: TextStyle(
|
||||
fontSize: 24.0,
|
||||
color: Colors.lightGreen,
|
||||
@@ -671,7 +671,7 @@ class MobileMeState extends State<MobileMe> {
|
||||
),
|
||||
onTap: () {
|
||||
if (_user != null) {
|
||||
if (_user.email == null || _user.email!.isEmpty) {
|
||||
if (_user!.email == null || _user!.email!.isEmpty) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
|
||||
@@ -27,7 +27,7 @@ class MobileMyAddresses extends StatefulWidget {
|
||||
}
|
||||
|
||||
class MobileMyAddressesState extends State<MobileMyAddresses> {
|
||||
late List<Address> addresses;
|
||||
List<Address>? addresses;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -70,9 +70,9 @@ class MobileMyAddressesState extends State<MobileMyAddresses> {
|
||||
],
|
||||
),
|
||||
body: ListView.builder(
|
||||
itemCount: addresses.length <= 1 ? 1 : addresses.length,
|
||||
itemCount: addresses!.length <= 1 ? 1 : addresses!.length,
|
||||
itemBuilder: (BuildContext context, int i) {
|
||||
if (addresses.length <= 0) {
|
||||
if (addresses!.length <= 0) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Center(
|
||||
@@ -80,7 +80,7 @@ class MobileMyAddressesState extends State<MobileMyAddresses> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Address address = addresses[i];
|
||||
Address address = addresses![i];
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 16.0),
|
||||
|
||||
@@ -28,7 +28,7 @@ class MobileMySupport extends StatefulWidget {
|
||||
}
|
||||
|
||||
class MobileMySupportState extends State<MobileMySupport> {
|
||||
late List<Ticket> tickets;
|
||||
List<Ticket>? tickets;
|
||||
|
||||
int _page = 1;
|
||||
int _pageCount = 1;
|
||||
@@ -41,7 +41,7 @@ class MobileMySupportState extends State<MobileMySupport> {
|
||||
void _onRefresh() {
|
||||
_page = 1;
|
||||
if (tickets != null) {
|
||||
tickets.clear();
|
||||
tickets!.clear();
|
||||
} else {
|
||||
tickets = [];
|
||||
}
|
||||
@@ -101,7 +101,7 @@ class MobileMySupportState extends State<MobileMySupport> {
|
||||
enablePullUp: true,
|
||||
header: WaterDropHeader(),
|
||||
footer: CustomFooter(
|
||||
builder: (BuildContext context, LoadStatus mode){
|
||||
builder: (BuildContext context, LoadStatus? mode){
|
||||
Widget footer;
|
||||
if(mode == LoadStatus.idle) {
|
||||
footer = Text(S.of(context).pull_up_to_load_more);
|
||||
@@ -143,9 +143,9 @@ class MobileMySupportState extends State<MobileMySupport> {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: tickets.length <= 1 ? 1 : tickets.length,
|
||||
itemCount: tickets!.length <= 1 ? 1 : tickets!.length,
|
||||
itemBuilder: (BuildContext context, int i) {
|
||||
if (tickets.length <= 0) {
|
||||
if (tickets!.length <= 0) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Center(
|
||||
@@ -153,7 +153,7 @@ class MobileMySupportState extends State<MobileMySupport> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Ticket ticket = tickets[i];
|
||||
Ticket ticket = tickets![i];
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
@@ -201,7 +201,7 @@ class MobileMySupportState extends State<MobileMySupport> {
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ticket.isClosed ?
|
||||
ticket.isClosed == true ?
|
||||
Container(
|
||||
padding: EdgeInsets.only(right: 10.0),
|
||||
child: Icon(Icons.lock, color: Colors.green, size: 16.0,),
|
||||
@@ -273,7 +273,7 @@ class MobileMySupportState extends State<MobileMySupport> {
|
||||
if (tickets == null) {
|
||||
tickets = [];
|
||||
}
|
||||
tickets.addAll((value['tickets'] as List).map((e) => Ticket.fromJson(e)).toList());
|
||||
tickets!.addAll((value['tickets'] as List).map((e) => Ticket.fromJson(e)).toList());
|
||||
});
|
||||
}
|
||||
}).catchError((error) {
|
||||
|
||||
@@ -324,7 +324,7 @@ class MobileNewAddressState extends State<MobileNewAddress> {
|
||||
),
|
||||
bottomNavigationBar: Container(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
color: Theme.of(context).buttonColor,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
|
||||
@@ -270,7 +270,7 @@ class MobileNewCommentState extends State<MobileNewComment> {
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return Util().getPicture(mainContext, store.state.user!,
|
||||
commentId: comment != null ? comment.id : 0,
|
||||
commentId: comment != null ? comment.id! : 0,
|
||||
orderId: widget.orderId);
|
||||
}
|
||||
);
|
||||
@@ -329,7 +329,7 @@ class MobileNewCommentState extends State<MobileNewComment> {
|
||||
}
|
||||
},
|
||||
queryParameters: {
|
||||
'comment_id': comment != null ? comment.id : 0,
|
||||
'comment_id': comment != null ? comment.id! : 0,
|
||||
},
|
||||
).catchError((error) {
|
||||
Utils.showMessageDialog(context, error);
|
||||
@@ -356,7 +356,7 @@ class MobileNewCommentState extends State<MobileNewComment> {
|
||||
isFormData: true,
|
||||
body: {
|
||||
'order_id': widget.orderId,
|
||||
'comment_id': comment != null ? comment.id : 0,
|
||||
'comment_id': comment != null ? comment.id! : 0,
|
||||
'content': commentController.text,
|
||||
'rating': rating.round(),
|
||||
},
|
||||
|
||||
@@ -331,7 +331,6 @@ class MobileNewTicketState extends State<MobileNewTicket> {
|
||||
galleryImagesFlag[imageId]['path'] = path;
|
||||
});
|
||||
});
|
||||
return null;
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
@@ -31,7 +31,7 @@ class MobileOrders extends StatefulWidget {
|
||||
class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderStateMixin {
|
||||
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
List<Order> orders = [];
|
||||
List<Order>? orders;
|
||||
|
||||
int _page = 1;
|
||||
int _pageCount = 1;
|
||||
@@ -44,7 +44,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
void _onRefresh() {
|
||||
_page = 1;
|
||||
if (orders != null) {
|
||||
orders.clear();
|
||||
orders!.clear();
|
||||
} else {
|
||||
orders = [];
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
enablePullUp: true,
|
||||
header: WaterDropHeader(),
|
||||
footer: CustomFooter(
|
||||
builder: (BuildContext context, LoadStatus mode){
|
||||
builder: (BuildContext context, LoadStatus? mode){
|
||||
Widget footer;
|
||||
if(mode == LoadStatus.idle) {
|
||||
footer = Text(S.of(context).pull_up_to_load_more);
|
||||
@@ -127,11 +127,11 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
Widget _buildBody() {
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: orders != null && orders.length > 0 ? orders.length : 1,
|
||||
itemCount: orders != null && orders!.length > 0 ? orders!.length : 1,
|
||||
itemBuilder: (BuildContext context, int position) {
|
||||
Order? order;
|
||||
if (orders != null && orders.length > 0) {
|
||||
order = orders[position];
|
||||
if (orders != null && orders!.length > 0) {
|
||||
order = orders![position];
|
||||
}
|
||||
if (order == null) {
|
||||
return Container(
|
||||
@@ -199,7 +199,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
),
|
||||
],
|
||||
);
|
||||
if (order.status == Constants.STATUS_COMPLETE && !order.hasComment) {
|
||||
if (order.status == Constants.STATUS_COMPLETE && order.hasComment != true) {
|
||||
row3.children.add(
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 10.0),
|
||||
@@ -438,7 +438,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
orders.addAll((data['items'] as List).map((e) => Order.fromJson(e)).toList());
|
||||
orders!.addAll((data['items'] as List).map((e) => Order.fromJson(e)).toList());
|
||||
});
|
||||
}
|
||||
}).catchError((error) {
|
||||
|
||||
@@ -96,7 +96,7 @@ class MobileProductItemState extends State<MobileProductItem> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
child: widget.business!.showMonthlySold ?
|
||||
child: widget.business!.showMonthlySold == true ?
|
||||
Text(
|
||||
S.of(context).sold_per_month_token(widget.product!.monthSales!.toStringAsFixed(0)),
|
||||
style: new TextStyle(
|
||||
|
||||
@@ -123,7 +123,7 @@ class MobileSearchPlaceState extends State<MobileSearchPlace> {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
void _selectPlaceAsNew(LocatedAddress locatedAddress) {
|
||||
void _selectPlaceAsNew(LocatedAddress? locatedAddress) {
|
||||
print('located address: ${locatedAddress.toString()}');
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (BuildContext context) => NewAddress(locatedAddress: locatedAddress, businessId: widget.businessId,),
|
||||
|
||||
@@ -598,7 +598,6 @@ class MobileViewTicketState extends State<MobileViewTicket> {
|
||||
galleryImagesFlag[imageId]['path'] = path;
|
||||
});
|
||||
});
|
||||
return null;
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
@@ -125,7 +125,7 @@ class ProductItemState extends State<ProductItem> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
child: widget.business.showMonthlySold ?
|
||||
child: widget.business.showMonthlySold == true ?
|
||||
Text(
|
||||
S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)),
|
||||
style: new TextStyle(
|
||||
@@ -210,7 +210,7 @@ class ProductItemState extends State<ProductItem> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
child: widget.business.showMonthlySold ?
|
||||
child: widget.business.showMonthlySold == true ?
|
||||
Text(
|
||||
S.of(context).sold_per_month_token(widget.product.monthSales!.toStringAsFixed(0)),
|
||||
style: new TextStyle(
|
||||
|
||||
@@ -41,7 +41,7 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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) {
|
||||
totalPrice = cartInfo.getTotalPrice();
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
|
||||
onTap: () {
|
||||
Utils.clearCart(context, cartInfo, onComplete: (_) {
|
||||
if (widget.onEmptyCartListener != null) {
|
||||
widget.onEmptyCartListener();
|
||||
widget.onEmptyCartListener?.call();
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -198,7 +198,7 @@ class ShoppingCartBarState extends State<ShoppingCartBar> {
|
||||
),
|
||||
onTap: () {
|
||||
if (widget.onPanelOpenCloseRequest != null) {
|
||||
widget.onPanelOpenCloseRequest();
|
||||
widget.onPanelOpenCloseRequest?.call();
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user