fix(runtime): late top-level/instance vars used with ??= (mediaQuery/screenHeight/etc) -> nullable. Fixes LateInitializationError on /me /shop /product-detail
This commit is contained in:
@@ -37,10 +37,10 @@ import 'product_item.dart';
|
||||
import 'product_search.dart';
|
||||
import 'shopping_cart_bar.dart';
|
||||
|
||||
late MediaQueryData mediaQuery;
|
||||
late double statusBarHeight;
|
||||
late double screenWidth;
|
||||
late double screenHeight;
|
||||
MediaQueryData? mediaQuery;
|
||||
double? statusBarHeight;
|
||||
double? screenWidth;
|
||||
double? screenHeight;
|
||||
|
||||
class Shop extends StatefulWidget {
|
||||
final int? businessId;
|
||||
@@ -80,11 +80,11 @@ class ShopState extends State<Shop>
|
||||
bool refresh = false;
|
||||
|
||||
late ShopScrollCoordinator _shopCoordinator;
|
||||
late ShopScrollController _pageScrollController;
|
||||
ShopScrollController? _pageScrollController;
|
||||
late TabController _tabController;
|
||||
final double _sliverAppBarInitHeight = 150.0;
|
||||
final double _tabBarHeight = 50.0;
|
||||
late double _sliverAppBarMaxHeight;
|
||||
double? _sliverAppBarMaxHeight;
|
||||
|
||||
ShopScrollController? _listScrollController1;
|
||||
late ShopScrollController _listScrollController2;
|
||||
@@ -204,17 +204,17 @@ class ShopState extends State<Shop>
|
||||
}
|
||||
|
||||
mediaQuery ??= MediaQuery.of(context);
|
||||
screenWidth ??= mediaQuery.size.width;
|
||||
screenHeight ??= mediaQuery.size.height;
|
||||
statusBarHeight ??= mediaQuery.padding.top;
|
||||
screenWidth ??= mediaQuery!.size.width;
|
||||
screenHeight ??= mediaQuery!.size.height;
|
||||
statusBarHeight ??= mediaQuery!.padding.top;
|
||||
|
||||
_sliverAppBarMaxHeight ??= screenHeight - 150.0;
|
||||
_sliverAppBarMaxHeight ??= screenHeight! - 150.0;
|
||||
|
||||
_pageScrollController ??= _shopCoordinator
|
||||
.pageScrollController(_sliverAppBarMaxHeight - _sliverAppBarInitHeight);
|
||||
.pageScrollController(_sliverAppBarMaxHeight! - _sliverAppBarInitHeight);
|
||||
|
||||
_shopCoordinator.pinnedHeaderSliverHeightBuilder ??= () {
|
||||
return statusBarHeight + kToolbarHeight + _tabBarHeight;
|
||||
return statusBarHeight! + kToolbarHeight + _tabBarHeight;
|
||||
};
|
||||
|
||||
refresh = false;
|
||||
@@ -513,8 +513,8 @@ class ShopState extends State<Shop>
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 0,
|
||||
left: screenWidth - 100,
|
||||
bottom: screenHeight - 100,
|
||||
left: screenWidth! - 100,
|
||||
bottom: screenHeight! - 100,
|
||||
child: Image.asset(
|
||||
'assets/images/under_renovation.png',
|
||||
width: 200.0,
|
||||
@@ -953,7 +953,7 @@ class ShopState extends State<Shop>
|
||||
color: Colors.white,
|
||||
)),
|
||||
Container(
|
||||
width: mediaQuery.size.width - 30.0,
|
||||
width: mediaQuery!.size.width - 30.0,
|
||||
padding: EdgeInsets.only(right: 10.0, bottom: 10.0),
|
||||
child: new Text(
|
||||
_business!.bulletin!.isEmpty ? '' : _business!.bulletin!,
|
||||
|
||||
Reference in New Issue
Block a user