diff --git a/packages/flutter/lib/src/material/app.dart b/packages/flutter/lib/src/material/app.dart index 17b34c1697..425944da85 100644 --- a/packages/flutter/lib/src/material/app.dart +++ b/packages/flutter/lib/src/material/app.dart @@ -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; diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index c11f6e437f..09fd27d258 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -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; diff --git a/packages/flutter/lib/src/material/bottom_navigation_bar.dart b/packages/flutter/lib/src/material/bottom_navigation_bar.dart index 5fba485268..011848688f 100644 --- a/packages/flutter/lib/src/material/bottom_navigation_bar.dart +++ b/packages/flutter/lib/src/material/bottom_navigation_bar.dart @@ -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 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, diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index 2730acb78e..040d0dcfcf 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -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 columns; diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index c60a738c6d..14cb455277 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -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. /// diff --git a/packages/flutter/lib/src/material/dialog.dart b/packages/flutter/lib/src/material/dialog.dart index 33b568d802..c4bc60fc01 100644 --- a/packages/flutter/lib/src/material/dialog.dart +++ b/packages/flutter/lib/src/material/dialog.dart @@ -319,9 +319,8 @@ class _DialogRoute extends PopupRoute { @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; diff --git a/packages/flutter/lib/src/material/dropdown.dart b/packages/flutter/lib/src/material/dropdown.dart index 627f8dcd2a..b0ff98253e 100644 --- a/packages/flutter/lib/src/material/dropdown.dart +++ b/packages/flutter/lib/src/material/dropdown.dart @@ -266,9 +266,7 @@ class _DropdownRoute extends PopupRoute<_DropdownRouteResult> { this.elevation: 8, this.theme, @required this.style, - }) { - assert(style != null); - } + }) : assert(style != null); final List> items; final Rect buttonRect; @@ -425,11 +423,9 @@ class DropdownButton extends StatefulWidget { this.style, this.iconSize: 24.0, this.isDense: false, - }) : super(key: key) { - assert(items != null); - assert(value == null || - items.where((DropdownMenuItem item) => item.value == value).length == 1); - } + }) : assert(items != null), + assert(value == null || items.where((DropdownMenuItem item) => item.value == value).length == 1), + super(key: key); /// The list of possible items to select among. final List> items; diff --git a/packages/flutter/lib/src/material/expansion_panel.dart b/packages/flutter/lib/src/material/expansion_panel.dart index 2b8a40aa57..39ace45881 100644 --- a/packages/flutter/lib/src/material/expansion_panel.dart +++ b/packages/flutter/lib/src/material/expansion_panel.dart @@ -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; diff --git a/packages/flutter/lib/src/material/ink_highlight.dart b/packages/flutter/lib/src/material/ink_highlight.dart index 29cb6912f1..3130b3d8a9 100644 --- a/packages/flutter/lib/src/material/ink_highlight.dart +++ b/packages/flutter/lib/src/material/ink_highlight.dart @@ -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) diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index 283b5550f0..a03aa5ff6e 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -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]. /// diff --git a/packages/flutter/lib/src/material/page.dart b/packages/flutter/lib/src/material/page.dart index 2a2fb7d442..6ff54e23c9 100644 --- a/packages/flutter/lib/src/material/page.dart +++ b/packages/flutter/lib/src/material/page.dart @@ -61,10 +61,9 @@ class MaterialPageRoute extends PageRoute { 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; diff --git a/packages/flutter/lib/src/material/paginated_data_table.dart b/packages/flutter/lib/src/material/paginated_data_table.dart index c2bee851eb..1c260627ab 100644 --- a/packages/flutter/lib/src/material/paginated_data_table.dart +++ b/packages/flutter/lib/src/material/paginated_data_table.dart @@ -73,21 +73,20 @@ class PaginatedDataTable extends StatefulWidget { this.availableRowsPerPage: const [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. /// diff --git a/packages/flutter/lib/src/material/scrollbar.dart b/packages/flutter/lib/src/material/scrollbar.dart index 6c0859f170..748030761d 100644 --- a/packages/flutter/lib/src/material/scrollbar.dart +++ b/packages/flutter/lib/src/material/scrollbar.dart @@ -84,8 +84,8 @@ class _ScrollbarState extends State 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); diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index e6a8a6826a..213884cdd7 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -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() diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index c2e964c5f5..e83c47e914 100644 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -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. /// diff --git a/packages/flutter/lib/src/material/tab_controller.dart b/packages/flutter/lib/src/material/tab_controller.dart index beafdd7299..ebe89d4082 100644 --- a/packages/flutter/lib/src/material/tab_controller.dart +++ b/packages/flutter/lib/src/material/tab_controller.dart @@ -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] diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index c6ed44bb6e..3b850f41a3 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -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> 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 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. /// diff --git a/packages/flutter/lib/src/material/toggleable.dart b/packages/flutter/lib/src/material/toggleable.dart index 08f1746169..6d65025eeb 100644 --- a/packages/flutter/lib/src/material/toggleable.dart +++ b/packages/flutter/lib/src/material/toggleable.dart @@ -30,16 +30,16 @@ abstract class RenderToggleable extends RenderConstrainedBox implements Semantic @required Color inactiveColor, ValueChanged 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