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