fix(runtime): 37 late fields with == null checks were wrongly migrated -> nullable. Fixes LateInitializationError crashes on page navigation (shop/checkout/comment/data pages)
This commit is contained in:
@@ -48,7 +48,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
var d = 1;
|
||||
|
||||
late CartInfo cartInfo;
|
||||
CartInfo? cartInfo;
|
||||
|
||||
GlobalKey startKey = GlobalKey();
|
||||
|
||||
@@ -63,10 +63,10 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
_qty = 0;
|
||||
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business!)!;
|
||||
if (cartInfo != null) {
|
||||
for (var i = 0; i < cartInfo.productList!.length; i++) {
|
||||
if (cartInfo.productList![i].product!.id == widget.product!.id
|
||||
&& cartInfo.productList![i].unitPrice == 0.0) {
|
||||
_qty = cartInfo.productList![i].quantity!.round();
|
||||
for (var i = 0; i < cartInfo!.productList!.length; i++) {
|
||||
if (cartInfo!.productList![i].product!.id == widget.product!.id
|
||||
&& cartInfo!.productList![i].unitPrice == 0.0) {
|
||||
_qty = cartInfo!.productList![i].quantity!.round();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -104,9 +104,9 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
_qty = 0;
|
||||
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business!)!;
|
||||
if (cartInfo != null) {
|
||||
for (var i = 0; i < cartInfo.productList!.length; i++) {
|
||||
if (cartInfo.productList![i].product!.id == widget.product!.id) {
|
||||
_qty = cartInfo.productList![i].quantity!.round();
|
||||
for (var i = 0; i < cartInfo!.productList!.length; i++) {
|
||||
if (cartInfo!.productList![i].product!.id == widget.product!.id) {
|
||||
_qty = cartInfo!.productList![i].quantity!.round();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -196,9 +196,9 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
_qty = 0;
|
||||
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business!)!;
|
||||
if (cartInfo != null) {
|
||||
for (var i = 0; i < cartInfo.productList!.length; i++) {
|
||||
if (cartInfo.productList![i].product!.id == widget.product!.id) {
|
||||
_qty = cartInfo.productList![i].quantity!.round();
|
||||
for (var i = 0; i < cartInfo!.productList!.length; i++) {
|
||||
if (cartInfo!.productList![i].product!.id == widget.product!.id) {
|
||||
_qty = cartInfo!.productList![i].quantity!.round();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
void _addToCart(BuildContext context) {
|
||||
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(
|
||||
msg: S.of(context).product_insufficient,
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
@@ -320,10 +320,10 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
textColor: Colors.white
|
||||
);
|
||||
} else {
|
||||
cartInfo.productList![widget.cartLineItemIndex].quantity = (cartInfo.productList![widget.cartLineItemIndex].quantity ?? 0) + 1.0;
|
||||
Utils.addSubproductQty(cartInfo, cartInfo.productList![widget.cartLineItemIndex]);
|
||||
cartInfo!.productList![widget.cartLineItemIndex].quantity = (cartInfo!.productList![widget.cartLineItemIndex].quantity ?? 0) + 1.0;
|
||||
Utils.addSubproductQty(cartInfo!, cartInfo!.productList![widget.cartLineItemIndex]);
|
||||
store.dispatch(UpdateCartInfo(
|
||||
Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo)));
|
||||
Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo!)));
|
||||
eventBus.fire(new OnCartInfoUpdated());
|
||||
}
|
||||
} else {
|
||||
@@ -344,7 +344,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
void _removeFromCart(BuildContext context) {
|
||||
if (widget.cartLineItemIndex != -1) {
|
||||
if (cartInfo.productList![widget.cartLineItemIndex].quantity! <= 1) {
|
||||
if (cartInfo!.productList![widget.cartLineItemIndex].quantity! <= 1) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@@ -379,18 +379,18 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
}
|
||||
|
||||
void _removeCartLineItem() {
|
||||
if (cartInfo.productList![widget.cartLineItemIndex].quantity! <= 1) {
|
||||
String uuid = cartInfo.productList![widget.cartLineItemIndex].uuid!;
|
||||
cartInfo.productList!.removeAt(widget.cartLineItemIndex);
|
||||
Utils.removeSubproduct(cartInfo, uuid);
|
||||
if (cartInfo!.productList![widget.cartLineItemIndex].quantity! <= 1) {
|
||||
String uuid = cartInfo!.productList![widget.cartLineItemIndex].uuid!;
|
||||
cartInfo!.productList!.removeAt(widget.cartLineItemIndex);
|
||||
Utils.removeSubproduct(cartInfo!, uuid);
|
||||
} else {
|
||||
cartInfo.productList![widget.cartLineItemIndex].quantity = (cartInfo.productList![widget.cartLineItemIndex].quantity ?? 0) - 1;
|
||||
Utils.addSubproductQty(cartInfo, cartInfo.productList![widget.cartLineItemIndex], remove: true);
|
||||
cartInfo!.productList![widget.cartLineItemIndex].quantity = (cartInfo!.productList![widget.cartLineItemIndex].quantity ?? 0) - 1;
|
||||
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)));
|
||||
} else {
|
||||
store.dispatch(new UpdateCartInfo(Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo)));
|
||||
store.dispatch(new UpdateCartInfo(Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo!)));
|
||||
}
|
||||
eventBus.fire(new OnCartInfoUpdated());
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class Carousel extends StatefulWidget {
|
||||
class CarouselState extends State<Carousel> {
|
||||
final _pageController = new PageController();
|
||||
|
||||
late Timer _timer;
|
||||
Timer? _timer;
|
||||
int _currentPage = 0;
|
||||
bool reverse = false;
|
||||
GlobalKey<IndicatorState> _indicatorStateKey = new GlobalKey();
|
||||
@@ -63,7 +63,7 @@ class CarouselState extends State<Carousel> {
|
||||
void dispose() {
|
||||
_pageController?.dispose();
|
||||
if (_timer != null) {
|
||||
_timer.cancel();
|
||||
_timer!.cancel();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class ParabolicAnimationWidget extends AnimatedWidget {
|
||||
this.endAdjustOffset = Offset.zero,
|
||||
}) : super(listenable: animation);
|
||||
|
||||
late Offset _startOffset;
|
||||
Offset? _startOffset;
|
||||
late Offset _endOffset;
|
||||
|
||||
@override
|
||||
@@ -36,13 +36,13 @@ class ParabolicAnimationWidget extends AnimatedWidget {
|
||||
// double x(double time) => _x + _v * time + 0.5 * _a * time * time;
|
||||
final double initV = -400; //纵坐标初速度, 负值为向上抛
|
||||
final double acceleration =
|
||||
(_endOffset.dy - _startOffset.dy - initV) / 0.5; //求纵坐标加速度
|
||||
(_endOffset.dy - _startOffset!.dy - initV) / 0.5; //求纵坐标加速度
|
||||
|
||||
final GravitySimulation spy = GravitySimulation(
|
||||
acceleration, _startOffset.dy, _endOffset.dy, initV); //y轴加速度运动 模拟
|
||||
acceleration, _startOffset!.dy, _endOffset.dy, initV); //y轴加速度运动 模拟
|
||||
|
||||
final GravitySimulation spx = GravitySimulation(0, _startOffset.dx,
|
||||
_endOffset.dx, _endOffset.dx - _startOffset.dx); //x轴匀速模拟 加速度为0
|
||||
final GravitySimulation spx = GravitySimulation(0, _startOffset!.dx,
|
||||
_endOffset.dx, _endOffset.dx - _startOffset!.dx); //x轴匀速模拟 加速度为0
|
||||
|
||||
final Animation<double> opacity = Tween<double>(begin: 1, end: 0).animate(
|
||||
CurvedAnimation(
|
||||
|
||||
@@ -33,7 +33,7 @@ class PaymentVerificationCodeDialogState extends State<PaymentVerificationCodeDi
|
||||
String getCodeText = '';
|
||||
String paymentCodeEncrypt = '';
|
||||
|
||||
late String verifyMethod;
|
||||
String? verifyMethod;
|
||||
late String verifyName;
|
||||
|
||||
final TextEditingController _pinPutController = TextEditingController();
|
||||
|
||||
@@ -18,7 +18,7 @@ class PopupAnimationWidget extends AnimatedWidget {
|
||||
this.popupOffset = Offset.zero,
|
||||
}) : super(listenable: animation);
|
||||
|
||||
late Offset _startOffset;
|
||||
Offset? _startOffset;
|
||||
Offset _offset = Offset.zero;
|
||||
|
||||
@override
|
||||
@@ -29,7 +29,7 @@ class PopupAnimationWidget extends AnimatedWidget {
|
||||
.animate(CurvedAnimation(
|
||||
parent: animation, curve: Interval(0, 0.4, curve: Curves.ease)));
|
||||
_offset =
|
||||
Offset(_startOffset.dx, _startOffset.dy - opacityAnimation.value * 80);
|
||||
Offset(_startOffset!.dx, _startOffset!.dy - opacityAnimation.value * 80);
|
||||
|
||||
return Positioned(
|
||||
left: _offset.dx,
|
||||
|
||||
@@ -602,7 +602,7 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
|
||||
|
||||
|
||||
class PanelController{
|
||||
late _SlidingUpPanelState _panelState;
|
||||
_SlidingUpPanelState? _panelState;
|
||||
|
||||
void _addState(_SlidingUpPanelState panelState){
|
||||
this._panelState = panelState;
|
||||
@@ -616,27 +616,27 @@ class PanelController{
|
||||
/// Closes the sliding panel to its collapsed state (i.e. to the minHeight)
|
||||
Future<void> close(){
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
return _panelState._close();
|
||||
return _panelState!._close();
|
||||
}
|
||||
|
||||
/// Opens the sliding panel fully
|
||||
/// (i.e. to the maxHeight)
|
||||
Future<void> open(){
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
return _panelState._open();
|
||||
return _panelState!._open();
|
||||
}
|
||||
|
||||
/// Hides the sliding panel (i.e. is invisible)
|
||||
Future<void> hide(){
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
return _panelState._hide();
|
||||
return _panelState!._hide();
|
||||
}
|
||||
|
||||
/// Shows the sliding panel in its collapsed state
|
||||
/// (i.e. "un-hide" the sliding panel)
|
||||
Future<void> show(){
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
return _panelState._show();
|
||||
return _panelState!._show();
|
||||
}
|
||||
|
||||
/// Animates the panel position to the value.
|
||||
@@ -647,7 +647,7 @@ class PanelController{
|
||||
Future<void> animatePanelToPosition(double value, {Duration? duration, Curve curve = Curves.linear}){
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
assert(0.0 <= value && value <= 1.0);
|
||||
return _panelState._animatePanelToPosition(value, duration: duration, curve: curve);
|
||||
return _panelState!._animatePanelToPosition(value, duration: duration, curve: curve);
|
||||
}
|
||||
|
||||
/// Animates the panel position to the snap point
|
||||
@@ -656,8 +656,8 @@ class PanelController{
|
||||
/// (optional) curve specifies the easing behavior of the animation.
|
||||
Future<void> animatePanelToSnapPoint({Duration? duration, Curve curve = Curves.linear}){
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
assert(_panelState.widget.snapPoint != null, "SlidingUpPanel snapPoint property must not be null");
|
||||
return _panelState._animatePanelToSnapPoint(duration: duration, curve: curve);
|
||||
assert(_panelState!.widget.snapPoint != null, "SlidingUpPanel snapPoint property must not be null");
|
||||
return _panelState!._animatePanelToSnapPoint(duration: duration, curve: curve);
|
||||
}
|
||||
|
||||
/// Sets the panel position (without animation).
|
||||
@@ -666,7 +666,7 @@ class PanelController{
|
||||
set panelPosition(double value){
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
assert(0.0 <= value && value <= 1.0);
|
||||
_panelState._panelPosition = value;
|
||||
_panelState!._panelPosition = value;
|
||||
}
|
||||
|
||||
/// Gets the current panel position.
|
||||
@@ -677,35 +677,35 @@ class PanelController{
|
||||
/// 1.0 is full open.
|
||||
double get panelPosition{
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
return _panelState._panelPosition;
|
||||
return _panelState!._panelPosition;
|
||||
}
|
||||
|
||||
/// Returns whether or not the panel is
|
||||
/// currently animating.
|
||||
bool get isPanelAnimating{
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
return _panelState._isPanelAnimating;
|
||||
return _panelState!._isPanelAnimating;
|
||||
}
|
||||
|
||||
/// Returns whether or not the
|
||||
/// panel is open.
|
||||
bool get isPanelOpen{
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
return _panelState._isPanelOpen;
|
||||
return _panelState!._isPanelOpen;
|
||||
}
|
||||
|
||||
/// Returns whether or not the
|
||||
/// panel is closed.
|
||||
bool get isPanelClosed{
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
return _panelState._isPanelClosed;
|
||||
return _panelState!._isPanelClosed;
|
||||
}
|
||||
|
||||
/// Returns whether or not the
|
||||
/// panel is shown/hidden.
|
||||
bool get isPanelShown{
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
return _panelState._isPanelShown;
|
||||
return _panelState!._isPanelShown;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user