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