Unverified Commit 0de8bef7 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Remove unnecessary null checks in flutter/cupertino (#119020)

parent 720bea02
...@@ -36,9 +36,7 @@ class CupertinoActivityIndicator extends StatefulWidget { ...@@ -36,9 +36,7 @@ class CupertinoActivityIndicator extends StatefulWidget {
this.color, this.color,
this.animating = true, this.animating = true,
this.radius = _kDefaultIndicatorRadius, this.radius = _kDefaultIndicatorRadius,
}) : assert(animating != null), }) : assert(radius > 0.0),
assert(radius != null),
assert(radius > 0.0),
progress = 1.0; progress = 1.0;
/// Creates a non-animated iOS-style activity indicator that displays /// Creates a non-animated iOS-style activity indicator that displays
...@@ -52,9 +50,7 @@ class CupertinoActivityIndicator extends StatefulWidget { ...@@ -52,9 +50,7 @@ class CupertinoActivityIndicator extends StatefulWidget {
this.color, this.color,
this.radius = _kDefaultIndicatorRadius, this.radius = _kDefaultIndicatorRadius,
this.progress = 1.0, this.progress = 1.0,
}) : assert(radius != null), }) : assert(radius > 0.0),
assert(radius > 0.0),
assert(progress != null),
assert(progress >= 0.0), assert(progress >= 0.0),
assert(progress <= 1.0), assert(progress <= 1.0),
animating = false; animating = false;
......
...@@ -177,15 +177,7 @@ class CupertinoApp extends StatefulWidget { ...@@ -177,15 +177,7 @@ class CupertinoApp extends StatefulWidget {
this.restorationScopeId, this.restorationScopeId,
this.scrollBehavior, this.scrollBehavior,
this.useInheritedMediaQuery = false, this.useInheritedMediaQuery = false,
}) : assert(routes != null), }) : routeInformationProvider = null,
assert(navigatorObservers != null),
assert(title != null),
assert(showPerformanceOverlay != null),
assert(checkerboardRasterCacheImages != null),
assert(checkerboardOffscreenLayers != null),
assert(showSemanticsDebugger != null),
assert(debugShowCheckedModeBanner != null),
routeInformationProvider = null,
routeInformationParser = null, routeInformationParser = null,
routerDelegate = null, routerDelegate = null,
backButtonDispatcher = null, backButtonDispatcher = null,
...@@ -222,12 +214,6 @@ class CupertinoApp extends StatefulWidget { ...@@ -222,12 +214,6 @@ class CupertinoApp extends StatefulWidget {
this.scrollBehavior, this.scrollBehavior,
this.useInheritedMediaQuery = false, this.useInheritedMediaQuery = false,
}) : assert(routerDelegate != null || routerConfig != null), }) : assert(routerDelegate != null || routerConfig != null),
assert(title != null),
assert(showPerformanceOverlay != null),
assert(checkerboardRasterCacheImages != null),
assert(checkerboardOffscreenLayers != null),
assert(showSemanticsDebugger != null),
assert(debugShowCheckedModeBanner != null),
navigatorObservers = null, navigatorObservers = null,
navigatorKey = null, navigatorKey = null,
onGenerateRoute = null, onGenerateRoute = null,
......
...@@ -74,16 +74,12 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget { ...@@ -74,16 +74,12 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget {
width: 0.0, // 0.0 means one physical pixel width: 0.0, // 0.0 means one physical pixel
), ),
), ),
}) : assert(items != null), }) : assert(
assert(
items.length >= 2, items.length >= 2,
"Tabs need at least 2 items to conform to Apple's HIG", "Tabs need at least 2 items to conform to Apple's HIG",
), ),
assert(currentIndex != null),
assert(0 <= currentIndex && currentIndex < items.length), assert(0 <= currentIndex && currentIndex < items.length),
assert(iconSize != null), assert(height >= 0.0);
assert(height != null && height >= 0.0),
assert(inactiveColor != null);
/// The interactive items laid out within the bottom navigation bar. /// The interactive items laid out within the bottom navigation bar.
/// ///
......
...@@ -50,8 +50,6 @@ class CupertinoButton extends StatefulWidget { ...@@ -50,8 +50,6 @@ class CupertinoButton extends StatefulWidget {
this.alignment = Alignment.center, this.alignment = Alignment.center,
required this.onPressed, required this.onPressed,
}) : assert(pressedOpacity == null || (pressedOpacity >= 0.0 && pressedOpacity <= 1.0)), }) : assert(pressedOpacity == null || (pressedOpacity >= 0.0 && pressedOpacity <= 1.0)),
assert(disabledColor != null),
assert(alignment != null),
_filled = false; _filled = false;
/// Creates an iOS-style button with a filled background. /// Creates an iOS-style button with a filled background.
...@@ -71,8 +69,6 @@ class CupertinoButton extends StatefulWidget { ...@@ -71,8 +69,6 @@ class CupertinoButton extends StatefulWidget {
this.alignment = Alignment.center, this.alignment = Alignment.center,
required this.onPressed, required this.onPressed,
}) : assert(pressedOpacity == null || (pressedOpacity >= 0.0 && pressedOpacity <= 1.0)), }) : assert(pressedOpacity == null || (pressedOpacity >= 0.0 && pressedOpacity <= 1.0)),
assert(disabledColor != null),
assert(alignment != null),
color = null, color = null,
_filled = true; _filled = true;
......
...@@ -780,16 +780,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable { ...@@ -780,16 +780,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
this.darkHighContrastElevatedColor, this.darkHighContrastElevatedColor,
this._debugResolveContext, this._debugResolveContext,
this._debugLabel, this._debugLabel,
) : assert(color != null), ) : // The super constructor has to be called with a dummy value in order to mark
assert(darkColor != null),
assert(highContrastColor != null),
assert(darkHighContrastColor != null),
assert(elevatedColor != null),
assert(darkElevatedColor != null),
assert(highContrastElevatedColor != null),
assert(darkHighContrastElevatedColor != null),
assert(_effectiveColor != null),
// The super constructor has to be called with a dummy value in order to mark
// this constructor const. // this constructor const.
// The field `value` is overridden in the class implementation. // The field `value` is overridden in the class implementation.
super(0); super(0);
...@@ -908,7 +899,6 @@ class CupertinoDynamicColor extends Color with Diagnosticable { ...@@ -908,7 +899,6 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
/// * [maybeResolve], which is similar to this function, but will allow a /// * [maybeResolve], which is similar to this function, but will allow a
/// null `resolvable` color. /// null `resolvable` color.
static Color resolve(Color resolvable, BuildContext context) { static Color resolve(Color resolvable, BuildContext context) {
assert(context != null);
return (resolvable is CupertinoDynamicColor) return (resolvable is CupertinoDynamicColor)
? resolvable.resolveFrom(context) ? resolvable.resolveFrom(context)
: resolvable; : resolvable;
...@@ -931,7 +921,6 @@ class CupertinoDynamicColor extends Color with Diagnosticable { ...@@ -931,7 +921,6 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
if (resolvable == null) { if (resolvable == null) {
return null; return null;
} }
assert(context != null);
return (resolvable is CupertinoDynamicColor) return (resolvable is CupertinoDynamicColor)
? resolvable.resolveFrom(context) ? resolvable.resolveFrom(context)
: resolvable; : resolvable;
......
...@@ -142,8 +142,7 @@ class CupertinoContextMenu extends StatefulWidget { ...@@ -142,8 +142,7 @@ class CupertinoContextMenu extends StatefulWidget {
'This feature was deprecated after v3.4.0-34.1.pre.', 'This feature was deprecated after v3.4.0-34.1.pre.',
) )
this.previewBuilder = _defaultPreviewBuilder, this.previewBuilder = _defaultPreviewBuilder,
}) : assert(actions != null && actions.isNotEmpty), }) : assert(actions.isNotEmpty),
assert(child != null),
builder = ((BuildContext context, Animation<double> animation) => child); builder = ((BuildContext context, Animation<double> animation) => child);
/// Creates a context menu with a custom [builder] controlling the widget. /// Creates a context menu with a custom [builder] controlling the widget.
...@@ -158,7 +157,7 @@ class CupertinoContextMenu extends StatefulWidget { ...@@ -158,7 +157,7 @@ class CupertinoContextMenu extends StatefulWidget {
super.key, super.key,
required this.actions, required this.actions,
required this.builder, required this.builder,
}) : assert(actions != null && actions.isNotEmpty), }) : assert(actions.isNotEmpty),
child = null, child = null,
previewBuilder = null; previewBuilder = null;
...@@ -794,8 +793,7 @@ class _ContextMenuRoute<T> extends PopupRoute<T> { ...@@ -794,8 +793,7 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
super.filter, super.filter,
required Rect previousChildRect, required Rect previousChildRect,
super.settings, super.settings,
}) : assert(actions != null && actions.isNotEmpty), }) : assert(actions.isNotEmpty),
assert(contextMenuLocation != null),
_actions = actions, _actions = actions,
_builder = builder, _builder = builder,
_contextMenuLocation = contextMenuLocation, _contextMenuLocation = contextMenuLocation,
...@@ -1081,8 +1079,7 @@ class _ContextMenuRouteStatic extends StatefulWidget { ...@@ -1081,8 +1079,7 @@ class _ContextMenuRouteStatic extends StatefulWidget {
this.onDismiss, this.onDismiss,
required this.orientation, required this.orientation,
this.sheetGlobalKey, this.sheetGlobalKey,
}) : assert(contextMenuLocation != null), });
assert(orientation != null);
final List<Widget>? actions; final List<Widget>? actions;
final Widget child; final Widget child;
...@@ -1409,9 +1406,7 @@ class _ContextMenuSheet extends StatelessWidget { ...@@ -1409,9 +1406,7 @@ class _ContextMenuSheet extends StatelessWidget {
required this.actions, required this.actions,
required _ContextMenuLocation contextMenuLocation, required _ContextMenuLocation contextMenuLocation,
required Orientation orientation, required Orientation orientation,
}) : assert(actions != null && actions.isNotEmpty), }) : assert(actions.isNotEmpty),
assert(contextMenuLocation != null),
assert(orientation != null),
_contextMenuLocation = contextMenuLocation, _contextMenuLocation = contextMenuLocation,
_orientation = orientation; _orientation = orientation;
......
...@@ -20,9 +20,7 @@ class CupertinoContextMenuAction extends StatefulWidget { ...@@ -20,9 +20,7 @@ class CupertinoContextMenuAction extends StatefulWidget {
this.isDestructiveAction = false, this.isDestructiveAction = false,
this.onPressed, this.onPressed,
this.trailingIcon, this.trailingIcon,
}) : assert(child != null), });
assert(isDefaultAction != null),
assert(isDestructiveAction != null);
/// The widget that will be placed inside the action. /// The widget that will be placed inside the action.
final Widget child; final Widget child;
......
...@@ -81,8 +81,7 @@ class _DatePickerLayoutDelegate extends MultiChildLayoutDelegate { ...@@ -81,8 +81,7 @@ class _DatePickerLayoutDelegate extends MultiChildLayoutDelegate {
_DatePickerLayoutDelegate({ _DatePickerLayoutDelegate({
required this.columnWidths, required this.columnWidths,
required this.textDirectionFactor, required this.textDirectionFactor,
}) : assert(columnWidths != null), });
assert(textDirectionFactor != null);
// The list containing widths of all columns. // The list containing widths of all columns.
final List<double> columnWidths; final List<double> columnWidths;
...@@ -277,14 +276,10 @@ class CupertinoDatePicker extends StatefulWidget { ...@@ -277,14 +276,10 @@ class CupertinoDatePicker extends StatefulWidget {
this.dateOrder, this.dateOrder,
this.backgroundColor, this.backgroundColor,
}) : initialDateTime = initialDateTime ?? DateTime.now(), }) : initialDateTime = initialDateTime ?? DateTime.now(),
assert(mode != null),
assert(onDateTimeChanged != null),
assert(minimumYear != null),
assert( assert(
minuteInterval > 0 && 60 % minuteInterval == 0, minuteInterval > 0 && 60 % minuteInterval == 0,
'minute interval is not a positive integer factor of 60', 'minute interval is not a positive integer factor of 60',
) { ) {
assert(this.initialDateTime != null);
assert( assert(
mode != CupertinoDatePickerMode.dateAndTime || minimumDate == null || !this.initialDateTime.isBefore(minimumDate!), mode != CupertinoDatePickerMode.dateAndTime || minimumDate == null || !this.initialDateTime.isBefore(minimumDate!),
'initial date is before minimum date', 'initial date is before minimum date',
...@@ -944,7 +939,6 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> { ...@@ -944,7 +939,6 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> {
} }
void _scrollToDate(DateTime newDate, DateTime fromDate, bool minCheck) { void _scrollToDate(DateTime newDate, DateTime fromDate, bool minCheck) {
assert(newDate != null);
SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) { SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) {
if (fromDate.year != newDate.year || fromDate.month != newDate.month || fromDate.day != newDate.day) { if (fromDate.year != newDate.year || fromDate.month != newDate.month || fromDate.day != newDate.day) {
_animateColumnControllerToItem(dateController, selectedDayFromInitial); _animateColumnControllerToItem(dateController, selectedDayFromInitial);
...@@ -1349,7 +1343,6 @@ class _CupertinoDatePickerDateState extends State<CupertinoDatePicker> { ...@@ -1349,7 +1343,6 @@ class _CupertinoDatePickerDateState extends State<CupertinoDatePicker> {
} }
void _scrollToDate(DateTime newDate) { void _scrollToDate(DateTime newDate) {
assert(newDate != null);
SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) { SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) {
if (selectedYear != newDate.year) { if (selectedYear != newDate.year) {
_animateColumnControllerToItem(yearController, newDate.year); _animateColumnControllerToItem(yearController, newDate.year);
...@@ -1551,15 +1544,12 @@ class CupertinoTimerPicker extends StatefulWidget { ...@@ -1551,15 +1544,12 @@ class CupertinoTimerPicker extends StatefulWidget {
this.alignment = Alignment.center, this.alignment = Alignment.center,
this.backgroundColor, this.backgroundColor,
required this.onTimerDurationChanged, required this.onTimerDurationChanged,
}) : assert(mode != null), }) : assert(initialTimerDuration >= Duration.zero),
assert(onTimerDurationChanged != null),
assert(initialTimerDuration >= Duration.zero),
assert(initialTimerDuration < const Duration(days: 1)), assert(initialTimerDuration < const Duration(days: 1)),
assert(minuteInterval > 0 && 60 % minuteInterval == 0), assert(minuteInterval > 0 && 60 % minuteInterval == 0),
assert(secondInterval > 0 && 60 % secondInterval == 0), assert(secondInterval > 0 && 60 % secondInterval == 0),
assert(initialTimerDuration.inMinutes % minuteInterval == 0), assert(initialTimerDuration.inMinutes % minuteInterval == 0),
assert(initialTimerDuration.inSeconds % secondInterval == 0), assert(initialTimerDuration.inSeconds % secondInterval == 0);
assert(alignment != null);
/// The mode of the timer picker. /// The mode of the timer picker.
final CupertinoTimerPickerMode mode; final CupertinoTimerPickerMode mode;
......
...@@ -37,8 +37,7 @@ class CupertinoDesktopTextSelectionToolbarButton extends StatefulWidget { ...@@ -37,8 +37,7 @@ class CupertinoDesktopTextSelectionToolbarButton extends StatefulWidget {
super.key, super.key,
required this.onPressed, required this.onPressed,
required Widget this.child, required Widget this.child,
}) : assert(child != null), }) : buttonItem = null;
buttonItem = null;
/// Create an instance of [CupertinoDesktopTextSelectionToolbarButton] whose child is /// Create an instance of [CupertinoDesktopTextSelectionToolbarButton] whose child is
/// a [Text] widget styled like the default Mac context menu button. /// a [Text] widget styled like the default Mac context menu button.
...@@ -66,8 +65,7 @@ class CupertinoDesktopTextSelectionToolbarButton extends StatefulWidget { ...@@ -66,8 +65,7 @@ class CupertinoDesktopTextSelectionToolbarButton extends StatefulWidget {
CupertinoDesktopTextSelectionToolbarButton.buttonItem({ CupertinoDesktopTextSelectionToolbarButton.buttonItem({
super.key, super.key,
required ContextMenuButtonItem this.buttonItem, required ContextMenuButtonItem this.buttonItem,
}) : assert(buttonItem != null), }) : onPressed = buttonItem.onPressed,
onPressed = buttonItem.onPressed,
child = null; child = null;
/// {@macro flutter.cupertino.CupertinoTextSelectionToolbarButton.onPressed} /// {@macro flutter.cupertino.CupertinoTextSelectionToolbarButton.onPressed}
......
...@@ -201,7 +201,7 @@ class CupertinoAlertDialog extends StatelessWidget { ...@@ -201,7 +201,7 @@ class CupertinoAlertDialog extends StatelessWidget {
this.actionScrollController, this.actionScrollController,
this.insetAnimationDuration = const Duration(milliseconds: 100), this.insetAnimationDuration = const Duration(milliseconds: 100),
this.insetAnimationCurve = Curves.decelerate, this.insetAnimationCurve = Curves.decelerate,
}) : assert(actions != null); });
/// The (optional) title of the dialog is displayed in a large font at the top /// The (optional) title of the dialog is displayed in a large font at the top
/// of the dialog. /// of the dialog.
...@@ -665,8 +665,7 @@ class CupertinoActionSheetAction extends StatelessWidget { ...@@ -665,8 +665,7 @@ class CupertinoActionSheetAction extends StatelessWidget {
this.isDefaultAction = false, this.isDefaultAction = false,
this.isDestructiveAction = false, this.isDestructiveAction = false,
required this.child, required this.child,
}) : assert(child != null), });
assert(onPressed != null);
/// The callback that is called when the button is tapped. /// The callback that is called when the button is tapped.
/// ///
...@@ -701,7 +700,7 @@ class CupertinoActionSheetAction extends StatelessWidget { ...@@ -701,7 +700,7 @@ class CupertinoActionSheetAction extends StatelessWidget {
} }
return MouseRegion( return MouseRegion(
cursor: onPressed != null && kIsWeb ? SystemMouseCursors.click : MouseCursor.defer, cursor: kIsWeb ? SystemMouseCursors.click : MouseCursor.defer,
child: GestureDetector( child: GestureDetector(
onTap: onPressed, onTap: onPressed,
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
...@@ -896,7 +895,6 @@ class _CupertinoDialogRenderElement extends RenderObjectElement { ...@@ -896,7 +895,6 @@ class _CupertinoDialogRenderElement extends RenderObjectElement {
} }
void _placeChildInSlot(RenderObject child, _AlertDialogSections slot) { void _placeChildInSlot(RenderObject child, _AlertDialogSections slot) {
assert(slot != null);
switch (slot) { switch (slot) {
case _AlertDialogSections.contentSection: case _AlertDialogSections.contentSection:
renderObject.contentSection = child as RenderBox; renderObject.contentSection = child as RenderBox;
...@@ -1443,7 +1441,7 @@ class _CupertinoAlertActionSection extends StatelessWidget { ...@@ -1443,7 +1441,7 @@ class _CupertinoAlertActionSection extends StatelessWidget {
this.scrollController, this.scrollController,
this.hasCancelButton = false, this.hasCancelButton = false,
this.isActionSheet = false, this.isActionSheet = false,
}) : assert(children != null); });
final List<Widget> children; final List<Widget> children;
...@@ -1593,9 +1591,7 @@ class CupertinoDialogAction extends StatelessWidget { ...@@ -1593,9 +1591,7 @@ class CupertinoDialogAction extends StatelessWidget {
this.isDestructiveAction = false, this.isDestructiveAction = false,
this.textStyle, this.textStyle,
required this.child, required this.child,
}) : assert(child != null), });
assert(isDefaultAction != null),
assert(isDestructiveAction != null);
/// The callback that is called when the button is tapped or otherwise /// The callback that is called when the button is tapped or otherwise
/// activated. /// activated.
......
...@@ -45,8 +45,7 @@ class CupertinoUserInterfaceLevel extends InheritedWidget { ...@@ -45,8 +45,7 @@ class CupertinoUserInterfaceLevel extends InheritedWidget {
super.key, super.key,
required CupertinoUserInterfaceLevelData data, required CupertinoUserInterfaceLevelData data,
required super.child, required super.child,
}) : assert(data != null), }) : _data = data;
_data = data;
final CupertinoUserInterfaceLevelData _data; final CupertinoUserInterfaceLevelData _data;
...@@ -65,7 +64,6 @@ class CupertinoUserInterfaceLevel extends InheritedWidget { ...@@ -65,7 +64,6 @@ class CupertinoUserInterfaceLevel extends InheritedWidget {
/// * [maybeOf], which is similar, but will return null if no /// * [maybeOf], which is similar, but will return null if no
/// [CupertinoUserInterfaceLevel] encloses the given context. /// [CupertinoUserInterfaceLevel] encloses the given context.
static CupertinoUserInterfaceLevelData of(BuildContext context) { static CupertinoUserInterfaceLevelData of(BuildContext context) {
assert(context != null);
final CupertinoUserInterfaceLevel? query = context.dependOnInheritedWidgetOfExactType<CupertinoUserInterfaceLevel>(); final CupertinoUserInterfaceLevel? query = context.dependOnInheritedWidgetOfExactType<CupertinoUserInterfaceLevel>();
if (query != null) { if (query != null) {
return query._data; return query._data;
...@@ -95,7 +93,6 @@ class CupertinoUserInterfaceLevel extends InheritedWidget { ...@@ -95,7 +93,6 @@ class CupertinoUserInterfaceLevel extends InheritedWidget {
/// * [of], which is similar, but will throw an exception if no /// * [of], which is similar, but will throw an exception if no
/// [CupertinoUserInterfaceLevel] encloses the given context. /// [CupertinoUserInterfaceLevel] encloses the given context.
static CupertinoUserInterfaceLevelData? maybeOf(BuildContext context) { static CupertinoUserInterfaceLevelData? maybeOf(BuildContext context) {
assert(context != null);
final CupertinoUserInterfaceLevel? query = context.dependOnInheritedWidgetOfExactType<CupertinoUserInterfaceLevel>(); final CupertinoUserInterfaceLevel? query = context.dependOnInheritedWidgetOfExactType<CupertinoUserInterfaceLevel>();
if (query != null) { if (query != null) {
return query._data; return query._data;
......
...@@ -257,15 +257,7 @@ class CupertinoNavigationBar extends StatefulWidget implements ObstructingPrefer ...@@ -257,15 +257,7 @@ class CupertinoNavigationBar extends StatefulWidget implements ObstructingPrefer
this.padding, this.padding,
this.transitionBetweenRoutes = true, this.transitionBetweenRoutes = true,
this.heroTag = _defaultHeroTag, this.heroTag = _defaultHeroTag,
}) : assert(automaticallyImplyLeading != null), }) : assert(
assert(automaticallyImplyMiddle != null),
assert(transitionBetweenRoutes != null),
assert(
heroTag != null,
'heroTag cannot be null. Use transitionBetweenRoutes = false to '
'disable Hero transition on this navigation bar.',
),
assert(
!transitionBetweenRoutes || identical(heroTag, _defaultHeroTag), !transitionBetweenRoutes || identical(heroTag, _defaultHeroTag),
'Cannot specify a heroTag override if this navigation bar does not ' 'Cannot specify a heroTag override if this navigation bar does not '
'transition due to transitionBetweenRoutes = false.', 'transition due to transitionBetweenRoutes = false.',
...@@ -599,9 +591,7 @@ class CupertinoSliverNavigationBar extends StatefulWidget { ...@@ -599,9 +591,7 @@ class CupertinoSliverNavigationBar extends StatefulWidget {
this.transitionBetweenRoutes = true, this.transitionBetweenRoutes = true,
this.heroTag = _defaultHeroTag, this.heroTag = _defaultHeroTag,
this.stretch = false, this.stretch = false,
}) : assert(automaticallyImplyLeading != null), }) : assert(
assert(automaticallyImplyTitle != null),
assert(
automaticallyImplyTitle == true || largeTitle != null, automaticallyImplyTitle == true || largeTitle != null,
'No largeTitle has been provided but automaticallyImplyTitle is also ' 'No largeTitle has been provided but automaticallyImplyTitle is also '
'false. Either provide a largeTitle or set automaticallyImplyTitle to ' 'false. Either provide a largeTitle or set automaticallyImplyTitle to '
...@@ -781,9 +771,7 @@ class _LargeTitleNavigationBarSliverDelegate ...@@ -781,9 +771,7 @@ class _LargeTitleNavigationBarSliverDelegate
required this.persistentHeight, required this.persistentHeight,
required this.alwaysShowMiddle, required this.alwaysShowMiddle,
required this.stretchConfiguration, required this.stretchConfiguration,
}) : assert(persistentHeight != null), });
assert(alwaysShowMiddle != null),
assert(transitionBetweenRoutes != null);
final _NavigationBarStaticComponentsKeys keys; final _NavigationBarStaticComponentsKeys keys;
final _NavigationBarStaticComponents components; final _NavigationBarStaticComponents components;
...@@ -1626,9 +1614,7 @@ class _TransitionableNavigationBar extends StatelessWidget { ...@@ -1626,9 +1614,7 @@ class _TransitionableNavigationBar extends StatelessWidget {
required this.hasUserMiddle, required this.hasUserMiddle,
required this.largeExpanded, required this.largeExpanded,
required this.child, required this.child,
}) : assert(componentsKeys != null), }) : assert(!largeExpanded || largeTitleTextStyle != null),
assert(largeExpanded != null),
assert(!largeExpanded || largeTitleTextStyle != null),
super(key: componentsKeys.navBarBoxKey); super(key: componentsKeys.navBarBoxKey);
final _NavigationBarStaticComponentsKeys componentsKeys; final _NavigationBarStaticComponentsKeys componentsKeys;
...@@ -2100,7 +2086,7 @@ class _NavigationBarComponentsTransition { ...@@ -2100,7 +2086,7 @@ class _NavigationBarComponentsTransition {
return null; return null;
} }
if (bottomLargeTitle != null && topBackLabel != null) { if (topBackLabel != null) {
// Move from current position to the top page's back label position. // Move from current position to the top page's back label position.
return slideFromLeadingEdge( return slideFromLeadingEdge(
fromKey: bottomComponents.largeTitleKey, fromKey: bottomComponents.largeTitleKey,
...@@ -2127,7 +2113,7 @@ class _NavigationBarComponentsTransition { ...@@ -2127,7 +2113,7 @@ class _NavigationBarComponentsTransition {
); );
} }
if (bottomLargeTitle != null && topLeading != null) { if (topLeading != null) {
// Unlike bottom middle, the bottom large title moves when it can't // Unlike bottom middle, the bottom large title moves when it can't
// transition to the top back label position. // transition to the top back label position.
final RelativeRect from = positionInTransitionBox(bottomComponents.largeTitleKey, from: bottomNavBarBox); final RelativeRect from = positionInTransitionBox(bottomComponents.largeTitleKey, from: bottomNavBarBox);
...@@ -2258,7 +2244,6 @@ class _NavigationBarComponentsTransition { ...@@ -2258,7 +2244,6 @@ class _NavigationBarComponentsTransition {
// text is too long, the topBackLabel will say 'Back' instead of the original // text is too long, the topBackLabel will say 'Back' instead of the original
// text. // text.
if (bottomLargeTitle != null && if (bottomLargeTitle != null &&
topBackLabel != null &&
bottomLargeExpanded) { bottomLargeExpanded) {
return slideFromLeadingEdge( return slideFromLeadingEdge(
fromKey: bottomComponents.largeTitleKey, fromKey: bottomComponents.largeTitleKey,
...@@ -2282,7 +2267,7 @@ class _NavigationBarComponentsTransition { ...@@ -2282,7 +2267,7 @@ class _NavigationBarComponentsTransition {
// The topBackLabel always comes from the large title first if available // The topBackLabel always comes from the large title first if available
// and expanded instead of middle. // and expanded instead of middle.
if (bottomMiddle != null && topBackLabel != null) { if (bottomMiddle != null) {
return slideFromLeadingEdge( return slideFromLeadingEdge(
fromKey: bottomComponents.middleKey, fromKey: bottomComponents.middleKey,
fromNavBarBox: bottomNavBarBox, fromNavBarBox: bottomNavBarBox,
...@@ -2452,10 +2437,6 @@ Widget _navBarHeroFlightShuttleBuilder( ...@@ -2452,10 +2437,6 @@ Widget _navBarHeroFlightShuttleBuilder(
BuildContext fromHeroContext, BuildContext fromHeroContext,
BuildContext toHeroContext, BuildContext toHeroContext,
) { ) {
assert(animation != null);
assert(flightDirection != null);
assert(fromHeroContext != null);
assert(toHeroContext != null);
assert(fromHeroContext.widget is Hero); assert(fromHeroContext.widget is Hero);
assert(toHeroContext.widget is Hero); assert(toHeroContext.widget is Hero);
...@@ -2468,8 +2449,6 @@ Widget _navBarHeroFlightShuttleBuilder( ...@@ -2468,8 +2449,6 @@ Widget _navBarHeroFlightShuttleBuilder(
final _TransitionableNavigationBar fromNavBar = fromHeroWidget.child as _TransitionableNavigationBar; final _TransitionableNavigationBar fromNavBar = fromHeroWidget.child as _TransitionableNavigationBar;
final _TransitionableNavigationBar toNavBar = toHeroWidget.child as _TransitionableNavigationBar; final _TransitionableNavigationBar toNavBar = toHeroWidget.child as _TransitionableNavigationBar;
assert(fromNavBar.componentsKeys != null);
assert(toNavBar.componentsKeys != null);
assert( assert(
fromNavBar.componentsKeys.navBarBoxKey.currentContext!.owner != null, fromNavBar.componentsKeys.navBarBoxKey.currentContext!.owner != null,
......
...@@ -39,8 +39,7 @@ class CupertinoPageScaffold extends StatefulWidget { ...@@ -39,8 +39,7 @@ class CupertinoPageScaffold extends StatefulWidget {
this.backgroundColor, this.backgroundColor,
this.resizeToAvoidBottomInset = true, this.resizeToAvoidBottomInset = true,
required this.child, required this.child,
}) : assert(child != null), });
assert(resizeToAvoidBottomInset != null);
/// The [navigationBar], typically a [CupertinoNavigationBar], is drawn at the /// The [navigationBar], typically a [CupertinoNavigationBar], is drawn at the
/// top of the screen. /// top of the screen.
......
...@@ -83,13 +83,9 @@ class CupertinoPicker extends StatefulWidget { ...@@ -83,13 +83,9 @@ class CupertinoPicker extends StatefulWidget {
required List<Widget> children, required List<Widget> children,
this.selectionOverlay = const CupertinoPickerDefaultSelectionOverlay(), this.selectionOverlay = const CupertinoPickerDefaultSelectionOverlay(),
bool looping = false, bool looping = false,
}) : assert(children != null), }) : assert(diameterRatio > 0.0, RenderListWheelViewport.diameterRatioZeroMessage),
assert(diameterRatio != null),
assert(diameterRatio > 0.0, RenderListWheelViewport.diameterRatioZeroMessage),
assert(magnification > 0), assert(magnification > 0),
assert(itemExtent != null),
assert(itemExtent > 0), assert(itemExtent > 0),
assert(squeeze != null),
assert(squeeze > 0), assert(squeeze > 0),
childDelegate = looping childDelegate = looping
? ListWheelChildLoopingListDelegate(children: children) ? ListWheelChildLoopingListDelegate(children: children)
...@@ -126,13 +122,9 @@ class CupertinoPicker extends StatefulWidget { ...@@ -126,13 +122,9 @@ class CupertinoPicker extends StatefulWidget {
required NullableIndexedWidgetBuilder itemBuilder, required NullableIndexedWidgetBuilder itemBuilder,
int? childCount, int? childCount,
this.selectionOverlay = const CupertinoPickerDefaultSelectionOverlay(), this.selectionOverlay = const CupertinoPickerDefaultSelectionOverlay(),
}) : assert(itemBuilder != null), }) : assert(diameterRatio > 0.0, RenderListWheelViewport.diameterRatioZeroMessage),
assert(diameterRatio != null),
assert(diameterRatio > 0.0, RenderListWheelViewport.diameterRatioZeroMessage),
assert(magnification > 0), assert(magnification > 0),
assert(itemExtent != null),
assert(itemExtent > 0), assert(itemExtent > 0),
assert(squeeze != null),
assert(squeeze > 0), assert(squeeze > 0),
childDelegate = ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount); childDelegate = ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount);
...@@ -254,7 +246,6 @@ class _CupertinoPickerState extends State<CupertinoPicker> { ...@@ -254,7 +246,6 @@ class _CupertinoPickerState extends State<CupertinoPicker> {
hasSuitableHapticHardware = false; hasSuitableHapticHardware = false;
break; break;
} }
assert(hasSuitableHapticHardware != null);
if (hasSuitableHapticHardware && index != _lastHapticIndex) { if (hasSuitableHapticHardware && index != _lastHapticIndex) {
_lastHapticIndex = index; _lastHapticIndex = index;
HapticFeedback.selectionClick(); HapticFeedback.selectionClick();
...@@ -355,9 +346,7 @@ class CupertinoPickerDefaultSelectionOverlay extends StatelessWidget { ...@@ -355,9 +346,7 @@ class CupertinoPickerDefaultSelectionOverlay extends StatelessWidget {
this.background = CupertinoColors.tertiarySystemFill, this.background = CupertinoColors.tertiarySystemFill,
this.capStartEdge = true, this.capStartEdge = true,
this.capEndEdge = true, this.capEndEdge = true,
}) : assert(background != null), });
assert(capStartEdge != null),
assert(capEndEdge != null);
/// Whether to use the default use rounded corners and margin on the start side. /// Whether to use the default use rounded corners and margin on the start side.
final bool capStartEdge; final bool capStartEdge;
......
...@@ -20,9 +20,7 @@ class _CupertinoSliverRefresh extends SingleChildRenderObjectWidget { ...@@ -20,9 +20,7 @@ class _CupertinoSliverRefresh extends SingleChildRenderObjectWidget {
this.refreshIndicatorLayoutExtent = 0.0, this.refreshIndicatorLayoutExtent = 0.0,
this.hasLayoutExtent = false, this.hasLayoutExtent = false,
super.child, super.child,
}) : assert(refreshIndicatorLayoutExtent != null), }) : assert(refreshIndicatorLayoutExtent >= 0.0);
assert(refreshIndicatorLayoutExtent >= 0.0),
assert(hasLayoutExtent != null);
// The amount of space the indicator should occupy in the sliver in a // The amount of space the indicator should occupy in the sliver in a
// resting state when in the refreshing mode. // resting state when in the refreshing mode.
...@@ -61,9 +59,7 @@ class _RenderCupertinoSliverRefresh extends RenderSliver ...@@ -61,9 +59,7 @@ class _RenderCupertinoSliverRefresh extends RenderSliver
required double refreshIndicatorExtent, required double refreshIndicatorExtent,
required bool hasLayoutExtent, required bool hasLayoutExtent,
RenderBox? child, RenderBox? child,
}) : assert(refreshIndicatorExtent != null), }) : assert(refreshIndicatorExtent >= 0.0),
assert(refreshIndicatorExtent >= 0.0),
assert(hasLayoutExtent != null),
_refreshIndicatorExtent = refreshIndicatorExtent, _refreshIndicatorExtent = refreshIndicatorExtent,
_hasLayoutExtent = hasLayoutExtent { _hasLayoutExtent = hasLayoutExtent {
this.child = child; this.child = child;
...@@ -74,7 +70,6 @@ class _RenderCupertinoSliverRefresh extends RenderSliver ...@@ -74,7 +70,6 @@ class _RenderCupertinoSliverRefresh extends RenderSliver
double get refreshIndicatorLayoutExtent => _refreshIndicatorExtent; double get refreshIndicatorLayoutExtent => _refreshIndicatorExtent;
double _refreshIndicatorExtent; double _refreshIndicatorExtent;
set refreshIndicatorLayoutExtent(double value) { set refreshIndicatorLayoutExtent(double value) {
assert(value != null);
assert(value >= 0.0); assert(value >= 0.0);
if (value == _refreshIndicatorExtent) { if (value == _refreshIndicatorExtent) {
return; return;
...@@ -89,7 +84,6 @@ class _RenderCupertinoSliverRefresh extends RenderSliver ...@@ -89,7 +84,6 @@ class _RenderCupertinoSliverRefresh extends RenderSliver
bool get hasLayoutExtent => _hasLayoutExtent; bool get hasLayoutExtent => _hasLayoutExtent;
bool _hasLayoutExtent; bool _hasLayoutExtent;
set hasLayoutExtent(bool value) { set hasLayoutExtent(bool value) {
assert(value != null);
if (value == _hasLayoutExtent) { if (value == _hasLayoutExtent) {
return; return;
} }
...@@ -303,9 +297,7 @@ class CupertinoSliverRefreshControl extends StatefulWidget { ...@@ -303,9 +297,7 @@ class CupertinoSliverRefreshControl extends StatefulWidget {
this.refreshIndicatorExtent = _defaultRefreshIndicatorExtent, this.refreshIndicatorExtent = _defaultRefreshIndicatorExtent,
this.builder = buildRefreshIndicator, this.builder = buildRefreshIndicator,
this.onRefresh, this.onRefresh,
}) : assert(refreshTriggerPullDistance != null), }) : assert(refreshTriggerPullDistance > 0.0),
assert(refreshTriggerPullDistance > 0.0),
assert(refreshIndicatorExtent != null),
assert(refreshIndicatorExtent >= 0.0), assert(refreshIndicatorExtent >= 0.0),
assert( assert(
refreshTriggerPullDistance >= refreshIndicatorExtent, refreshTriggerPullDistance >= refreshIndicatorExtent,
......
...@@ -225,21 +225,11 @@ mixin CupertinoRouteTransitionMixin<T> on PageRoute<T> { ...@@ -225,21 +225,11 @@ mixin CupertinoRouteTransitionMixin<T> on PageRoute<T> {
@override @override
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) { Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
final Widget child = buildContent(context); final Widget child = buildContent(context);
final Widget result = Semantics( return Semantics(
scopesRoute: true, scopesRoute: true,
explicitChildNodes: true, explicitChildNodes: true,
child: child, child: child,
); );
assert(() {
if (child == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('The builder for route "${settings.name}" returned null.'),
ErrorDescription('Route builders must never return null.'),
]);
}
return true;
}());
return result;
} }
// Called by _CupertinoBackGestureDetector when a pop ("back") drag start // Called by _CupertinoBackGestureDetector when a pop ("back") drag start
...@@ -343,9 +333,7 @@ class CupertinoPageRoute<T> extends PageRoute<T> with CupertinoRouteTransitionMi ...@@ -343,9 +333,7 @@ class CupertinoPageRoute<T> extends PageRoute<T> with CupertinoRouteTransitionMi
this.maintainState = true, this.maintainState = true,
super.fullscreenDialog, super.fullscreenDialog,
super.allowSnapshotting = true, super.allowSnapshotting = true,
}) : assert(builder != null), }) {
assert(maintainState != null),
assert(fullscreenDialog != null) {
assert(opaque); assert(opaque);
} }
...@@ -373,8 +361,7 @@ class _PageBasedCupertinoPageRoute<T> extends PageRoute<T> with CupertinoRouteTr ...@@ -373,8 +361,7 @@ class _PageBasedCupertinoPageRoute<T> extends PageRoute<T> with CupertinoRouteTr
_PageBasedCupertinoPageRoute({ _PageBasedCupertinoPageRoute({
required CupertinoPage<T> page, required CupertinoPage<T> page,
super.allowSnapshotting = true, super.allowSnapshotting = true,
}) : assert(page != null), }) : super(settings: page) {
super(settings: page) {
assert(opaque); assert(opaque);
} }
...@@ -424,9 +411,7 @@ class CupertinoPage<T> extends Page<T> { ...@@ -424,9 +411,7 @@ class CupertinoPage<T> extends Page<T> {
super.name, super.name,
super.arguments, super.arguments,
super.restorationId, super.restorationId,
}) : assert(child != null), });
assert(maintainState != null),
assert(fullscreenDialog != null);
/// The content to be shown in the [Route] created by this page. /// The content to be shown in the [Route] created by this page.
final Widget child; final Widget child;
...@@ -468,8 +453,7 @@ class CupertinoPageTransition extends StatelessWidget { ...@@ -468,8 +453,7 @@ class CupertinoPageTransition extends StatelessWidget {
required Animation<double> secondaryRouteAnimation, required Animation<double> secondaryRouteAnimation,
required this.child, required this.child,
required bool linearTransition, required bool linearTransition,
}) : assert(linearTransition != null), }) : _primaryPositionAnimation =
_primaryPositionAnimation =
(linearTransition (linearTransition
? primaryRouteAnimation ? primaryRouteAnimation
: CurvedAnimation( : CurvedAnimation(
...@@ -607,9 +591,7 @@ class _CupertinoBackGestureDetector<T> extends StatefulWidget { ...@@ -607,9 +591,7 @@ class _CupertinoBackGestureDetector<T> extends StatefulWidget {
required this.enabledCallback, required this.enabledCallback,
required this.onStartPopGesture, required this.onStartPopGesture,
required this.child, required this.child,
}) : assert(enabledCallback != null), });
assert(onStartPopGesture != null),
assert(child != null);
final Widget child; final Widget child;
...@@ -731,8 +713,7 @@ class _CupertinoBackGestureController<T> { ...@@ -731,8 +713,7 @@ class _CupertinoBackGestureController<T> {
_CupertinoBackGestureController({ _CupertinoBackGestureController({
required this.navigator, required this.navigator,
required this.controller, required this.controller,
}) : assert(navigator != null), }) {
assert(controller != null) {
navigator.didStartUserGesture(); navigator.didStartUserGesture();
} }
...@@ -854,7 +835,6 @@ class _CupertinoEdgeShadowDecoration extends Decoration { ...@@ -854,7 +835,6 @@ class _CupertinoEdgeShadowDecoration extends Decoration {
_CupertinoEdgeShadowDecoration? b, _CupertinoEdgeShadowDecoration? b,
double t, double t,
) { ) {
assert(t != null);
if (a == null && b == null) { if (a == null && b == null) {
return null; return null;
} }
...@@ -921,8 +901,7 @@ class _CupertinoEdgeShadowPainter extends BoxPainter { ...@@ -921,8 +901,7 @@ class _CupertinoEdgeShadowPainter extends BoxPainter {
_CupertinoEdgeShadowPainter( _CupertinoEdgeShadowPainter(
this._decoration, this._decoration,
super.onChange, super.onChange,
) : assert(_decoration != null), ) : assert(_decoration._colors == null || _decoration._colors!.length > 1);
assert(_decoration._colors == null || _decoration._colors!.length > 1);
final _CupertinoEdgeShadowDecoration _decoration; final _CupertinoEdgeShadowDecoration _decoration;
...@@ -1192,7 +1171,6 @@ Future<T?> showCupertinoModalPopup<T>({ ...@@ -1192,7 +1171,6 @@ Future<T?> showCupertinoModalPopup<T>({
RouteSettings? routeSettings, RouteSettings? routeSettings,
Offset? anchorPoint, Offset? anchorPoint,
}) { }) {
assert(useRootNavigator != null);
return Navigator.of(context, rootNavigator: useRootNavigator).push( return Navigator.of(context, rootNavigator: useRootNavigator).push(
CupertinoModalPopupRoute<T>( CupertinoModalPopupRoute<T>(
builder: builder, builder: builder,
...@@ -1297,8 +1275,6 @@ Future<T?> showCupertinoDialog<T>({ ...@@ -1297,8 +1275,6 @@ Future<T?> showCupertinoDialog<T>({
RouteSettings? routeSettings, RouteSettings? routeSettings,
Offset? anchorPoint, Offset? anchorPoint,
}) { }) {
assert(builder != null);
assert(useRootNavigator != null);
return Navigator.of(context, rootNavigator: useRootNavigator).push<T>(CupertinoDialogRoute<T>( return Navigator.of(context, rootNavigator: useRootNavigator).push<T>(CupertinoDialogRoute<T>(
builder: builder, builder: builder,
...@@ -1361,8 +1337,7 @@ class CupertinoDialogRoute<T> extends RawDialogRoute<T> { ...@@ -1361,8 +1337,7 @@ class CupertinoDialogRoute<T> extends RawDialogRoute<T> {
super.transitionBuilder = _buildCupertinoDialogTransitions, super.transitionBuilder = _buildCupertinoDialogTransitions,
super.settings, super.settings,
super.anchorPoint, super.anchorPoint,
}) : assert(barrierDismissible != null), }) : super(
super(
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) { pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
return builder(context); return builder(context);
}, },
......
...@@ -87,12 +87,8 @@ class CupertinoScrollbar extends RawScrollbar { ...@@ -87,12 +87,8 @@ class CupertinoScrollbar extends RawScrollbar {
'This feature was deprecated after v2.9.0-1.0.pre.', 'This feature was deprecated after v2.9.0-1.0.pre.',
) )
bool? isAlwaysShown, bool? isAlwaysShown,
}) : assert(thickness != null), }) : assert(thickness < double.infinity),
assert(thickness < double.infinity),
assert(thicknessWhileDragging != null),
assert(thicknessWhileDragging < double.infinity), assert(thicknessWhileDragging < double.infinity),
assert(radius != null),
assert(radiusWhileDragging != null),
assert( assert(
isAlwaysShown == null || thumbVisibility == null, isAlwaysShown == null || thumbVisibility == null,
'Scrollbar thumb appearance should only be controlled with thumbVisibility, ' 'Scrollbar thumb appearance should only be controlled with thumbVisibility, '
......
...@@ -126,14 +126,7 @@ class CupertinoSearchTextField extends StatefulWidget { ...@@ -126,14 +126,7 @@ class CupertinoSearchTextField extends StatefulWidget {
this.onTap, this.onTap,
this.autocorrect = true, this.autocorrect = true,
this.enabled, this.enabled,
}) : assert(padding != null), }) : assert(
assert(itemColor != null),
assert(itemSize != null),
assert(prefixInsets != null),
assert(suffixInsets != null),
assert(suffixIcon != null),
assert(suffixMode != null),
assert(
!((decoration != null) && (backgroundColor != null)), !((decoration != null) && (backgroundColor != null)),
'Cannot provide both a background color and a decoration\n' 'Cannot provide both a background color and a decoration\n'
'To provide both, use "decoration: BoxDecoration(color: ' 'To provide both, use "decoration: BoxDecoration(color: '
......
...@@ -99,9 +99,7 @@ class CupertinoSegmentedControl<T extends Object> extends StatefulWidget { ...@@ -99,9 +99,7 @@ class CupertinoSegmentedControl<T extends Object> extends StatefulWidget {
this.borderColor, this.borderColor,
this.pressedColor, this.pressedColor,
this.padding, this.padding,
}) : assert(children != null), }) : assert(children.length >= 2),
assert(children.length >= 2),
assert(onValueChanged != null),
assert( assert(
groupValue == null || children.keys.any((T child) => child == groupValue), groupValue == null || children.keys.any((T child) => child == groupValue),
'The groupValue must be either null or one of the keys in the children map.', 'The groupValue must be either null or one of the keys in the children map.',
...@@ -458,8 +456,7 @@ class _RenderSegmentedControl<T> extends RenderBox ...@@ -458,8 +456,7 @@ class _RenderSegmentedControl<T> extends RenderBox
required TextDirection textDirection, required TextDirection textDirection,
required List<Color> backgroundColors, required List<Color> backgroundColors,
required Color borderColor, required Color borderColor,
}) : assert(textDirection != null), }) : _textDirection = textDirection,
_textDirection = textDirection,
_selectedIndex = selectedIndex, _selectedIndex = selectedIndex,
_pressedIndex = pressedIndex, _pressedIndex = pressedIndex,
_backgroundColors = backgroundColors, _backgroundColors = backgroundColors,
...@@ -685,7 +682,6 @@ class _RenderSegmentedControl<T> extends RenderBox ...@@ -685,7 +682,6 @@ class _RenderSegmentedControl<T> extends RenderBox
} }
void _paintChild(PaintingContext context, Offset offset, RenderBox child, int childIndex) { void _paintChild(PaintingContext context, Offset offset, RenderBox child, int childIndex) {
assert(child != null);
final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData;
...@@ -708,7 +704,6 @@ class _RenderSegmentedControl<T> extends RenderBox ...@@ -708,7 +704,6 @@ class _RenderSegmentedControl<T> extends RenderBox
@override @override
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) { bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
assert(position != null);
RenderBox? child = lastChild; RenderBox? child = lastChild;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData;
......
...@@ -71,12 +71,8 @@ class CupertinoSlider extends StatefulWidget { ...@@ -71,12 +71,8 @@ class CupertinoSlider extends StatefulWidget {
this.divisions, this.divisions,
this.activeColor, this.activeColor,
this.thumbColor = CupertinoColors.white, this.thumbColor = CupertinoColors.white,
}) : assert(value != null), }) : assert(value >= min && value <= max),
assert(min != null), assert(divisions == null || divisions > 0);
assert(max != null),
assert(value >= min && value <= max),
assert(divisions == null || divisions > 0),
assert(thumbColor != null);
/// The currently selected value for this slider. /// The currently selected value for this slider.
/// ///
...@@ -337,9 +333,7 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements MouseTracke ...@@ -337,9 +333,7 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements MouseTracke
required TickerProvider vsync, required TickerProvider vsync,
required TextDirection textDirection, required TextDirection textDirection,
MouseCursor cursor = MouseCursor.defer, MouseCursor cursor = MouseCursor.defer,
}) : assert(value != null && value >= 0.0 && value <= 1.0), }) : assert(value >= 0.0 && value <= 1.0),
assert(textDirection != null),
assert(cursor != null),
_cursor = cursor, _cursor = cursor,
_value = value, _value = value,
_divisions = divisions, _divisions = divisions,
...@@ -363,7 +357,7 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements MouseTracke ...@@ -363,7 +357,7 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements MouseTracke
double get value => _value; double get value => _value;
double _value; double _value;
set value(double newValue) { set value(double newValue) {
assert(newValue != null && newValue >= 0.0 && newValue <= 1.0); assert(newValue >= 0.0 && newValue <= 1.0);
if (newValue == _value) { if (newValue == _value) {
return; return;
} }
...@@ -435,7 +429,6 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements MouseTracke ...@@ -435,7 +429,6 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements MouseTracke
TextDirection get textDirection => _textDirection; TextDirection get textDirection => _textDirection;
TextDirection _textDirection; TextDirection _textDirection;
set textDirection(TextDirection value) { set textDirection(TextDirection value) {
assert(value != null);
if (_textDirection == value) { if (_textDirection == value) {
return; return;
} }
......
...@@ -320,10 +320,7 @@ class CupertinoSlidingSegmentedControl<T> extends StatefulWidget { ...@@ -320,10 +320,7 @@ class CupertinoSlidingSegmentedControl<T> extends StatefulWidget {
this.thumbColor = _kThumbColor, this.thumbColor = _kThumbColor,
this.padding = _kHorizontalItemPadding, this.padding = _kHorizontalItemPadding,
this.backgroundColor = CupertinoColors.tertiarySystemFill, this.backgroundColor = CupertinoColors.tertiarySystemFill,
}) : assert(children != null), }) : assert(children.length >= 2),
assert(children.length >= 2),
assert(padding != null),
assert(onValueChanged != null),
assert( assert(
groupValue == null || children.keys.contains(groupValue), groupValue == null || children.keys.contains(groupValue),
'The groupValue must be either null or one of the keys in the children map.', 'The groupValue must be either null or one of the keys in the children map.',
...@@ -523,7 +520,6 @@ class _SegmentedControlState<T> extends State<CupertinoSlidingSegmentedControl<T ...@@ -523,7 +520,6 @@ class _SegmentedControlState<T> extends State<CupertinoSlidingSegmentedControl<T
// _Segment widget) to make the overall animation look natural when the thumb // _Segment widget) to make the overall animation look natural when the thumb
// is not sliding. // is not sliding.
void _playThumbScaleAnimation({ required bool isExpanding }) { void _playThumbScaleAnimation({ required bool isExpanding }) {
assert(isExpanding != null);
thumbScaleAnimation = thumbScaleController.drive( thumbScaleAnimation = thumbScaleController.drive(
Tween<double>( Tween<double>(
begin: thumbScaleAnimation.value, begin: thumbScaleAnimation.value,
...@@ -793,8 +789,7 @@ class _RenderSegmentedControl<T> extends RenderBox ...@@ -793,8 +789,7 @@ class _RenderSegmentedControl<T> extends RenderBox
required this.state, required this.state,
}) : _highlightedIndex = highlightedIndex, }) : _highlightedIndex = highlightedIndex,
_thumbColor = thumbColor, _thumbColor = thumbColor,
_thumbScale = thumbScale, _thumbScale = thumbScale;
assert(state != null);
final _SegmentedControlState<T> state; final _SegmentedControlState<T> state;
...@@ -1074,13 +1069,11 @@ class _RenderSegmentedControl<T> extends RenderBox ...@@ -1074,13 +1069,11 @@ class _RenderSegmentedControl<T> extends RenderBox
// Paint the separator to the right of the given child. // Paint the separator to the right of the given child.
final Paint separatorPaint = Paint(); final Paint separatorPaint = Paint();
void _paintSeparator(PaintingContext context, Offset offset, RenderBox child) { void _paintSeparator(PaintingContext context, Offset offset, RenderBox child) {
assert(child != null);
final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData;
context.paintChild(child, offset + childParentData.offset); context.paintChild(child, offset + childParentData.offset);
} }
void _paintChild(PaintingContext context, Offset offset, RenderBox child) { void _paintChild(PaintingContext context, Offset offset, RenderBox child) {
assert(child != null);
final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData;
context.paintChild(child, childParentData.offset + offset); context.paintChild(child, childParentData.offset + offset);
} }
...@@ -1119,7 +1112,6 @@ class _RenderSegmentedControl<T> extends RenderBox ...@@ -1119,7 +1112,6 @@ class _RenderSegmentedControl<T> extends RenderBox
@override @override
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) { bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
assert(position != null);
RenderBox? child = lastChild; RenderBox? child = lastChild;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = final _SegmentedControlContainerBoxParentData childParentData =
......
...@@ -76,8 +76,7 @@ class CupertinoSwitch extends StatefulWidget { ...@@ -76,8 +76,7 @@ class CupertinoSwitch extends StatefulWidget {
this.applyTheme, this.applyTheme,
this.focusColor, this.focusColor,
this.dragStartBehavior = DragStartBehavior.start, this.dragStartBehavior = DragStartBehavior.start,
}) : assert(value != null), });
assert(dragStartBehavior != null);
/// Whether this switch is on or off. /// Whether this switch is on or off.
/// ///
...@@ -473,10 +472,7 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { ...@@ -473,10 +472,7 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
required TextDirection textDirection, required TextDirection textDirection,
required bool isFocused, required bool isFocused,
required _CupertinoSwitchState state, required _CupertinoSwitchState state,
}) : assert(value != null), }) : _value = value,
assert(activeColor != null),
assert(state != null),
_value = value,
_activeColor = activeColor, _activeColor = activeColor,
_trackColor = trackColor, _trackColor = trackColor,
_focusColor = focusColor, _focusColor = focusColor,
...@@ -495,7 +491,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { ...@@ -495,7 +491,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
bool get value => _value; bool get value => _value;
bool _value; bool _value;
set value(bool value) { set value(bool value) {
assert(value != null);
if (value == _value) { if (value == _value) {
return; return;
} }
...@@ -506,7 +501,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { ...@@ -506,7 +501,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
Color get activeColor => _activeColor; Color get activeColor => _activeColor;
Color _activeColor; Color _activeColor;
set activeColor(Color value) { set activeColor(Color value) {
assert(value != null);
if (value == _activeColor) { if (value == _activeColor) {
return; return;
} }
...@@ -517,7 +511,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { ...@@ -517,7 +511,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
Color get trackColor => _trackColor; Color get trackColor => _trackColor;
Color _trackColor; Color _trackColor;
set trackColor(Color value) { set trackColor(Color value) {
assert(value != null);
if (value == _trackColor) { if (value == _trackColor) {
return; return;
} }
...@@ -528,7 +521,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { ...@@ -528,7 +521,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
Color get thumbColor => _thumbPainter.color; Color get thumbColor => _thumbPainter.color;
CupertinoThumbPainter _thumbPainter; CupertinoThumbPainter _thumbPainter;
set thumbColor(Color value) { set thumbColor(Color value) {
assert(value != null);
if (value == thumbColor) { if (value == thumbColor) {
return; return;
} }
...@@ -539,7 +531,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { ...@@ -539,7 +531,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
Color get focusColor => _focusColor; Color get focusColor => _focusColor;
Color _focusColor; Color _focusColor;
set focusColor(Color value) { set focusColor(Color value) {
assert(value != null);
if (value == _focusColor) { if (value == _focusColor) {
return; return;
} }
...@@ -564,7 +555,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { ...@@ -564,7 +555,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
TextDirection get textDirection => _textDirection; TextDirection get textDirection => _textDirection;
TextDirection _textDirection; TextDirection _textDirection;
set textDirection(TextDirection value) { set textDirection(TextDirection value) {
assert(value != null);
if (_textDirection == value) { if (_textDirection == value) {
return; return;
} }
...@@ -575,7 +565,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { ...@@ -575,7 +565,6 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
bool get isFocused => _isFocused; bool get isFocused => _isFocused;
bool _isFocused; bool _isFocused;
set isFocused(bool value) { set isFocused(bool value) {
assert(value != null);
if(value == _isFocused) { if(value == _isFocused) {
return; return;
} }
......
...@@ -36,7 +36,6 @@ class CupertinoTabController extends ChangeNotifier { ...@@ -36,7 +36,6 @@ class CupertinoTabController extends ChangeNotifier {
/// greater than or equal to 0, and less than the total number of tabs. /// greater than or equal to 0, and less than the total number of tabs.
CupertinoTabController({ int initialIndex = 0 }) CupertinoTabController({ int initialIndex = 0 })
: _index = initialIndex, : _index = initialIndex,
assert(initialIndex != null),
assert(initialIndex >= 0); assert(initialIndex >= 0);
bool _isDisposed = false; bool _isDisposed = false;
...@@ -52,7 +51,6 @@ class CupertinoTabController extends ChangeNotifier { ...@@ -52,7 +51,6 @@ class CupertinoTabController extends ChangeNotifier {
int get index => _index; int get index => _index;
int _index; int _index;
set index(int value) { set index(int value) {
assert(value != null);
assert(value >= 0); assert(value >= 0);
if (_index == value) { if (_index == value) {
return; return;
...@@ -135,9 +133,7 @@ class CupertinoTabScaffold extends StatefulWidget { ...@@ -135,9 +133,7 @@ class CupertinoTabScaffold extends StatefulWidget {
this.backgroundColor, this.backgroundColor,
this.resizeToAvoidBottomInset = true, this.resizeToAvoidBottomInset = true,
this.restorationId, this.restorationId,
}) : assert(tabBar != null), }) : assert(
assert(tabBuilder != null),
assert(
controller == null || controller.index < tabBar.items.length, controller == null || controller.index < tabBar.items.length,
"The CupertinoTabController's current index ${controller.index} is " "The CupertinoTabController's current index ${controller.index} is "
'out of bounds for the tab bar with ${tabBar.items.length} tabs', 'out of bounds for the tab bar with ${tabBar.items.length} tabs',
...@@ -324,12 +320,10 @@ class _CupertinoTabScaffoldState extends State<CupertinoTabScaffold> with Restor ...@@ -324,12 +320,10 @@ class _CupertinoTabScaffoldState extends State<CupertinoTabScaffold> with Restor
contentPadding = EdgeInsets.only(bottom: existingMediaQuery.viewInsets.bottom); contentPadding = EdgeInsets.only(bottom: existingMediaQuery.viewInsets.bottom);
} }
if (widget.tabBar != null && // Only pad the content with the height of the tab bar if the tab
// Only pad the content with the height of the tab bar if the tab // isn't already entirely obstructed by a keyboard or other view insets.
// isn't already entirely obstructed by a keyboard or other view insets. // Don't double pad.
// Don't double pad. if (!widget.resizeToAvoidBottomInset || widget.tabBar.preferredSize.height > existingMediaQuery.viewInsets.bottom) {
(!widget.resizeToAvoidBottomInset ||
widget.tabBar.preferredSize.height > existingMediaQuery.viewInsets.bottom)) {
// TODO(xster): Use real size after partial layout instead of preferred size. // TODO(xster): Use real size after partial layout instead of preferred size.
// https://github.com/flutter/flutter/issues/12912 // https://github.com/flutter/flutter/issues/12912
final double bottomPadding = final double bottomPadding =
...@@ -406,9 +400,7 @@ class _TabSwitchingView extends StatefulWidget { ...@@ -406,9 +400,7 @@ class _TabSwitchingView extends StatefulWidget {
required this.currentTabIndex, required this.currentTabIndex,
required this.tabCount, required this.tabCount,
required this.tabBuilder, required this.tabBuilder,
}) : assert(currentTabIndex != null), }) : assert(tabCount > 0);
assert(tabCount != null && tabCount > 0),
assert(tabBuilder != null);
final int currentTabIndex; final int currentTabIndex;
final int tabCount; final int tabCount;
...@@ -530,8 +522,7 @@ class RestorableCupertinoTabController extends RestorableChangeNotifier<Cupertin ...@@ -530,8 +522,7 @@ class RestorableCupertinoTabController extends RestorableChangeNotifier<Cupertin
/// The `initialIndex` must not be null and defaults to 0. The value must be /// The `initialIndex` must not be null and defaults to 0. The value must be
/// greater than or equal to 0, and less than the total number of tabs. /// greater than or equal to 0, and less than the total number of tabs.
RestorableCupertinoTabController({ int initialIndex = 0 }) RestorableCupertinoTabController({ int initialIndex = 0 })
: assert(initialIndex != null), : assert(initialIndex >= 0),
assert(initialIndex >= 0),
_initialIndex = initialIndex; _initialIndex = initialIndex;
final int _initialIndex; final int _initialIndex;
......
...@@ -50,7 +50,7 @@ class CupertinoTabView extends StatefulWidget { ...@@ -50,7 +50,7 @@ class CupertinoTabView extends StatefulWidget {
this.onUnknownRoute, this.onUnknownRoute,
this.navigatorObservers = const <NavigatorObserver>[], this.navigatorObservers = const <NavigatorObserver>[],
this.restorationScopeId, this.restorationScopeId,
}) : assert(navigatorObservers != null); });
/// The widget builder for the default route of the tab view /// The widget builder for the default route of the tab view
/// ([Navigator.defaultRouteName], which is `/`). /// ([Navigator.defaultRouteName], which is `/`).
......
...@@ -281,35 +281,21 @@ class CupertinoTextField extends StatefulWidget { ...@@ -281,35 +281,21 @@ class CupertinoTextField extends StatefulWidget {
this.contextMenuBuilder = _defaultContextMenuBuilder, this.contextMenuBuilder = _defaultContextMenuBuilder,
this.spellCheckConfiguration, this.spellCheckConfiguration,
this.magnifierConfiguration, this.magnifierConfiguration,
}) : assert(textAlign != null), }) : assert(obscuringCharacter.length == 1),
assert(readOnly != null),
assert(autofocus != null),
assert(obscuringCharacter != null && obscuringCharacter.length == 1),
assert(obscureText != null),
assert(autocorrect != null),
smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled), smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled), smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
assert(enableSuggestions != null),
assert(scrollPadding != null),
assert(dragStartBehavior != null),
assert(selectionHeightStyle != null),
assert(selectionWidthStyle != null),
assert(maxLines == null || maxLines > 0), assert(maxLines == null || maxLines > 0),
assert(minLines == null || minLines > 0), assert(minLines == null || minLines > 0),
assert( assert(
(maxLines == null) || (minLines == null) || (maxLines >= minLines), (maxLines == null) || (minLines == null) || (maxLines >= minLines),
"minLines can't be greater than maxLines", "minLines can't be greater than maxLines",
), ),
assert(expands != null),
assert( assert(
!expands || (maxLines == null && minLines == null), !expands || (maxLines == null && minLines == null),
'minLines and maxLines must be null when expands is true.', 'minLines and maxLines must be null when expands is true.',
), ),
assert(!obscureText || maxLines == 1, 'Obscured fields cannot be multiline.'), assert(!obscureText || maxLines == 1, 'Obscured fields cannot be multiline.'),
assert(maxLength == null || maxLength > 0), assert(maxLength == null || maxLength > 0),
assert(clearButtonMode != null),
assert(prefixMode != null),
assert(suffixMode != null),
// Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set. // Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set.
assert( assert(
!identical(textInputAction, TextInputAction.newline) || !identical(textInputAction, TextInputAction.newline) ||
...@@ -317,7 +303,6 @@ class CupertinoTextField extends StatefulWidget { ...@@ -317,7 +303,6 @@ class CupertinoTextField extends StatefulWidget {
!identical(keyboardType, TextInputType.text), !identical(keyboardType, TextInputType.text),
'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.', 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.',
), ),
assert(enableIMEPersonalizedLearning != null),
keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline), keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline),
enableInteractiveSelection = enableInteractiveSelection ?? (!readOnly || !obscureText); enableInteractiveSelection = enableInteractiveSelection ?? (!readOnly || !obscureText);
...@@ -425,35 +410,21 @@ class CupertinoTextField extends StatefulWidget { ...@@ -425,35 +410,21 @@ class CupertinoTextField extends StatefulWidget {
this.contextMenuBuilder = _defaultContextMenuBuilder, this.contextMenuBuilder = _defaultContextMenuBuilder,
this.spellCheckConfiguration, this.spellCheckConfiguration,
this.magnifierConfiguration, this.magnifierConfiguration,
}) : assert(textAlign != null), }) : assert(obscuringCharacter.length == 1),
assert(readOnly != null),
assert(autofocus != null),
assert(obscuringCharacter != null && obscuringCharacter.length == 1),
assert(obscureText != null),
assert(autocorrect != null),
smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled), smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled), smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
assert(enableSuggestions != null),
assert(scrollPadding != null),
assert(dragStartBehavior != null),
assert(selectionHeightStyle != null),
assert(selectionWidthStyle != null),
assert(maxLines == null || maxLines > 0), assert(maxLines == null || maxLines > 0),
assert(minLines == null || minLines > 0), assert(minLines == null || minLines > 0),
assert( assert(
(maxLines == null) || (minLines == null) || (maxLines >= minLines), (maxLines == null) || (minLines == null) || (maxLines >= minLines),
"minLines can't be greater than maxLines", "minLines can't be greater than maxLines",
), ),
assert(expands != null),
assert( assert(
!expands || (maxLines == null && minLines == null), !expands || (maxLines == null && minLines == null),
'minLines and maxLines must be null when expands is true.', 'minLines and maxLines must be null when expands is true.',
), ),
assert(!obscureText || maxLines == 1, 'Obscured fields cannot be multiline.'), assert(!obscureText || maxLines == 1, 'Obscured fields cannot be multiline.'),
assert(maxLength == null || maxLength > 0), assert(maxLength == null || maxLength > 0),
assert(clearButtonMode != null),
assert(prefixMode != null),
assert(suffixMode != null),
// Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set. // Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set.
assert( assert(
!identical(textInputAction, TextInputAction.newline) || !identical(textInputAction, TextInputAction.newline) ||
...@@ -461,8 +432,6 @@ class CupertinoTextField extends StatefulWidget { ...@@ -461,8 +432,6 @@ class CupertinoTextField extends StatefulWidget {
!identical(keyboardType, TextInputType.text), !identical(keyboardType, TextInputType.text),
'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.', 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.',
), ),
assert(clipBehavior != null),
assert(enableIMEPersonalizedLearning != null),
keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline), keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline),
enableInteractiveSelection = enableInteractiveSelection ?? (!readOnly || !obscureText); enableInteractiveSelection = enableInteractiveSelection ?? (!readOnly || !obscureText);
...@@ -1102,9 +1071,6 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio ...@@ -1102,9 +1071,6 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
} }
Widget _addTextDependentAttachments(Widget editableText, TextStyle textStyle, TextStyle placeholderStyle) { Widget _addTextDependentAttachments(Widget editableText, TextStyle textStyle, TextStyle placeholderStyle) {
assert(editableText != null);
assert(textStyle != null);
assert(placeholderStyle != null);
// If there are no surrounding widgets, just return the core editable text // If there are no surrounding widgets, just return the core editable text
// part. // part.
if (!_hasDecoration) { if (!_hasDecoration) {
...@@ -1267,7 +1233,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio ...@@ -1267,7 +1233,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
? side ? side
: side.copyWith(color: CupertinoDynamicColor.resolve(side.color, context)); : side.copyWith(color: CupertinoDynamicColor.resolve(side.color, context));
} }
resolvedBorder = border == null || border.runtimeType != Border resolvedBorder = border.runtimeType != Border
? border ? border
: Border( : Border(
top: resolveBorderSide(border.top), top: resolveBorderSide(border.top),
......
...@@ -158,28 +158,19 @@ class CupertinoTextFormFieldRow extends FormField<String> { ...@@ -158,28 +158,19 @@ class CupertinoTextFormFieldRow extends FormField<String> {
), ),
EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder, EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
}) : assert(initialValue == null || controller == null), }) : assert(initialValue == null || controller == null),
assert(textAlign != null), assert(obscuringCharacter.length == 1),
assert(autofocus != null),
assert(readOnly != null),
assert(obscuringCharacter != null && obscuringCharacter.length == 1),
assert(obscureText != null),
assert(autocorrect != null),
assert(enableSuggestions != null),
assert(scrollPadding != null),
assert(maxLines == null || maxLines > 0), assert(maxLines == null || maxLines > 0),
assert(minLines == null || minLines > 0), assert(minLines == null || minLines > 0),
assert( assert(
(maxLines == null) || (minLines == null) || (maxLines >= minLines), (maxLines == null) || (minLines == null) || (maxLines >= minLines),
"minLines can't be greater than maxLines", "minLines can't be greater than maxLines",
), ),
assert(expands != null),
assert( assert(
!expands || (maxLines == null && minLines == null), !expands || (maxLines == null && minLines == null),
'minLines and maxLines must be null when expands is true.', 'minLines and maxLines must be null when expands is true.',
), ),
assert(!obscureText || maxLines == 1, 'Obscured fields cannot be multiline.'), assert(!obscureText || maxLines == 1, 'Obscured fields cannot be multiline.'),
assert(maxLength == null || maxLength > 0), assert(maxLength == null || maxLength > 0),
assert(enableInteractiveSelection != null),
super( super(
initialValue: controller?.text ?? initialValue ?? '', initialValue: controller?.text ?? initialValue ?? '',
builder: (FormFieldState<String> field) { builder: (FormFieldState<String> field) {
......
...@@ -426,8 +426,7 @@ class _CupertinoTextSelectionToolbarContent extends StatefulWidget { ...@@ -426,8 +426,7 @@ class _CupertinoTextSelectionToolbarContent extends StatefulWidget {
required this.isAbove, required this.isAbove,
required this.toolbarBuilder, required this.toolbarBuilder,
required this.children, required this.children,
}) : assert(children != null), }) : assert(children.length > 0);
assert(children.length > 0);
final Offset anchor; final Offset anchor;
final List<Widget> children; final List<Widget> children;
...@@ -533,13 +532,7 @@ class _CupertinoTextSelectionToolbarItems extends RenderObjectWidget { ...@@ -533,13 +532,7 @@ class _CupertinoTextSelectionToolbarItems extends RenderObjectWidget {
required this.dividerWidth, required this.dividerWidth,
required this.nextButton, required this.nextButton,
required this.nextButtonDisabled, required this.nextButtonDisabled,
}) : assert(children != null), }) : assert(children.isNotEmpty);
assert(children.isNotEmpty),
assert(backButton != null),
assert(dividerWidth != null),
assert(nextButton != null),
assert(nextButtonDisabled != null),
assert(page != null);
final Widget backButton; final Widget backButton;
final List<Widget> children; final List<Widget> children;
...@@ -732,9 +725,7 @@ class _RenderCupertinoTextSelectionToolbarItems extends RenderBox with Container ...@@ -732,9 +725,7 @@ class _RenderCupertinoTextSelectionToolbarItems extends RenderBox with Container
_RenderCupertinoTextSelectionToolbarItems({ _RenderCupertinoTextSelectionToolbarItems({
required double dividerWidth, required double dividerWidth,
required int page, required int page,
}) : assert(dividerWidth != null), }) : _dividerWidth = dividerWidth,
assert(page != null),
_dividerWidth = dividerWidth,
_page = page, _page = page,
super(); super();
......
...@@ -42,8 +42,7 @@ class CupertinoTextSelectionToolbarButton extends StatelessWidget { ...@@ -42,8 +42,7 @@ class CupertinoTextSelectionToolbarButton extends StatelessWidget {
super.key, super.key,
this.onPressed, this.onPressed,
required Widget this.child, required Widget this.child,
}) : assert(child != null), }) : text = null,
text = null,
buttonItem = null; buttonItem = null;
/// Create an instance of [CupertinoTextSelectionToolbarButton] whose child is /// Create an instance of [CupertinoTextSelectionToolbarButton] whose child is
...@@ -62,8 +61,7 @@ class CupertinoTextSelectionToolbarButton extends StatelessWidget { ...@@ -62,8 +61,7 @@ class CupertinoTextSelectionToolbarButton extends StatelessWidget {
CupertinoTextSelectionToolbarButton.buttonItem({ CupertinoTextSelectionToolbarButton.buttonItem({
super.key, super.key,
required ContextMenuButtonItem this.buttonItem, required ContextMenuButtonItem this.buttonItem,
}) : assert(buttonItem != null), }) : child = null,
child = null,
text = null, text = null,
onPressed = buttonItem.onPressed; onPressed = buttonItem.onPressed;
......
...@@ -268,8 +268,7 @@ class _TextThemeDefaultsBuilder { ...@@ -268,8 +268,7 @@ class _TextThemeDefaultsBuilder {
const _TextThemeDefaultsBuilder( const _TextThemeDefaultsBuilder(
this.labelColor, this.labelColor,
this.inactiveGrayColor, this.inactiveGrayColor,
) : assert(labelColor != null), );
assert(inactiveGrayColor != null);
final Color labelColor; final Color labelColor;
final Color inactiveGrayColor; final Color inactiveGrayColor;
......
...@@ -53,8 +53,7 @@ class CupertinoTheme extends StatelessWidget { ...@@ -53,8 +53,7 @@ class CupertinoTheme extends StatelessWidget {
super.key, super.key,
required this.data, required this.data,
required this.child, required this.child,
}) : assert(child != null), });
assert(data != null);
/// The [CupertinoThemeData] styling for this theme. /// The [CupertinoThemeData] styling for this theme.
final CupertinoThemeData data; final CupertinoThemeData data;
...@@ -137,7 +136,7 @@ class _InheritedCupertinoTheme extends InheritedWidget { ...@@ -137,7 +136,7 @@ class _InheritedCupertinoTheme extends InheritedWidget {
const _InheritedCupertinoTheme({ const _InheritedCupertinoTheme({
required this.theme, required this.theme,
required super.child, required super.child,
}) : assert(theme != null); });
final CupertinoTheme theme; final CupertinoTheme theme;
...@@ -528,7 +527,6 @@ class _CupertinoTextThemeDefaults { ...@@ -528,7 +527,6 @@ class _CupertinoTextThemeDefaults {
} }
CupertinoTextThemeData createDefaults({ required Color primaryColor }) { CupertinoTextThemeData createDefaults({ required Color primaryColor }) {
assert(primaryColor != null);
return _DefaultCupertinoTextThemeData( return _DefaultCupertinoTextThemeData(
primaryColor: primaryColor, primaryColor: primaryColor,
labelColor: labelColor, labelColor: labelColor,
...@@ -545,9 +543,7 @@ class _DefaultCupertinoTextThemeData extends CupertinoTextThemeData { ...@@ -545,9 +543,7 @@ class _DefaultCupertinoTextThemeData extends CupertinoTextThemeData {
required this.labelColor, required this.labelColor,
required this.inactiveGray, required this.inactiveGray,
required super.primaryColor, required super.primaryColor,
}) : assert(labelColor != null), });
assert(inactiveGray != null),
assert(primaryColor != null);
final Color labelColor; final Color labelColor;
final Color inactiveGray; final Color inactiveGray;
......
...@@ -47,7 +47,7 @@ class CupertinoThumbPainter { ...@@ -47,7 +47,7 @@ class CupertinoThumbPainter {
const CupertinoThumbPainter({ const CupertinoThumbPainter({
this.color = CupertinoColors.white, this.color = CupertinoColors.white,
this.shadows = _kSliderBoxShadows, this.shadows = _kSliderBoxShadows,
}) : assert(shadows != null); });
/// Creates an object that paints an iOS-style switch thumb. /// Creates an object that paints an iOS-style switch thumb.
const CupertinoThumbPainter.switchThumb({ const CupertinoThumbPainter.switchThumb({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment