apply prefer_asserts_in_initializer_list lint (#10463)
This commit is contained in:
parent
fe520201b8
commit
c55097da7d
@ -63,12 +63,11 @@ class MaterialApp extends StatefulWidget {
|
||||
this.checkerboardOffscreenLayers: false,
|
||||
this.showSemanticsDebugger: false,
|
||||
this.debugShowCheckedModeBanner: true
|
||||
}) : super(key: key) {
|
||||
assert(debugShowMaterialGrid != null);
|
||||
assert(routes != null);
|
||||
assert(!routes.containsKey(Navigator.defaultRouteName) || (home == null));
|
||||
assert(routes.containsKey(Navigator.defaultRouteName) || (home != null) || (onGenerateRoute != null));
|
||||
}
|
||||
}) : assert(debugShowMaterialGrid != null),
|
||||
assert(routes != null),
|
||||
assert(!routes.containsKey(Navigator.defaultRouteName) || (home == null)),
|
||||
assert(routes.containsKey(Navigator.defaultRouteName) || (home != null) || (onGenerateRoute != null)),
|
||||
super(key: key);
|
||||
|
||||
/// A one-line description of this app for use in the window manager.
|
||||
final String title;
|
||||
|
@ -138,13 +138,12 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
this.centerTitle,
|
||||
this.toolbarOpacity: 1.0,
|
||||
this.bottomOpacity: 1.0,
|
||||
}) : preferredSize = new Size.fromHeight(kToolbarHeight + (bottom?.preferredSize?.height ?? 0.0)),
|
||||
super(key: key) {
|
||||
assert(elevation != null);
|
||||
assert(primary != null);
|
||||
assert(toolbarOpacity != null);
|
||||
assert(bottomOpacity != null);
|
||||
}
|
||||
}) : assert(elevation != null),
|
||||
assert(primary != null),
|
||||
assert(toolbarOpacity != null),
|
||||
assert(bottomOpacity != null),
|
||||
preferredSize = new Size.fromHeight(kToolbarHeight + (bottom?.preferredSize?.height ?? 0.0)),
|
||||
super(key: key);
|
||||
|
||||
/// A widget to display before the [title].
|
||||
///
|
||||
@ -513,9 +512,8 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
@required this.floating,
|
||||
@required this.pinned,
|
||||
@required this.snapConfiguration,
|
||||
}) : _bottomHeight = bottom?.preferredSize?.height ?? 0.0 {
|
||||
assert(primary || topPadding == 0.0);
|
||||
}
|
||||
}) : assert(primary || topPadding == 0.0),
|
||||
_bottomHeight = bottom?.preferredSize?.height ?? 0.0;
|
||||
|
||||
final Widget leading;
|
||||
final Widget title;
|
||||
|
@ -69,14 +69,13 @@ class BottomNavigationBar extends StatefulWidget {
|
||||
this.type: BottomNavigationBarType.fixed,
|
||||
this.fixedColor,
|
||||
this.iconSize: 24.0,
|
||||
}) : super(key: key) {
|
||||
assert(items != null);
|
||||
assert(items.length >= 2);
|
||||
assert(0 <= currentIndex && currentIndex < items.length);
|
||||
assert(type != null);
|
||||
assert(type == BottomNavigationBarType.fixed || fixedColor == null);
|
||||
assert(iconSize != null);
|
||||
}
|
||||
}) : assert(items != null),
|
||||
assert(items.length >= 2),
|
||||
assert(0 <= currentIndex && currentIndex < items.length),
|
||||
assert(type != null),
|
||||
assert(type == BottomNavigationBarType.fixed || fixedColor == null),
|
||||
assert(iconSize != null),
|
||||
super(key: key);
|
||||
|
||||
/// The interactive items laid out within the bottom navigation bar.
|
||||
final List<BottomNavigationBarItem> items;
|
||||
@ -450,11 +449,9 @@ class _Circle {
|
||||
@required this.index,
|
||||
@required this.color,
|
||||
@required TickerProvider vsync,
|
||||
}) {
|
||||
assert(state != null);
|
||||
assert(index != null);
|
||||
assert(color != null);
|
||||
|
||||
}) : assert(state != null),
|
||||
assert(index != null),
|
||||
assert(color != null) {
|
||||
controller = new AnimationController(
|
||||
duration: kThemeAnimationDuration,
|
||||
vsync: vsync,
|
||||
|
@ -259,14 +259,14 @@ class DataTable extends StatelessWidget {
|
||||
this.sortAscending: true,
|
||||
this.onSelectAll,
|
||||
@required this.rows
|
||||
}) : _onlyTextColumn = _initOnlyTextColumn(columns), super(key: key) {
|
||||
assert(columns != null);
|
||||
assert(columns.isNotEmpty);
|
||||
assert(sortColumnIndex == null || (sortColumnIndex >= 0 && sortColumnIndex < columns.length));
|
||||
assert(sortAscending != null);
|
||||
assert(rows != null);
|
||||
assert(!rows.any((DataRow row) => row.cells.length != columns.length));
|
||||
}
|
||||
}) : assert(columns != null),
|
||||
assert(columns.isNotEmpty),
|
||||
assert(sortColumnIndex == null || (sortColumnIndex >= 0 && sortColumnIndex < columns.length)),
|
||||
assert(sortAscending != null),
|
||||
assert(rows != null),
|
||||
assert(!rows.any((DataRow row) => row.cells.length != columns.length)),
|
||||
_onlyTextColumn = _initOnlyTextColumn(columns),
|
||||
super(key: key);
|
||||
|
||||
/// The configuration and labels for the columns in the table.
|
||||
final List<DataColumn> columns;
|
||||
|
@ -181,14 +181,13 @@ class DayPicker extends StatelessWidget {
|
||||
@required this.lastDate,
|
||||
@required this.displayedMonth,
|
||||
this.selectableDayPredicate,
|
||||
}) : super(key: key) {
|
||||
assert(selectedDate != null);
|
||||
assert(currentDate != null);
|
||||
assert(onChanged != null);
|
||||
assert(displayedMonth != null);
|
||||
assert(!firstDate.isAfter(lastDate));
|
||||
assert(selectedDate.isAfter(firstDate) || selectedDate.isAtSameMomentAs(firstDate));
|
||||
}
|
||||
}) : assert(selectedDate != null),
|
||||
assert(currentDate != null),
|
||||
assert(onChanged != null),
|
||||
assert(displayedMonth != null),
|
||||
assert(!firstDate.isAfter(lastDate)),
|
||||
assert(selectedDate.isAfter(firstDate) || selectedDate.isAtSameMomentAs(firstDate)),
|
||||
super(key: key);
|
||||
|
||||
/// The currently selected date.
|
||||
///
|
||||
@ -331,12 +330,11 @@ class MonthPicker extends StatefulWidget {
|
||||
@required this.firstDate,
|
||||
@required this.lastDate,
|
||||
this.selectableDayPredicate,
|
||||
}) : super(key: key) {
|
||||
assert(selectedDate != null);
|
||||
assert(onChanged != null);
|
||||
assert(!firstDate.isAfter(lastDate));
|
||||
assert(selectedDate.isAfter(firstDate) || selectedDate.isAtSameMomentAs(firstDate));
|
||||
}
|
||||
}) : assert(selectedDate != null),
|
||||
assert(onChanged != null),
|
||||
assert(!firstDate.isAfter(lastDate)),
|
||||
assert(selectedDate.isAfter(firstDate) || selectedDate.isAtSameMomentAs(firstDate)),
|
||||
super(key: key);
|
||||
|
||||
/// The currently selected date.
|
||||
///
|
||||
@ -519,11 +517,10 @@ class YearPicker extends StatefulWidget {
|
||||
@required this.onChanged,
|
||||
@required this.firstDate,
|
||||
@required this.lastDate,
|
||||
}) : super(key: key) {
|
||||
assert(selectedDate != null);
|
||||
assert(onChanged != null);
|
||||
assert(!firstDate.isAfter(lastDate));
|
||||
}
|
||||
}) : assert(selectedDate != null),
|
||||
assert(onChanged != null),
|
||||
assert(!firstDate.isAfter(lastDate)),
|
||||
super(key: key);
|
||||
|
||||
/// The currently selected date.
|
||||
///
|
||||
|
@ -319,9 +319,8 @@ class _DialogRoute<T> extends PopupRoute<T> {
|
||||
@required this.theme,
|
||||
bool barrierDismissible: true,
|
||||
@required this.child,
|
||||
}) : _barrierDismissible = barrierDismissible {
|
||||
assert(barrierDismissible != null);
|
||||
}
|
||||
}) : assert(barrierDismissible != null),
|
||||
_barrierDismissible = barrierDismissible;
|
||||
|
||||
final Widget child;
|
||||
final ThemeData theme;
|
||||
|
@ -266,9 +266,7 @@ class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> {
|
||||
this.elevation: 8,
|
||||
this.theme,
|
||||
@required this.style,
|
||||
}) {
|
||||
assert(style != null);
|
||||
}
|
||||
}) : assert(style != null);
|
||||
|
||||
final List<DropdownMenuItem<T>> items;
|
||||
final Rect buttonRect;
|
||||
@ -425,11 +423,9 @@ class DropdownButton<T> extends StatefulWidget {
|
||||
this.style,
|
||||
this.iconSize: 24.0,
|
||||
this.isDense: false,
|
||||
}) : super(key: key) {
|
||||
assert(items != null);
|
||||
assert(value == null ||
|
||||
items.where((DropdownMenuItem<T> item) => item.value == value).length == 1);
|
||||
}
|
||||
}) : assert(items != null),
|
||||
assert(value == null || items.where((DropdownMenuItem<T> item) => item.value == value).length == 1),
|
||||
super(key: key);
|
||||
|
||||
/// The list of possible items to select among.
|
||||
final List<DropdownMenuItem<T>> items;
|
||||
|
@ -43,11 +43,9 @@ class ExpansionPanel {
|
||||
@required this.headerBuilder,
|
||||
@required this.body,
|
||||
this.isExpanded: false
|
||||
}) {
|
||||
assert(headerBuilder != null);
|
||||
assert(body != null);
|
||||
assert(isExpanded != null);
|
||||
}
|
||||
}) : assert(headerBuilder != null),
|
||||
assert(body != null),
|
||||
assert(isExpanded != null);
|
||||
|
||||
/// The widget builder that builds the expansion panels' header.
|
||||
final ExpansionPanelHeaderBuilder headerBuilder;
|
||||
|
@ -43,13 +43,13 @@ class InkHighlight extends InkFeature {
|
||||
BorderRadius borderRadius,
|
||||
RectCallback rectCallback,
|
||||
VoidCallback onRemoved,
|
||||
}) : _color = color,
|
||||
}) : assert(color != null),
|
||||
assert(shape != null),
|
||||
_color = color,
|
||||
_shape = shape,
|
||||
_borderRadius = borderRadius ?? BorderRadius.zero,
|
||||
_rectCallback = rectCallback,
|
||||
super(controller: controller, referenceBox: referenceBox, onRemoved: onRemoved) {
|
||||
assert(color != null);
|
||||
assert(shape != null);
|
||||
_alphaController = new AnimationController(duration: _kHighlightFadeDuration, vsync: controller.vsync)
|
||||
..addListener(controller.markNeedsPaint)
|
||||
..addStatusListener(_handleAlphaStatusChanged)
|
||||
|
@ -366,10 +366,9 @@ abstract class InkFeature {
|
||||
@required MaterialInkController controller,
|
||||
@required this.referenceBox,
|
||||
this.onRemoved
|
||||
}) : _controller = controller {
|
||||
assert(_controller != null);
|
||||
assert(referenceBox != null);
|
||||
}
|
||||
}) : assert(controller != null),
|
||||
assert(referenceBox != null),
|
||||
_controller = controller;
|
||||
|
||||
/// The [MaterialInkController] associated with this [InkFeature].
|
||||
///
|
||||
|
@ -61,10 +61,9 @@ class MaterialPageRoute<T> extends PageRoute<T> {
|
||||
RouteSettings settings: const RouteSettings(),
|
||||
this.maintainState: true,
|
||||
this.fullscreenDialog: false,
|
||||
}) : super(settings: settings) {
|
||||
assert(builder != null);
|
||||
assert(opaque);
|
||||
}
|
||||
}) : assert(builder != null),
|
||||
assert(opaque),
|
||||
super(settings: settings);
|
||||
|
||||
/// Builds the primary contents of the route.
|
||||
final WidgetBuilder builder;
|
||||
|
@ -73,21 +73,20 @@ class PaginatedDataTable extends StatefulWidget {
|
||||
this.availableRowsPerPage: const <int>[defaultRowsPerPage, defaultRowsPerPage * 2, defaultRowsPerPage * 5, defaultRowsPerPage * 10],
|
||||
this.onRowsPerPageChanged,
|
||||
@required this.source
|
||||
}) : super(key: key) {
|
||||
assert(header != null);
|
||||
assert(columns != null);
|
||||
assert(columns.isNotEmpty);
|
||||
assert(sortColumnIndex == null || (sortColumnIndex >= 0 && sortColumnIndex < columns.length));
|
||||
assert(sortAscending != null);
|
||||
assert(rowsPerPage != null);
|
||||
assert(rowsPerPage > 0);
|
||||
assert(() {
|
||||
if (onRowsPerPageChanged != null)
|
||||
assert(availableRowsPerPage != null && availableRowsPerPage.contains(rowsPerPage));
|
||||
return true;
|
||||
});
|
||||
assert(source != null);
|
||||
}
|
||||
}) : assert(header != null),
|
||||
assert(columns != null),
|
||||
assert(columns.isNotEmpty),
|
||||
assert(sortColumnIndex == null || (sortColumnIndex >= 0 && sortColumnIndex < columns.length)),
|
||||
assert(sortAscending != null),
|
||||
assert(rowsPerPage != null),
|
||||
assert(rowsPerPage > 0),
|
||||
assert(() {
|
||||
if (onRowsPerPageChanged != null)
|
||||
assert(availableRowsPerPage != null && availableRowsPerPage.contains(rowsPerPage));
|
||||
return true;
|
||||
}),
|
||||
assert(source != null),
|
||||
super(key: key);
|
||||
|
||||
/// The table card's header.
|
||||
///
|
||||
|
@ -84,8 +84,8 @@ class _ScrollbarState extends State<Scrollbar> with TickerProviderStateMixin {
|
||||
}
|
||||
|
||||
class _ScrollbarPainter extends ChangeNotifier implements CustomPainter {
|
||||
_ScrollbarPainter(TickerProvider vsync) {
|
||||
assert(vsync != null);
|
||||
_ScrollbarPainter(TickerProvider vsync)
|
||||
: assert(vsync != null) {
|
||||
_fadeController = new AnimationController(duration: _kThumbFadeDuration, vsync: vsync);
|
||||
_opacity = new CurvedAnimation(parent: _fadeController, curve: Curves.fastOutSlowIn)
|
||||
..addListener(notifyListeners);
|
||||
|
@ -280,12 +280,12 @@ class _RenderSlider extends RenderBox implements SemanticsActionHandler {
|
||||
TextTheme textTheme,
|
||||
this.onChanged,
|
||||
TickerProvider vsync,
|
||||
}) : _value = value,
|
||||
}) : assert(value != null && value >= 0.0 && value <= 1.0),
|
||||
_value = value,
|
||||
_divisions = divisions,
|
||||
_activeColor = activeColor,
|
||||
_thumbOpenAtMin = thumbOpenAtMin,
|
||||
_textTheme = textTheme {
|
||||
assert(value != null && value >= 0.0 && value <= 1.0);
|
||||
this.label = label;
|
||||
final GestureArenaTeam team = new GestureArenaTeam();
|
||||
_drag = new HorizontalDragGestureRecognizer()
|
||||
|
@ -140,12 +140,11 @@ class Stepper extends StatefulWidget {
|
||||
this.onStepTapped,
|
||||
this.onStepContinue,
|
||||
this.onStepCancel,
|
||||
}) : super(key: key) {
|
||||
assert(steps != null);
|
||||
assert(type != null);
|
||||
assert(currentStep != null);
|
||||
assert(0 <= currentStep && currentStep < steps.length);
|
||||
}
|
||||
}) : assert(steps != null),
|
||||
assert(type != null),
|
||||
assert(currentStep != null),
|
||||
assert(0 <= currentStep && currentStep < steps.length),
|
||||
super(key: key);
|
||||
|
||||
/// The steps of the stepper whose titles, subtitles, icons always get shown.
|
||||
///
|
||||
|
@ -63,16 +63,15 @@ import 'constants.dart';
|
||||
class TabController extends ChangeNotifier {
|
||||
/// Creates an object that manages the state required by [TabBar] and a [TabBarView].
|
||||
TabController({ int initialIndex: 0, @required this.length, @required TickerProvider vsync })
|
||||
: _index = initialIndex,
|
||||
: assert(length != null && length > 1),
|
||||
assert(initialIndex != null && initialIndex >= 0 && initialIndex < length),
|
||||
_index = initialIndex,
|
||||
_previousIndex = initialIndex,
|
||||
_animationController = new AnimationController(
|
||||
value: initialIndex.toDouble(),
|
||||
upperBound: (length - 1).toDouble(),
|
||||
vsync: vsync
|
||||
) {
|
||||
assert(length != null && length > 1);
|
||||
assert(initialIndex != null && initialIndex >= 0 && initialIndex < length);
|
||||
}
|
||||
);
|
||||
|
||||
/// An animation whose value represents the current position of the [TabBar]'s
|
||||
/// selected tab indicator as well as the scrollOffsets of the [TabBar]
|
||||
|
@ -155,16 +155,15 @@ class _TabLabelBarRenderer extends RenderFlex {
|
||||
CrossAxisAlignment crossAxisAlignment,
|
||||
TextBaseline textBaseline,
|
||||
@required this.onPerformLayout,
|
||||
}) : super(
|
||||
children: children,
|
||||
direction: direction,
|
||||
mainAxisSize: mainAxisSize,
|
||||
mainAxisAlignment: mainAxisAlignment,
|
||||
crossAxisAlignment: crossAxisAlignment,
|
||||
textBaseline: textBaseline,
|
||||
) {
|
||||
assert(onPerformLayout != null);
|
||||
}
|
||||
}) : assert(onPerformLayout != null),
|
||||
super(
|
||||
children: children,
|
||||
direction: direction,
|
||||
mainAxisSize: mainAxisSize,
|
||||
mainAxisAlignment: mainAxisAlignment,
|
||||
crossAxisAlignment: crossAxisAlignment,
|
||||
textBaseline: textBaseline,
|
||||
);
|
||||
|
||||
ValueChanged<List<double>> onPerformLayout;
|
||||
|
||||
@ -411,10 +410,9 @@ class TabBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
this.labelStyle,
|
||||
this.unselectedLabelColor,
|
||||
this.unselectedLabelStyle,
|
||||
}) : super(key: key) {
|
||||
assert(tabs != null && tabs.length > 1);
|
||||
assert(isScrollable != null);
|
||||
}
|
||||
}) : assert(tabs != null && tabs.length > 1),
|
||||
assert(isScrollable != null),
|
||||
super(key: key);
|
||||
|
||||
/// Typically a list of [Tab] widgets.
|
||||
final List<Widget> tabs;
|
||||
@ -741,9 +739,8 @@ class TabBarView extends StatefulWidget {
|
||||
Key key,
|
||||
@required this.children,
|
||||
this.controller,
|
||||
}) : super(key: key) {
|
||||
assert(children != null && children.length > 1);
|
||||
}
|
||||
}) : assert(children != null && children.length > 1),
|
||||
super(key: key);
|
||||
|
||||
/// This widget's selection and animation state.
|
||||
///
|
||||
|
@ -30,16 +30,16 @@ abstract class RenderToggleable extends RenderConstrainedBox implements Semantic
|
||||
@required Color inactiveColor,
|
||||
ValueChanged<bool> onChanged,
|
||||
@required TickerProvider vsync,
|
||||
}) : _value = value,
|
||||
}) : assert(value != null),
|
||||
assert(activeColor != null),
|
||||
assert(inactiveColor != null),
|
||||
assert(vsync != null),
|
||||
_value = value,
|
||||
_activeColor = activeColor,
|
||||
_inactiveColor = inactiveColor,
|
||||
_onChanged = onChanged,
|
||||
_vsync = vsync,
|
||||
super(additionalConstraints: new BoxConstraints.tight(size)) {
|
||||
assert(value != null);
|
||||
assert(activeColor != null);
|
||||
assert(inactiveColor != null);
|
||||
assert(vsync != null);
|
||||
_tap = new TapGestureRecognizer()
|
||||
..onTapDown = _handleTapDown
|
||||
..onTap = _handleTap
|
||||
|
Loading…
x
Reference in New Issue
Block a user