phase3: nullfix field-formal field-nullable handler. 907 -> 872

This commit is contained in:
2026-07-25 18:14:55 +08:00
parent fce670664b
commit c21ccbd54d
38 changed files with 151 additions and 131 deletions

View File

@@ -17,8 +17,8 @@ import '../../store/store.dart';
import '../../utils/utils.dart';
class AddRemoveButton extends StatefulWidget {
final Product product;
final Business business;
final Product? product;
final Business? business;
final bool addOnly;
final int cartLineItemIndex;
final bool addToBasket;
@@ -59,12 +59,12 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
@override
Widget build(BuildContext context) {
if (widget.product.leftNum == null) {
if (widget.product!.leftNum == null) {
_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
if (cartInfo.productList![i].product!.id == widget.product!.id
&& cartInfo.productList![i].unitPrice == 0.0) {
_qty = cartInfo.productList![i].quantity!.round();
break;
@@ -78,7 +78,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
),
);
}
if (widget.product.leftNum! <= 0) {
if (widget.product!.leftNum! <= 0) {
return Container(
padding: EdgeInsets.only(top: 0.0, bottom: 10.0, left: 8.0, right: 8.0),
child: Text(
@@ -105,7 +105,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
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) {
if (cartInfo.productList![i].product!.id == widget.product!.id) {
_qty = cartInfo.productList![i].quantity!.round();
break;
}
@@ -198,14 +198,14 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
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) {
if (cartInfo.productList![i].product!.id == widget.product!.id) {
_qty = cartInfo.productList![i].quantity!.round();
break;
}
}
}
if (widget.product.productAttributes != null &&
widget.product.productAttributes!.length > 0 && widget.cartLineItemIndex == -1) {
if (widget.product!.productAttributes != null &&
widget.product!.productAttributes!.length > 0 && widget.cartLineItemIndex == -1) {
return new Row(
key: startKey,
crossAxisAlignment: CrossAxisAlignment.end,
@@ -312,7 +312,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,
@@ -328,7 +328,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
eventBus.fire(new OnCartInfoUpdated());
}
} else {
if (widget.product.productAttributes!.length > 0) {
if (widget.product!.productAttributes!.length > 0) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) =>
@@ -337,7 +337,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
);
} else {
eventBus.fire(new OnProductWillAddToCart(widget.product, {},
widget.product.price, widget.product.description,
widget.product!.price, widget.product!.description,
widget.business, buttonKey: startKey));
}
}

View File

@@ -12,7 +12,7 @@ import '../../utils/utils.dart';
class DownloadItem extends StatefulWidget {
final dynamic desc;
final double width;
final double? width;
const DownloadItem(this.desc, {Key? key, this.width}) : super(key: key);
@override
@@ -52,7 +52,7 @@ class DownloadItemState extends State<DownloadItem> {
margin: EdgeInsets.only(right: 16.0),
),
Container(
width: widget.width != null ? widget.width - iconWidth - buttonWidth - 60 : MediaQuery.of(context).size.width - iconWidth - buttonWidth - 60,
width: widget.width != null ? widget.width! - iconWidth - buttonWidth - 60 : MediaQuery.of(context).size.width - iconWidth - buttonWidth - 60,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,

View File

@@ -28,16 +28,16 @@ class ReadMoreText extends StatefulWidget {
final String data;
final String trimExpandedText;
final String trimCollapsedText;
final Color colorClickableText;
final Color? colorClickableText;
final int trimLength;
final int trimLines;
final TrimMode trimMode;
final TextStyle style;
final TextAlign textAlign;
final TextDirection textDirection;
final Locale locale;
final double textScaleFactor;
final String semanticsLabel;
final TextStyle? style;
final TextAlign? textAlign;
final TextDirection? textDirection;
final Locale? locale;
final double? textScaleFactor;
final String? semanticsLabel;
@override
ReadMoreTextState createState() => ReadMoreTextState();
@@ -58,7 +58,7 @@ class ReadMoreTextState extends State<ReadMoreText> {
Widget build(BuildContext context) {
final DefaultTextStyle defaultTextStyle = DefaultTextStyle.of(context);
TextStyle effectiveTextStyle = widget.style;
if (widget.style == null || widget.style.inherit) {
if (widget.style == null || widget.style!.inherit) {
effectiveTextStyle = defaultTextStyle.style.merge(widget.style);
}

View File

@@ -3,10 +3,10 @@ import 'package:flutter/material.dart';
class ShowPrice extends StatelessWidget {
final double price;
final double regularPrice;
final double? regularPrice;
final double largeFontSize;
final double smallFontSize;
final String currencySign;
final String? currencySign;
final Color color;
final FontWeight fontWeight;
@@ -65,12 +65,12 @@ class ShowPrice extends StatelessWidget {
),
),
),
regularPrice == null || price.round() >= regularPrice.round() ?
regularPrice == null || price.round() >= regularPrice!.round() ?
SizedBox.shrink() :
Container(
padding: EdgeInsets.only(top: largeFontSize / 2),
child: Text(
regularPrice.toStringAsFixed(0),
regularPrice!.toStringAsFixed(0),
style: TextStyle(
color: Colors.black38,
fontSize: smallFontSize,

View File

@@ -30,7 +30,7 @@ class SlidingUpPanel extends StatefulWidget {
/// otherwise, [collapsed] will be displayed overtop
/// of this Widget. If [panel] and [panelBuilder] are both non-null,
/// [panel] will be used.
final Widget panel;
final Widget? panel;
/// WARNING: This feature is still in beta and is subject to change without
/// notice. Stability is not gauranteed. Provides a [ScrollController] and
@@ -38,28 +38,28 @@ class SlidingUpPanel extends StatefulWidget {
/// the panel position with the scroll position. Useful for implementing an
/// infinite scroll behavior. If [panel] and [panelBuilder] are both non-null,
/// [panel] will be used.
final Widget Function(ScrollController sc) panelBuilder;
final Widget Function(ScrollController sc)? panelBuilder;
/// The Widget displayed overtop the [panel] when collapsed.
/// This fades out as the panel is opened.
final Widget collapsed;
final Widget? collapsed;
/// The Widget that lies underneath the sliding panel.
/// This Widget automatically sizes itself
/// to fill the screen.
final Widget body;
final Widget? body;
/// Optional persistent widget that floats above the [panel] and attaches
/// to the top of the [panel]. Content at the top of the panel will be covered
/// by this widget. Add padding to the bottom of the `panel` to
/// avoid coverage.
final Widget header;
final Widget? header;
/// Optional persistent widget that floats above the [panel] and
/// attaches to the bottom of the [panel]. Content at the bottom of the panel
/// will be covered by this widget. Add padding to the bottom of the `panel`
/// to avoid coverage.
final Widget footer;
final Widget? footer;
/// The height of the sliding panel when fully collapsed.
final double minHeight;
@@ -72,13 +72,13 @@ class SlidingUpPanel extends StatefulWidget {
/// and go directly to the open/close position. This value is represented as a
/// percentage of the total animation distance ([maxHeight] - [minHeight]),
/// so it must be between 0.0 and 1.0, exclusive.
final double snapPoint;
final double? snapPoint;
/// A border to draw around the sliding panel sheet.
final Border border;
final Border? border;
/// If non-null, the corners of the sliding panel sheet are rounded by this [BorderRadiusGeometry].
final BorderRadiusGeometry borderRadius;
final BorderRadiusGeometry? borderRadius;
/// A list of shadows cast behind the sliding panel sheet.
final List<BoxShadow> boxShadow;
@@ -87,10 +87,10 @@ class SlidingUpPanel extends StatefulWidget {
final Color color;
/// The amount to inset the children of the sliding panel sheet.
final EdgeInsetsGeometry padding;
final EdgeInsetsGeometry? padding;
/// Empty space surrounding the sliding panel sheet.
final EdgeInsetsGeometry margin;
final EdgeInsetsGeometry? margin;
/// Set to false to not to render the sheet the [panel] sits upon.
/// This means that only the [body], [collapsed], and the [panel]
@@ -104,7 +104,7 @@ class SlidingUpPanel extends StatefulWidget {
final bool panelSnapping;
/// If non-null, this can be used to control the state of the panel.
final PanelController controller;
final PanelController? controller;
/// If non-null, shows a darkening shadow over the [body] as the panel slides open.
final bool backdropEnabled;
@@ -125,15 +125,15 @@ class SlidingUpPanel extends StatefulWidget {
/// is called as the panel slides around with the
/// current position of the panel. The position is a double
/// between 0.0 and 1.0 where 0.0 is fully collapsed and 1.0 is fully open.
final void Function(double position) onPanelSlide;
final void Function(double position)? onPanelSlide;
/// If non-null, this callback is called when the
/// panel is fully opened
final VoidCallback onPanelOpened;
final VoidCallback? onPanelOpened;
/// If non-null, this callback is called when the panel
/// is fully collapsed.
final VoidCallback onPanelClosed;
final VoidCallback? onPanelClosed;
/// If non-null and true, the SlidingUpPanel exhibits a
/// parallax effect as the panel slides up. Essentially,
@@ -320,8 +320,8 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
top: widget.slideDirection == SlideDirection.UP ? 0.0 : null,
bottom: widget.slideDirection == SlideDirection.DOWN ? 0.0 : null,
width: MediaQuery.of(context).size.width -
(widget.margin != null ? widget.margin.horizontal : 0) -
(widget.padding != null ? widget.padding.horizontal : 0),
(widget.margin != null ? widget.margin!.horizontal : 0) -
(widget.padding != null ? widget.padding!.horizontal : 0),
child: Container(
height: widget.maxHeight,
child: widget.panel != null
@@ -349,8 +349,8 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
top: widget.slideDirection == SlideDirection.UP ? 0.0 : null,
bottom: widget.slideDirection == SlideDirection.DOWN ? 0.0 : null,
width: MediaQuery.of(context).size.width -
(widget.margin != null ? widget.margin.horizontal : 0) -
(widget.padding != null ? widget.padding.horizontal : 0),
(widget.margin != null ? widget.margin!.horizontal : 0) -
(widget.padding != null ? widget.padding!.horizontal : 0),
child: Container(
height: widget.minHeight,
child: widget.collapsed == null ? Container() : FadeTransition(