phase3: nullable fields/methods, casts, ?.call, pinput/YoutubePlayer v5, buttonColor, dead-code removal. 72->16

This commit is contained in:
2026-08-01 01:21:37 +08:00
parent 137eca4c69
commit 7c69197396
39 changed files with 107 additions and 113 deletions

View File

@@ -61,7 +61,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
Widget build(BuildContext context) {
if (widget.product!.leftNum == null) {
_qty = 0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business!);
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
@@ -102,7 +102,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
}
if (widget.addToBasket) {
_qty = 0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business!);
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) {
@@ -194,7 +194,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
);
} else {
_qty = 0;
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business!);
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) {

View File

@@ -94,7 +94,7 @@ class BreadCrumbs extends StatelessWidget {
color: Colors.blueAccent,
),
Text(
breadCrumb.text,
breadCrumb.text!,
style: TextStyle(
color: Colors.blueAccent,
fontSize: 14.0,
@@ -103,7 +103,7 @@ class BreadCrumbs extends StatelessWidget {
],
) :
Text(
breadCrumb.text,
breadCrumb.text!,
style: TextStyle(
color: Colors.blueAccent,
fontSize: 14.0,
@@ -145,7 +145,7 @@ class BreadCrumbs extends StatelessWidget {
color: Colors.lightBlueAccent,
),
Text(
breadCrumb.text,
breadCrumb.text!,
style: TextStyle(
color: Colors.black54,
fontSize: 14.0,
@@ -155,7 +155,7 @@ class BreadCrumbs extends StatelessWidget {
],
) :
Text(
breadCrumb.text,
breadCrumb.text!,
style: TextStyle(
color: Colors.black54,
fontSize: 14.0,
@@ -184,7 +184,7 @@ class BreadCrumbs extends StatelessWidget {
}
class BreadCrumb {
final String text;
final String? text;
final String? route;
final IconData? icon;
final Widget? item;

View File

@@ -38,7 +38,7 @@ class CarouselState extends State<Carousel> {
@override
void initState() {
super.initState();
if (widget.autoPlay) {
if (widget.autoPlay == true) {
_timer = new Timer.periodic(widget.duration, (timer) {
_pageController.animateToPage(_currentPage,
duration: widget.animationDuration, curve: Curves.linear);

View File

@@ -69,13 +69,13 @@ class ParabolicAnimationWidget extends AnimatedWidget {
RenderBox stackBox = stackKey.currentContext!.findRenderObject()! as RenderBox;
Offset stackBoxOffset = stackBox.globalToLocal(Offset.zero);
EdgeInsets startMargin = _margin(startKey);
EdgeInsets startMargin = _margin(startKey)!;
RenderBox startBox = startKey.currentContext!.findRenderObject()! as RenderBox;
_startOffset = startBox.localToGlobal(Offset(
startMargin.left + startAdjustOffset.dx,
stackBoxOffset.dy + startMargin.top + startAdjustOffset.dy));
EdgeInsets endMargin = _margin(endKey);
EdgeInsets endMargin = _margin(endKey)!;
RenderBox endBox = endKey.currentContext!.findRenderObject()! as RenderBox;
_endOffset = endBox.localToGlobal(Offset(
endMargin.left + endAdjustOffset.dx,
@@ -83,9 +83,9 @@ class ParabolicAnimationWidget extends AnimatedWidget {
}
}
EdgeInsets _margin(GlobalKey key) {
EdgeInsetsGeometry _margin(GlobalKey key) {
final Widget widget = key.currentContext!.widget;
EdgeInsets margin = (widget is Container) ? (widget.margin ?? EdgeInsets.zero) : EdgeInsets.zero;
EdgeInsetsGeometry margin = (widget is Container) ? (widget.margin ?? EdgeInsets.zero) : EdgeInsets.zero;
return margin ?? EdgeInsets.zero;
}
}

View File

@@ -109,8 +109,6 @@ class PaymentVerificationCodeDialogState extends State<PaymentVerificationCodeDi
);
}
},
defaultPinDecoration: _pinPutDecoration.copyWith(
borderRadius: BorderRadius.circular(20)),
),
),
),

View File

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