diff --git a/dev/benchmarks/microbenchmarks/pubspec.yaml b/dev/benchmarks/microbenchmarks/pubspec.yaml index df46d24ad5..8399399284 100644 --- a/dev/benchmarks/microbenchmarks/pubspec.yaml +++ b/dev/benchmarks/microbenchmarks/pubspec.yaml @@ -29,13 +29,15 @@ dependencies: coverage: 0.14.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" csslib: 0.16.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + dart_style: 1.3.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" fake_async: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" html: 0.14.0+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.17.0-nullsafety.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.16.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl_translation: 0.17.10+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" isolate: 2.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.3-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -48,6 +50,7 @@ dependencies: package_config: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.8.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.10.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + petitparser: 3.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf: 0.7.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -74,4 +77,4 @@ dependencies: flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 2c1c +# PUBSPEC CHECKSUM: 77af diff --git a/dev/benchmarks/test_apps/stocks/pubspec.yaml b/dev/benchmarks/test_apps/stocks/pubspec.yaml index 0d1bbc19ec..bc7782a318 100644 --- a/dev/benchmarks/test_apps/stocks/pubspec.yaml +++ b/dev/benchmarks/test_apps/stocks/pubspec.yaml @@ -9,23 +9,42 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter - intl: 0.17.0-nullsafety.2 + intl: 0.16.1 + intl_translation: 0.17.10+1 http: 0.12.2 isolate: 2.0.3 + _fe_analyzer_shared: 7.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.39.17 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + args: 1.6.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" characters: 1.1.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + cli_util: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.15.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + crypto: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + csslib: 0.16.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + dart_style: 1.3.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + glob: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + html: 0.14.0+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + js: 0.6.3-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.3.0-nullsafety.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + node_interop: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + node_io: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + package_config: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.8.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.10.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + petitparser: 3.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + pub_semver: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.8.0-nullsafety.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.3.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.1.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + watcher: 0.9.7+15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + yaml: 2.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: flutter_test: @@ -34,33 +53,19 @@ dev_dependencies: sdk: flutter test: 1.16.0-nullsafety.9 - _fe_analyzer_shared: 7.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - analyzer: 0.39.17 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" archive: 2.0.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - args: 1.6.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - cli_util: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" coverage: 0.14.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - crypto: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.16.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" fake_async: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 6.0.0-nullsafety.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - glob: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.14.0+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - js: 0.6.3-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" logging: 0.11.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" matcher: 0.12.10-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - node_interop: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - node_io: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - package_config: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - pub_semver: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf: 0.7.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -73,13 +78,11 @@ dev_dependencies: test_api: 0.2.19-nullsafety.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_core: 0.3.12-nullsafety.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vm_service: 5.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - watcher: 0.9.7+15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" web_socket_channel: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" webdriver: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" webkit_inspection_protocol: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - yaml: 2.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 4b8b +# PUBSPEC CHECKSUM: b21f diff --git a/dev/integration_tests/flutter_gallery/lib/demo/animation/home.dart b/dev/integration_tests/flutter_gallery/lib/demo/animation/home.dart index e8eb5e04ed..c2bd940d2a 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/animation/home.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/animation/home.dart @@ -32,10 +32,10 @@ const double _kAppBarMidHeight = 256.0; // TODO(hansmuller): it would be worth adding something like this to the framework. class _RenderStatusBarPaddingSliver extends RenderSliver { _RenderStatusBarPaddingSliver({ - required double maxHeight, - required double scrollFactor, - }) : assert(maxHeight >= 0.0), - assert(scrollFactor >= 1.0), + @required double maxHeight, + @required double scrollFactor, + }) : assert(maxHeight != null && maxHeight >= 0.0), + assert(scrollFactor != null && scrollFactor >= 1.0), _maxHeight = maxHeight, _scrollFactor = scrollFactor; @@ -43,7 +43,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver { double get maxHeight => _maxHeight; double _maxHeight; set maxHeight(double value) { - assert(maxHeight >= 0.0); + assert(maxHeight != null && maxHeight >= 0.0); if (_maxHeight == value) return; _maxHeight = value; @@ -55,7 +55,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver { double get scrollFactor => _scrollFactor; double _scrollFactor; set scrollFactor(double value) { - assert(scrollFactor >= 1.0); + assert(scrollFactor != null && scrollFactor >= 1.0); if (_scrollFactor == value) return; _scrollFactor = value; @@ -64,7 +64,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver { @override void performLayout() { - final double height = (maxHeight - constraints.scrollOffset / scrollFactor).clamp(0.0, maxHeight); + final double height = (maxHeight - constraints.scrollOffset / scrollFactor).clamp(0.0, maxHeight) as double; geometry = SliverGeometry( paintExtent: math.min(height, constraints.remainingPaintExtent), scrollExtent: maxHeight, @@ -75,11 +75,11 @@ class _RenderStatusBarPaddingSliver extends RenderSliver { class _StatusBarPaddingSliver extends SingleChildRenderObjectWidget { const _StatusBarPaddingSliver({ - Key? key, - required this.maxHeight, + Key key, + @required this.maxHeight, this.scrollFactor = 5.0, - }) : assert(maxHeight >= 0.0), - assert(scrollFactor >= 1.0), + }) : assert(maxHeight != null && maxHeight >= 0.0), + assert(scrollFactor != null && scrollFactor >= 1.0), super(key: key); final double maxHeight; @@ -110,9 +110,9 @@ class _StatusBarPaddingSliver extends SingleChildRenderObjectWidget { class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { _SliverAppBarDelegate({ - required this.minHeight, - required this.maxHeight, - required this.child, + @required this.minHeight, + @required this.maxHeight, + @required this.child, }); final double minHeight; @@ -170,51 +170,51 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate { this.selectedIndex, }); - final Alignment? translation; - final double? tColumnToRow; - final double? tCollapsed; - final int? cardCount; - final double? selectedIndex; + final Alignment translation; + final double tColumnToRow; + final double tCollapsed; + final int cardCount; + final double selectedIndex; - Rect? _interpolateRect(Rect begin, Rect end) { - return Rect.lerp(begin, end, tColumnToRow!); + Rect _interpolateRect(Rect begin, Rect end) { + return Rect.lerp(begin, end, tColumnToRow); } - Offset? _interpolatePoint(Offset begin, Offset end) { - return Offset.lerp(begin, end, tColumnToRow!); + Offset _interpolatePoint(Offset begin, Offset end) { + return Offset.lerp(begin, end, tColumnToRow); } @override void performLayout(Size size) { final double columnCardX = size.width / 5.0; final double columnCardWidth = size.width - columnCardX; - final double columnCardHeight = size.height / cardCount!; + final double columnCardHeight = size.height / cardCount; final double rowCardWidth = size.width; - final Offset offset = translation!.alongSize(size); + final Offset offset = translation.alongSize(size); double columnCardY = 0.0; - double rowCardX = -(selectedIndex! * rowCardWidth); + double rowCardX = -(selectedIndex * rowCardWidth); // When tCollapsed > 0 the titles spread apart final double columnTitleX = size.width / 10.0; - final double rowTitleWidth = size.width * ((1 + tCollapsed!) / 2.25); - double rowTitleX = (size.width - rowTitleWidth) / 2.0 - selectedIndex! * rowTitleWidth; + final double rowTitleWidth = size.width * ((1 + tCollapsed) / 2.25); + double rowTitleX = (size.width - rowTitleWidth) / 2.0 - selectedIndex * rowTitleWidth; // When tCollapsed > 0, the indicators move closer together //final double rowIndicatorWidth = 48.0 + (1.0 - tCollapsed) * (rowTitleWidth - 48.0); const double paddedSectionIndicatorWidth = kSectionIndicatorWidth + 8.0; final double rowIndicatorWidth = paddedSectionIndicatorWidth + - (1.0 - tCollapsed!) * (rowTitleWidth - paddedSectionIndicatorWidth); - double rowIndicatorX = (size.width - rowIndicatorWidth) / 2.0 - selectedIndex! * rowIndicatorWidth; + (1.0 - tCollapsed) * (rowTitleWidth - paddedSectionIndicatorWidth); + double rowIndicatorX = (size.width - rowIndicatorWidth) / 2.0 - selectedIndex * rowIndicatorWidth; // Compute the size and origin of each card, title, and indicator for the maxHeight // "column" layout, and the midHeight "row" layout. The actual layout is just the // interpolated value between the column and row layouts for t. - for (int index = 0; index < cardCount!; index++) { + for (int index = 0; index < cardCount; index++) { // Layout the card for index. final Rect columnCardRect = Rect.fromLTWH(columnCardX, columnCardY, columnCardWidth, columnCardHeight); final Rect rowCardRect = Rect.fromLTWH(rowCardX, 0.0, rowCardWidth, size.height); - final Rect cardRect = _interpolateRect(columnCardRect, rowCardRect)!.shift(offset); + final Rect cardRect = _interpolateRect(columnCardRect, rowCardRect).shift(offset); final String cardId = 'card$index'; if (hasChild(cardId)) { layoutChild(cardId, BoxConstraints.tight(cardRect.size)); @@ -228,7 +228,7 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate { final double centeredRowTitleX = rowTitleX + (rowTitleWidth - titleSize.width) / 2.0; final Offset columnTitleOrigin = Offset(columnTitleX, columnTitleY); final Offset rowTitleOrigin = Offset(centeredRowTitleX, rowTitleY); - final Offset titleOrigin = _interpolatePoint(columnTitleOrigin, rowTitleOrigin)!; + final Offset titleOrigin = _interpolatePoint(columnTitleOrigin, rowTitleOrigin); positionChild('title$index', titleOrigin + offset); // Layout the selection indicator for index. @@ -240,7 +240,7 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate { final double centeredRowIndicatorX = rowIndicatorX + (rowIndicatorWidth - indicatorSize.width) / 2.0; final double rowIndicatorY = titleRect.bottomCenter.dy + 16.0; final Offset rowIndicatorOrigin = Offset(centeredRowIndicatorX, rowIndicatorY); - final Offset indicatorOrigin = _interpolatePoint(columnIndicatorOrigin, rowIndicatorOrigin)!; + final Offset indicatorOrigin = _interpolatePoint(columnIndicatorOrigin, rowIndicatorOrigin); positionChild('indicator$index', indicatorOrigin + offset); columnCardY += columnCardHeight; @@ -260,29 +260,32 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate { class _AllSectionsView extends AnimatedWidget { _AllSectionsView({ - Key? key, - required this.sectionIndex, - required this.sections, - required this.selectedIndex, + Key key, + this.sectionIndex, + @required this.sections, + @required this.selectedIndex, this.minHeight, this.midHeight, this.maxHeight, this.sectionCards = const [], - }) : assert(sectionCards.length == sections.length), + }) : assert(sections != null), + assert(sectionCards != null), + assert(sectionCards.length == sections.length), assert(sectionIndex >= 0 && sectionIndex < sections.length), - assert(selectedIndex.value! >= 0.0 && selectedIndex.value! < sections.length.toDouble()), + assert(selectedIndex != null), + assert(selectedIndex.value >= 0.0 && selectedIndex.value < sections.length.toDouble()), super(key: key, listenable: selectedIndex); final int sectionIndex; final List
sections; - final ValueNotifier selectedIndex; - final double? minHeight; - final double? midHeight; - final double? maxHeight; + final ValueNotifier selectedIndex; + final double minHeight; + final double midHeight; + final double maxHeight; final List sectionCards; double _selectedIndexDelta(int index) { - return (index.toDouble() - selectedIndex.value!).abs().clamp(0.0, 1.0); + return (index.toDouble() - selectedIndex.value).abs().clamp(0.0, 1.0) as double; } Widget _build(BuildContext context, BoxConstraints constraints) { @@ -292,16 +295,16 @@ class _AllSectionsView extends AnimatedWidget { // 0.0 when size.height equals the maxHeight, 1.0 when the size.height // equals the midHeight. final double tColumnToRow = - 1.0 - ((size.height - midHeight!) / - (maxHeight! - midHeight!)).clamp(0.0, 1.0); + 1.0 - ((size.height - midHeight) / + (maxHeight - midHeight)).clamp(0.0, 1.0); // The layout's progress from from the midHeight row layout to // a minHeight row layout. Its value is 0.0 when size.height equals // midHeight and 1.0 when size.height equals minHeight. final double tCollapsed = - 1.0 - ((size.height - minHeight!) / - (midHeight! - minHeight!)).clamp(0.0, 1.0); + 1.0 - ((size.height - minHeight) / + (midHeight - minHeight)).clamp(0.0, 1.0); double _indicatorOpacity(int index) { return 1.0 - _selectedIndexDelta(index) * 0.5; @@ -340,7 +343,7 @@ class _AllSectionsView extends AnimatedWidget { return CustomMultiChildLayout( delegate: _AllSectionsLayout( - translation: Alignment((selectedIndex.value! - sectionIndex) * 2.0 - 1.0, -1.0), + translation: Alignment((selectedIndex.value - sectionIndex) * 2.0 - 1.0, -1.0), tColumnToRow: tColumnToRow, tCollapsed: tCollapsed, cardCount: sections.length, @@ -361,14 +364,15 @@ class _AllSectionsView extends AnimatedWidget { // visible. class _SnappingScrollPhysics extends ClampingScrollPhysics { const _SnappingScrollPhysics({ - ScrollPhysics? parent, - required this.midScrollOffset, - }) : super(parent: parent); + ScrollPhysics parent, + @required this.midScrollOffset, + }) : assert(midScrollOffset != null), + super(parent: parent); final double midScrollOffset; @override - _SnappingScrollPhysics applyTo(ScrollPhysics? ancestor) { + _SnappingScrollPhysics applyTo(ScrollPhysics ancestor) { return _SnappingScrollPhysics(parent: buildParent(ancestor), midScrollOffset: midScrollOffset); } @@ -383,8 +387,8 @@ class _SnappingScrollPhysics extends ClampingScrollPhysics { } @override - Simulation? createBallisticSimulation(ScrollMetrics position, double dragVelocity) { - final Simulation? simulation = super.createBallisticSimulation(position, dragVelocity); + Simulation createBallisticSimulation(ScrollMetrics position, double dragVelocity) { + final Simulation simulation = super.createBallisticSimulation(position, dragVelocity); final double offset = position.pixels; if (simulation != null) { @@ -415,7 +419,7 @@ class _SnappingScrollPhysics extends ClampingScrollPhysics { } class AnimationDemoHome extends StatefulWidget { - const AnimationDemoHome({ Key? key }) : super(key: key); + const AnimationDemoHome({ Key key }) : super(key: key); static const String routeName = '/animation'; @@ -428,7 +432,7 @@ class _AnimationDemoHomeState extends State { final PageController _headingPageController = PageController(); final PageController _detailsPageController = PageController(); ScrollPhysics _headingScrollPhysics = const NeverScrollableScrollPhysics(); - ValueNotifier selectedIndex = ValueNotifier(0.0); + ValueNotifier selectedIndex = ValueNotifier(0.0); @override Widget build(BuildContext context) { @@ -488,7 +492,7 @@ class _AnimationDemoHomeState extends State { } Iterable _detailItemsFor(Section section) { - final Iterable detailItems = section.details!.map((SectionDetail detail) { + final Iterable detailItems = section.details.map((SectionDetail detail) { return SectionDetailView(detail: detail); }); return ListTile.divideTiles(context: context, tiles: detailItems); diff --git a/dev/integration_tests/flutter_gallery/lib/demo/animation/sections.dart b/dev/integration_tests/flutter_gallery/lib/demo/animation/sections.dart index 9c5377c821..9ff1f1cb7a 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/animation/sections.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/animation/sections.dart @@ -20,10 +20,10 @@ class SectionDetail { this.imageAsset, this.imageAssetPackage, }); - final String? title; - final String? subtitle; - final String? imageAsset; - final String? imageAssetPackage; + final String title; + final String subtitle; + final String imageAsset; + final String imageAssetPackage; } @immutable @@ -36,12 +36,12 @@ class Section { this.rightColor, this.details, }); - final String? title; - final String? backgroundAsset; - final String? backgroundAssetPackage; - final Color? leftColor; - final Color? rightColor; - final List? details; + final String title; + final String backgroundAsset; + final String backgroundAssetPackage; + final Color leftColor; + final Color rightColor; + final List details; @override bool operator==(Object other) { diff --git a/dev/integration_tests/flutter_gallery/lib/demo/animation/widgets.dart b/dev/integration_tests/flutter_gallery/lib/demo/animation/widgets.dart index 13f65ff2b0..c04553c3a2 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/animation/widgets.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/animation/widgets.dart @@ -10,8 +10,9 @@ const double kSectionIndicatorWidth = 32.0; // The card for a single section. Displays the section's gradient and background image. class SectionCard extends StatelessWidget { - const SectionCard({ Key? key, required this.section }) - : super(key: key); + const SectionCard({ Key key, @required this.section }) + : assert(section != null), + super(key: key); final Section section; @@ -26,13 +27,13 @@ class SectionCard extends StatelessWidget { begin: Alignment.centerLeft, end: Alignment.centerRight, colors: [ - section.leftColor!, - section.rightColor!, + section.leftColor, + section.rightColor, ], ), ), child: Image.asset( - section.backgroundAsset!, + section.backgroundAsset, package: section.backgroundAssetPackage, color: const Color.fromRGBO(255, 255, 255, 0.075), colorBlendMode: BlendMode.modulate, @@ -47,11 +48,13 @@ class SectionCard extends StatelessWidget { // offset a little. It's supposed to look sort-of 3D. class SectionTitle extends StatelessWidget { const SectionTitle({ - Key? key, - required this.section, - required this.scale, - required this.opacity, - }) : assert(opacity >= 0.0 && opacity <= 1.0), + Key key, + @required this.section, + @required this.scale, + @required this.opacity, + }) : assert(section != null), + assert(scale != null), + assert(opacity != null && opacity >= 0.0 && opacity <= 1.0), super(key: key); final Section section; @@ -83,9 +86,9 @@ class SectionTitle extends StatelessWidget { children: [ Positioned( top: 4.0, - child: Text(section.title!, style: sectionTitleShadowStyle), + child: Text(section.title, style: sectionTitleShadowStyle), ), - Text(section.title!, style: sectionTitleStyle), + Text(section.title, style: sectionTitleStyle), ], ), ), @@ -96,7 +99,7 @@ class SectionTitle extends StatelessWidget { // Small horizontal bar that indicates the selected section. class SectionIndicator extends StatelessWidget { - const SectionIndicator({ Key? key, this.opacity = 1.0 }) : super(key: key); + const SectionIndicator({ Key key, this.opacity = 1.0 }) : super(key: key); final double opacity; @@ -114,8 +117,8 @@ class SectionIndicator extends StatelessWidget { // Display a single SectionDetail. class SectionDetailView extends StatelessWidget { - SectionDetailView({ Key? key, required this.detail }) - : assert(detail.imageAsset != null), + SectionDetailView({ Key key, @required this.detail }) + : assert(detail != null && detail.imageAsset != null), assert((detail.imageAsset ?? detail.title) != null), super(key: key); @@ -128,7 +131,7 @@ class SectionDetailView extends StatelessWidget { borderRadius: BorderRadius.circular(6.0), image: DecorationImage( image: AssetImage( - detail.imageAsset!, + detail.imageAsset, package: detail.imageAssetPackage, ), fit: BoxFit.cover, @@ -150,8 +153,8 @@ class SectionDetailView extends StatelessWidget { ); } else { item = ListTile( - title: Text(detail.title!), - subtitle: Text(detail.subtitle!), + title: Text(detail.title), + subtitle: Text(detail.subtitle), leading: SizedBox(width: 32.0, height: 32.0, child: image), ); } diff --git a/dev/integration_tests/flutter_gallery/lib/demo/animation_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/animation_demo.dart index f690509351..5b787f89b8 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/animation_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/animation_demo.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; import 'animation/home.dart'; class AnimationDemo extends StatelessWidget { - const AnimationDemo({Key? key}) : super(key: key); + const AnimationDemo({Key key}) : super(key: key); static const String routeName = '/animation'; diff --git a/dev/integration_tests/flutter_gallery/lib/demo/calculator/home.dart b/dev/integration_tests/flutter_gallery/lib/demo/calculator/home.dart index 822d259644..a124f9f090 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/calculator/home.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/calculator/home.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; import 'logic.dart'; class Calculator extends StatefulWidget { - const Calculator({Key? key}) : super(key: key); + const Calculator({Key key}) : super(key: key); @override _CalculatorState createState() => _CalculatorState(); @@ -43,7 +43,7 @@ class _CalculatorState extends State { } void handleNumberTap(int n) { - final CalcExpression? expression = _expression.appendDigit(n); + final CalcExpression expression = _expression.appendDigit(n); if (expression != null) { setState(() { pushExpression(expression); @@ -52,7 +52,7 @@ class _CalculatorState extends State { } void handlePointTap() { - final CalcExpression? expression = _expression.appendPoint(); + final CalcExpression expression = _expression.appendPoint(); if (expression != null) { setState(() { pushExpression(expression); @@ -61,7 +61,7 @@ class _CalculatorState extends State { } void handlePlusTap() { - final CalcExpression? expression = _expression.appendOperation(Operation.Addition); + final CalcExpression expression = _expression.appendOperation(Operation.Addition); if (expression != null) { setState(() { pushExpression(expression); @@ -70,7 +70,7 @@ class _CalculatorState extends State { } void handleMinusTap() { - final CalcExpression? expression = _expression.appendMinus(); + final CalcExpression expression = _expression.appendMinus(); if (expression != null) { setState(() { pushExpression(expression); @@ -79,7 +79,7 @@ class _CalculatorState extends State { } void handleMultTap() { - final CalcExpression? expression = _expression.appendOperation(Operation.Multiplication); + final CalcExpression expression = _expression.appendOperation(Operation.Multiplication); if (expression != null) { setState(() { pushExpression(expression); @@ -88,7 +88,7 @@ class _CalculatorState extends State { } void handleDivTap() { - final CalcExpression? expression = _expression.appendOperation(Operation.Division); + final CalcExpression expression = _expression.appendOperation(Operation.Division); if (expression != null) { setState(() { pushExpression(expression); @@ -97,7 +97,7 @@ class _CalculatorState extends State { } void handleEqualsTap() { - final CalcExpression? resultExpression = _expression.computeResult(); + final CalcExpression resultExpression = _expression.computeResult(); if (resultExpression != null) { setState(() { setResult(resultExpression); @@ -140,13 +140,13 @@ class _CalculatorState extends State { class CalcDisplay extends StatelessWidget { const CalcDisplay({ this.content }); - final String? content; + final String content; @override Widget build(BuildContext context) { return Center( child: Text( - content!, + content, style: const TextStyle(fontSize: 24.0), ), ); @@ -156,7 +156,7 @@ class CalcDisplay extends StatelessWidget { class KeyPad extends StatelessWidget { const KeyPad({ this.calcState }); - final _CalculatorState? calcState; + final _CalculatorState calcState; @override Widget build(BuildContext context) { @@ -193,9 +193,9 @@ class KeyPad extends StatelessWidget { NumberKey(3, calcState), ]), KeyRow([ - CalcKey('.', calcState!.handlePointTap), + CalcKey('.', calcState.handlePointTap), NumberKey(0, calcState), - CalcKey('=', calcState!.handleEqualsTap), + CalcKey('=', calcState.handleEqualsTap), ]), ], ), @@ -205,11 +205,11 @@ class KeyPad extends StatelessWidget { color: themeData.backgroundColor, child: Column( children: [ - CalcKey('\u232B', calcState!.handleDelTap), - CalcKey('\u00F7', calcState!.handleDivTap), - CalcKey('\u00D7', calcState!.handleMultTap), - CalcKey('-', calcState!.handleMinusTap), - CalcKey('+', calcState!.handlePlusTap), + CalcKey('\u232B', calcState.handleDelTap), + CalcKey('\u00F7', calcState.handleDivTap), + CalcKey('\u00D7', calcState.handleMultTap), + CalcKey('-', calcState.handleMinusTap), + CalcKey('+', calcState.handlePlusTap), ], ), ), @@ -263,8 +263,8 @@ class CalcKey extends StatelessWidget { } class NumberKey extends CalcKey { - NumberKey(int value, _CalculatorState? calcState) + NumberKey(int value, _CalculatorState calcState) : super('$value', () { - calcState!.handleNumberTap(value); + calcState.handleNumberTap(value); }); } diff --git a/dev/integration_tests/flutter_gallery/lib/demo/calculator/logic.dart b/dev/integration_tests/flutter_gallery/lib/demo/calculator/logic.dart index 9f832a6e50..8001f8fd29 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/calculator/logic.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/calculator/logic.dart @@ -9,10 +9,10 @@ class ExpressionToken { ExpressionToken(this.stringRep); - final String? stringRep; + final String stringRep; @override - String toString() => stringRep!; + String toString() => stringRep; } /// A token that represents a number. @@ -71,7 +71,7 @@ class OperationToken extends ExpressionToken { Operation operation; - static String? opString(Operation operation) { + static String opString(Operation operation) { switch (operation) { case Operation.Addition: return ' + '; @@ -82,6 +82,8 @@ class OperationToken extends ExpressionToken { case Operation.Division: return ' \u00F7 '; } + assert(operation != null); + return null; } } @@ -122,13 +124,13 @@ class CalcExpression { : this([], ExpressionState.Start); CalcExpression.result(FloatToken result) - : _list = [], + : _list = [], state = ExpressionState.Result { _list.add(result); } /// The tokens comprising the expression. - final List _list; + final List _list; /// The state of the expression. final ExpressionState state; @@ -144,10 +146,10 @@ class CalcExpression { /// Append a digit to the current expression and return a new expression /// representing the result. Returns null to indicate that it is not legal /// to append a digit in the current state. - CalcExpression? appendDigit(int digit) { + CalcExpression appendDigit(int digit) { ExpressionState newState = ExpressionState.Number; - ExpressionToken? newToken; - final List outList = _list.toList(); + ExpressionToken newToken; + final List outList = _list.toList(); switch (state) { case ExpressionState.Start: // Start a new number with digit. @@ -159,12 +161,12 @@ class CalcExpression { newToken = IntToken('-$digit'); break; case ExpressionState.Number: - final ExpressionToken last = outList.removeLast()!; + final ExpressionToken last = outList.removeLast(); newToken = IntToken('${last.stringRep}$digit'); break; case ExpressionState.Point: case ExpressionState.NumberWithPoint: - final ExpressionToken last = outList.removeLast()!; + final ExpressionToken last = outList.removeLast(); newState = ExpressionState.NumberWithPoint; newToken = FloatToken('${last.stringRep}$digit'); break; @@ -179,17 +181,17 @@ class CalcExpression { /// Append a point to the current expression and return a new expression /// representing the result. Returns null to indicate that it is not legal /// to append a point in the current state. - CalcExpression? appendPoint() { - ExpressionToken? newToken; - final List outList = _list.toList(); + CalcExpression appendPoint() { + ExpressionToken newToken; + final List outList = _list.toList(); switch (state) { case ExpressionState.Start: newToken = FloatToken('.'); break; case ExpressionState.LeadingNeg: case ExpressionState.Number: - final ExpressionToken last = outList.removeLast()!; - newToken = FloatToken(last.stringRep! + '.'); + final ExpressionToken last = outList.removeLast(); + newToken = FloatToken(last.stringRep + '.'); break; case ExpressionState.Point: case ExpressionState.NumberWithPoint: @@ -204,7 +206,7 @@ class CalcExpression { /// Append an operation symbol to the current expression and return a new /// expression representing the result. Returns null to indicate that it is not /// legal to append an operation symbol in the current state. - CalcExpression? appendOperation(Operation op) { + CalcExpression appendOperation(Operation op) { switch (state) { case ExpressionState.Start: case ExpressionState.LeadingNeg: @@ -216,7 +218,7 @@ class CalcExpression { case ExpressionState.Result: break; } - final List outList = _list.toList(); + final List outList = _list.toList(); outList.add(OperationToken(op)); return CalcExpression(outList, ExpressionState.Start); } @@ -224,7 +226,7 @@ class CalcExpression { /// Append a leading minus sign to the current expression and return a new /// expression representing the result. Returns null to indicate that it is not /// legal to append a leading minus sign in the current state. - CalcExpression? appendLeadingNeg() { + CalcExpression appendLeadingNeg() { switch (state) { case ExpressionState.Start: break; @@ -236,7 +238,7 @@ class CalcExpression { // Cannot enter leading neg now. return null; } - final List outList = _list.toList(); + final List outList = _list.toList(); outList.add(LeadingNegToken()); return CalcExpression(outList, ExpressionState.LeadingNeg); } @@ -246,7 +248,7 @@ class CalcExpression { /// to append a minus sign in the current state. Depending on the current /// state the minus sign will be interpreted as either a leading negative /// sign or a subtraction operation. - CalcExpression? appendMinus() { + CalcExpression appendMinus() { switch (state) { case ExpressionState.Start: return appendLeadingNeg(); @@ -264,7 +266,7 @@ class CalcExpression { /// Computes the result of the current expression and returns a new /// ResultExpression containing the result. Returns null to indicate that /// it is not legal to compute a result in the current state. - CalcExpression? computeResult() { + CalcExpression computeResult() { switch (state) { case ExpressionState.Start: case ExpressionState.LeadingNeg: @@ -279,13 +281,13 @@ class CalcExpression { // We make a copy of _list because CalcExpressions are supposed to // be immutable. - final List list = _list.toList(); + final List list = _list.toList(); // We obey order-of-operations by computing the sum of the 'terms', // where a "term" is defined to be a sequence of numbers separated by // multiplication or division symbols. num currentTermValue = removeNextTerm(list); while (list.isNotEmpty) { - final OperationToken opToken = list.removeAt(0)! as OperationToken; + final OperationToken opToken = list.removeAt(0) as OperationToken; final num nextTermValue = removeNextTerm(list); switch (opToken.operation) { case Operation.Addition: @@ -309,13 +311,13 @@ class CalcExpression { /// Removes the next "term" from `list` and returns its numeric value. /// A "term" is a sequence of number tokens separated by multiplication /// and division symbols. - static num removeNextTerm(List list) { - assert(list.isNotEmpty); - final NumberToken firstNumToken = list.removeAt(0)! as NumberToken; + static num removeNextTerm(List list) { + assert(list != null && list.isNotEmpty); + final NumberToken firstNumToken = list.removeAt(0) as NumberToken; num currentValue = firstNumToken.number; while (list.isNotEmpty) { bool isDivision = false; - final OperationToken nextOpToken = list.first! as OperationToken; + final OperationToken nextOpToken = list.first as OperationToken; switch (nextOpToken.operation) { case Operation.Addition: case Operation.Subtraction: @@ -329,7 +331,7 @@ class CalcExpression { // Remove the operation token. list.removeAt(0); // Remove the next number token. - final NumberToken nextNumToken = list.removeAt(0)! as NumberToken; + final NumberToken nextNumToken = list.removeAt(0) as NumberToken; final num nextNumber = nextNumToken.number; if (isDivision) currentValue /= nextNumber; diff --git a/dev/integration_tests/flutter_gallery/lib/demo/calculator_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/calculator_demo.dart index b8842ff3cc..aaa9953364 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/calculator_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/calculator_demo.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; import 'calculator/home.dart'; class CalculatorDemo extends StatelessWidget { - const CalculatorDemo({Key? key}) : super(key: key); + const CalculatorDemo({Key key}) : super(key: key); static const String routeName = '/calculator'; diff --git a/dev/integration_tests/flutter_gallery/lib/demo/colors_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/colors_demo.dart index 73f20b25c2..26a966cfb0 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/colors_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/colors_demo.dart @@ -9,12 +9,12 @@ const double kColorItemHeight = 48.0; class Palette { Palette({ this.name, this.primary, this.accent, this.threshold = 900}); - final String? name; - final MaterialColor? primary; - final MaterialAccentColor? accent; + final String name; + final MaterialColor primary; + final MaterialAccentColor accent; final int threshold; // titles for indices > threshold are white, otherwise black - bool get isValid => name != null && primary != null; + bool get isValid => name != null && primary != null && threshold != null; } final List allPalettes = [ @@ -42,11 +42,14 @@ final List allPalettes = [ class ColorItem extends StatelessWidget { const ColorItem({ - Key? key, - required this.index, - required this.color, + Key key, + @required this.index, + @required this.color, this.prefix = '', - }) : super(key: key); + }) : assert(index != null), + assert(color != null), + assert(prefix != null), + super(key: key); final int index; final Color color; @@ -81,9 +84,9 @@ class ColorItem extends StatelessWidget { class PaletteTabView extends StatelessWidget { PaletteTabView({ - Key? key, - required this.colors, - }) : assert(colors.isValid), + Key key, + @required this.colors, + }) : assert(colors != null && colors.isValid), super(key: key); final Palette colors; @@ -94,8 +97,8 @@ class PaletteTabView extends StatelessWidget { @override Widget build(BuildContext context) { final TextTheme textTheme = Theme.of(context).textTheme; - final TextStyle whiteTextStyle = textTheme.bodyText2!.copyWith(color: Colors.white); - final TextStyle blackTextStyle = textTheme.bodyText2!.copyWith(color: Colors.black); + final TextStyle whiteTextStyle = textTheme.bodyText2.copyWith(color: Colors.white); + final TextStyle blackTextStyle = textTheme.bodyText2.copyWith(color: Colors.black); return Scrollbar( child: ListView( itemExtent: kColorItemHeight, @@ -103,14 +106,14 @@ class PaletteTabView extends StatelessWidget { ...primaryKeys.map((int index) { return DefaultTextStyle( style: index > colors.threshold ? whiteTextStyle : blackTextStyle, - child: ColorItem(index: index, color: colors.primary![index]!), + child: ColorItem(index: index, color: colors.primary[index]), ); }), if (colors.accent != null) ...accentKeys.map((int index) { return DefaultTextStyle( style: index > colors.threshold ? whiteTextStyle : blackTextStyle, - child: ColorItem(index: index, color: colors.accent![index]!, prefix: 'A'), + child: ColorItem(index: index, color: colors.accent[index], prefix: 'A'), ); }), ], diff --git a/dev/integration_tests/flutter_gallery/lib/demo/contacts_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/contacts_demo.dart index 00a8d15160..76dbf1cf6d 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/contacts_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/contacts_demo.dart @@ -6,10 +6,10 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; class _ContactCategory extends StatelessWidget { - const _ContactCategory({ Key? key, this.icon, this.children }) : super(key: key); + const _ContactCategory({ Key key, this.icon, this.children }) : super(key: key); - final IconData? icon; - final List? children; + final IconData icon; + final List children; @override Widget build(BuildContext context) { @@ -20,7 +20,7 @@ class _ContactCategory extends StatelessWidget { border: Border(bottom: BorderSide(color: themeData.dividerColor)) ), child: DefaultTextStyle( - style: Theme.of(context).textTheme.subtitle1!, + style: Theme.of(context).textTheme.subtitle1, child: SafeArea( top: false, bottom: false, @@ -32,7 +32,7 @@ class _ContactCategory extends StatelessWidget { width: 72.0, child: Icon(icon, color: themeData.primaryColor), ), - Expanded(child: Column(children: children!)), + Expanded(child: Column(children: children)), ], ), ), @@ -42,14 +42,14 @@ class _ContactCategory extends StatelessWidget { } class _ContactItem extends StatelessWidget { - const _ContactItem({ Key? key, this.icon, required this.lines, this.tooltip, this.onPressed }) + const _ContactItem({ Key key, this.icon, this.lines, this.tooltip, this.onPressed }) : assert(lines.length > 1), super(key: key); - final IconData? icon; + final IconData icon; final List lines; - final String? tooltip; - final VoidCallback? onPressed; + final String tooltip; + final VoidCallback onPressed; @override Widget build(BuildContext context) { diff --git a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_alert_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_alert_demo.dart index 30c348b74c..9c608a8bbd 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_alert_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_alert_demo.dart @@ -14,24 +14,24 @@ class CupertinoAlertDemo extends StatefulWidget { } class _CupertinoAlertDemoState extends State { - String? lastSelectedValue; + String lastSelectedValue; - void showDemoDialog({required BuildContext context, Widget? child}) { + void showDemoDialog({BuildContext context, Widget child}) { showCupertinoDialog( context: context, - builder: (BuildContext context) => child!, - ).then((String? value) { + builder: (BuildContext context) => child, + ).then((String value) { if (value != null) { setState(() { lastSelectedValue = value; }); } }); } - void showDemoActionSheet({required BuildContext context, Widget? child}) { + void showDemoActionSheet({BuildContext context, Widget child}) { showCupertinoModalPopup( context: context, - builder: (BuildContext context) => child!, - ).then((String? value) { + builder: (BuildContext context) => child, + ).then((String value) { if (value != null) { setState(() { lastSelectedValue = value; }); } @@ -196,10 +196,10 @@ class _CupertinoAlertDemoState extends State { } class CupertinoDessertDialog extends StatelessWidget { - const CupertinoDessertDialog({Key? key, this.title, this.content}) : super(key: key); + const CupertinoDessertDialog({Key key, this.title, this.content}) : super(key: key); - final Widget? title; - final Widget? content; + final Widget title; + final Widget content; @override Widget build(BuildContext context) { diff --git a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart index 191e99b268..36fbb4d2e6 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart @@ -44,7 +44,7 @@ class CupertinoNavigationDemo extends StatelessWidget { final List colorItems; final List colorNameItems; - final int? randomSeed; + final int randomSeed; @override Widget build(BuildContext context) { @@ -71,6 +71,7 @@ class CupertinoNavigationDemo extends StatelessWidget { ], ), tabBuilder: (BuildContext context, int index) { + assert(index >= 0 && index <= 2); switch (index) { case 0: return CupertinoTabView( @@ -83,19 +84,21 @@ class CupertinoNavigationDemo extends StatelessWidget { }, defaultTitle: 'Colors', ); + break; case 1: return CupertinoTabView( builder: (BuildContext context) => CupertinoDemoTab2(), defaultTitle: 'Support Chat', ); + break; case 2: return CupertinoTabView( builder: (BuildContext context) => CupertinoDemoTab3(), defaultTitle: 'Account', ); + break; } - assert(false); - return const CupertinoTabView(); + return null; }, ), ), @@ -117,7 +120,7 @@ class ExitButton extends StatelessWidget { ), onPressed: () { // The demo is on the root navigator. - Navigator.of(context, rootNavigator: true)!.pop(); + Navigator.of(context, rootNavigator: true).pop(); }, ); } @@ -139,9 +142,9 @@ class CupertinoDemoTab1 extends StatelessWidget { this.randomSeed, }); - final List? colorItems; - final List? colorNameItems; - final int? randomSeed; + final List colorItems; + final List colorNameItems; + final int randomSeed; @override Widget build(BuildContext context) { @@ -167,8 +170,8 @@ class CupertinoDemoTab1 extends StatelessWidget { return Tab1RowItem( index: index, lastItem: index == _kChildCount - 1, - color: colorItems![index], - colorName: colorNameItems![index], + color: colorItems[index], + colorName: colorNameItems[index], randomSeed: randomSeed, ); }, @@ -191,18 +194,18 @@ class Tab1RowItem extends StatelessWidget { this.randomSeed, }); - final int? index; - final bool? lastItem; - final Color? color; - final String? colorName; - final int? randomSeed; + final int index; + final bool lastItem; + final Color color; + final String colorName; + final int randomSeed; @override Widget build(BuildContext context) { final Widget row = GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - Navigator.of(context)!.push(CupertinoPageRoute( + Navigator.of(context).push(CupertinoPageRoute( title: colorName, builder: (BuildContext context) => Tab1ItemPage( color: color, @@ -235,7 +238,7 @@ class Tab1RowItem extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(colorName!), + Text(colorName), const Padding(padding: EdgeInsets.only(top: 8.0)), Text( 'Buy this cool color', @@ -270,7 +273,7 @@ class Tab1RowItem extends StatelessWidget { ), ); - if (lastItem!) { + if (lastItem) { return row; } @@ -289,10 +292,10 @@ class Tab1RowItem extends StatelessWidget { class Tab1ItemPage extends StatefulWidget { const Tab1ItemPage({this.color, this.colorName, this.index, this.randomSeed}); - final Color? color; - final String? colorName; - final int? index; - final int? randomSeed; + final Color color; + final String colorName; + final int index; + final int randomSeed; @override State createState() => Tab1ItemPageState(); @@ -306,14 +309,14 @@ class Tab1ItemPageState extends State { final math.Random random = math.Random(widget.randomSeed); return Color.fromARGB( 255, - (widget.color!.red + random.nextInt(100) - 50).clamp(0, 255), - (widget.color!.green + random.nextInt(100) - 50).clamp(0, 255), - (widget.color!.blue + random.nextInt(100) - 50).clamp(0, 255), + (widget.color.red + random.nextInt(100) - 50).clamp(0, 255) as int, + (widget.color.green + random.nextInt(100) - 50).clamp(0, 255) as int, + (widget.color.blue + random.nextInt(100) - 50).clamp(0, 255) as int, ); }); } - late List relatedColors; + List relatedColors; @override Widget build(BuildContext context) { @@ -347,7 +350,7 @@ class Tab1ItemPageState extends State { mainAxisSize: MainAxisSize.min, children: [ Text( - widget.colorName!, + widget.colorName, style: const TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold), ), const Padding(padding: EdgeInsets.only(top: 6.0)), @@ -591,13 +594,13 @@ enum Tab2ConversationBubbleColor { class Tab2ConversationBubble extends StatelessWidget { const Tab2ConversationBubble({this.text, this.color}); - final String? text; - final Tab2ConversationBubbleColor? color; + final String text; + final Tab2ConversationBubbleColor color; @override Widget build(BuildContext context) { - Color? backgroundColor; - Color? foregroundColor; + Color backgroundColor; + Color foregroundColor; switch (color) { case Tab2ConversationBubbleColor.gray: @@ -608,8 +611,6 @@ class Tab2ConversationBubble extends StatelessWidget { backgroundColor = CupertinoTheme.of(context).primaryColor; foregroundColor = CupertinoColors.white; break; - default: - break; } return Container( @@ -620,7 +621,7 @@ class Tab2ConversationBubble extends StatelessWidget { margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0), padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 10.0), child: Text( - text!, + text, style: TextStyle( color: foregroundColor, letterSpacing: -0.4, @@ -635,8 +636,8 @@ class Tab2ConversationBubble extends StatelessWidget { class Tab2ConversationAvatar extends StatelessWidget { const Tab2ConversationAvatar({this.text, this.color}); - final String? text; - final Color? color; + final String text; + final Color color; @override Widget build(BuildContext context) { @@ -647,20 +648,20 @@ class Tab2ConversationAvatar extends StatelessWidget { begin: FractionalOffset.topCenter, end: FractionalOffset.bottomCenter, colors: [ - color!, + color, Color.fromARGB( - color!.alpha, - (color!.red - 60).clamp(0, 255), - (color!.green - 60).clamp(0, 255), - (color!.blue - 60).clamp(0, 255), + color.alpha, + (color.red - 60).clamp(0, 255) as int, + (color.green - 60).clamp(0, 255) as int, + (color.blue - 60).clamp(0, 255) as int, ), - ] + ], ), ), margin: const EdgeInsets.only(left: 8.0, bottom: 8.0), padding: const EdgeInsets.all(12.0), child: Text( - text!, + text, style: const TextStyle( color: CupertinoColors.white, fontSize: 13.0, @@ -674,8 +675,8 @@ class Tab2ConversationAvatar extends StatelessWidget { class Tab2ConversationRow extends StatelessWidget { const Tab2ConversationRow({this.avatar, this.text}); - final Tab2ConversationAvatar? avatar; - final String? text; + final Tab2ConversationAvatar avatar; + final String text; @override Widget build(BuildContext context) { @@ -686,8 +687,7 @@ class Tab2ConversationRow extends StatelessWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: isSelf ? CrossAxisAlignment.center : CrossAxisAlignment.end, children: [ - if (avatar != null) - avatar!, + if (avatar != null) avatar, CupertinoUserInterfaceLevel( data: CupertinoUserInterfaceLevelData.elevated, child: Tab2ConversationBubble( @@ -752,7 +752,7 @@ class CupertinoDemoTab3 extends StatelessWidget { const Padding(padding: EdgeInsets.only(top: 32.0)), GestureDetector( onTap: () { - Navigator.of(context, rootNavigator: true)!.push( + Navigator.of(context, rootNavigator: true).push( CupertinoPageRoute( fullscreenDialog: true, builder: (BuildContext context) => Tab3Dialog(), @@ -800,7 +800,7 @@ class Tab3Dialog extends StatelessWidget { child: const Text('Cancel'), padding: EdgeInsets.zero, onPressed: () { - Navigator.of(context)!.pop(false); + Navigator.of(context).pop(false); }, ), ), diff --git a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart index b7c7eaddf6..f45819e94d 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart @@ -20,9 +20,10 @@ class CupertinoPickerDemo extends StatefulWidget { class _BottomPicker extends StatelessWidget { const _BottomPicker({ - Key? key, - required this.child, - }) : super(key: key); + Key key, + @required this.child, + }) : assert(child != null), + super(key: key); final Widget child; @@ -52,9 +53,10 @@ class _BottomPicker extends StatelessWidget { class _Menu extends StatelessWidget { const _Menu({ - Key? key, - required this.children, - }) : super(key: key); + Key key, + @required this.children, + }) : assert(children != null), + super(key: key); final List children; diff --git a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart index 4547ef2148..31a50bcbd2 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart @@ -16,7 +16,7 @@ class CupertinoRefreshControlDemo extends StatefulWidget { } class _CupertinoRefreshControlDemoState extends State { - late List> randomizedContacts; + List> randomizedContacts; @override void initState() { @@ -64,7 +64,7 @@ class _CupertinoRefreshControlDemoState extends State.delayed(const Duration(seconds: 2)) - ..then((_) { + ..then((_) { if (mounted) { setState(() => repopulateList()); } @@ -149,10 +149,10 @@ class _ListItem extends StatelessWidget { this.called, }); - final String? name; - final String? place; - final String? date; - final bool? called; + final String name; + final String place; + final String date; + final bool called; @override Widget build(BuildContext context) { @@ -164,7 +164,7 @@ class _ListItem extends StatelessWidget { children: [ Container( width: 38.0, - child: called! + child: called ? Align( alignment: Alignment.topCenter, child: Icon( @@ -191,7 +191,7 @@ class _ListItem extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - name!, + name, maxLines: 1, overflow: TextOverflow.ellipsis, style: const TextStyle( @@ -200,7 +200,7 @@ class _ListItem extends StatelessWidget { ), ), Text( - place!, + place, maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -213,7 +213,7 @@ class _ListItem extends StatelessWidget { ), ), Text( - date!, + date, style: TextStyle( color: CupertinoColors.inactiveGray.resolveFrom(context), fontSize: 15.0, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_segmented_control_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_segmented_control_demo.dart index 529ff4adee..e68b21c684 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_segmented_control_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_segmented_control_demo.dart @@ -43,9 +43,9 @@ class _CupertinoSegmentedControlDemoState extends State { - TextEditingController? _chatTextController; - TextEditingController? _locationTextController; + TextEditingController _chatTextController; + TextEditingController _locationTextController; @override void initState() { @@ -49,12 +49,12 @@ class _CupertinoTextFieldDemoState extends State { color: CupertinoColors.activeGreen, ), padding: const EdgeInsets.only(bottom: 4), - onPressed: ()=> setState(()=> _chatTextController!.clear()), + onPressed: ()=> setState(()=> _chatTextController.clear()), ), ), autofocus: true, suffixMode: OverlayVisibilityMode.editing, - onSubmitted: (String text)=> setState(()=> _chatTextController!.clear()), + onSubmitted: (String text)=> setState(()=> _chatTextController.clear()), ); } diff --git a/dev/integration_tests/flutter_gallery/lib/demo/fortnightly/fortnightly.dart b/dev/integration_tests/flutter_gallery/lib/demo/fortnightly/fortnightly.dart index 7f8dc30729..e68dac3159 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/fortnightly/fortnightly.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/fortnightly/fortnightly.dart @@ -33,7 +33,7 @@ class FortnightlyDemo extends StatelessWidget { class ShortAppBar extends StatelessWidget { const ShortAppBar({ this.onBackPressed }); - final VoidCallback? onBackPressed; + final VoidCallback onBackPressed; @override Widget build(BuildContext context) { @@ -118,7 +118,7 @@ over water meant for the whole central valley of California? The story will shoc Text( ' ¬ ', // TODO(larche): Replace textTheme.headline2.color with a ColorScheme value when known. - style: textTheme.overline!.apply(color: textTheme.headline2!.color), + style: textTheme.overline.apply(color: textTheme.headline2.color), ), Text( 'CULTURE', @@ -196,7 +196,7 @@ TextTheme _buildTextTheme(TextTheme base) { theme = theme.apply(displayColor: Colors.black); theme = theme.copyWith( - headline4: base.headline4!.copyWith( + headline4: base.headline4.copyWith( fontFamily: 'Merriweather', fontStyle: FontStyle.italic, fontSize: 28, @@ -204,21 +204,21 @@ TextTheme _buildTextTheme(TextTheme base) { color: Colors.black, height: .88, ), - headline2: base.headline2!.copyWith( + headline2: base.headline2.copyWith( fontFamily: 'LibreFranklin', fontSize: 18, fontWeight: FontWeight.w500, color: Colors.black.withAlpha(153), ), - headline5: base.headline5!.copyWith(fontWeight: FontWeight.w500), - bodyText2: base.bodyText2!.copyWith( + headline5: base.headline5.copyWith(fontWeight: FontWeight.w500), + bodyText2: base.bodyText2.copyWith( fontFamily: 'Merriweather', fontSize: 14, fontWeight: FontWeight.w300, color: const Color(0xFF666666), height: 1.11, ), - bodyText1: base.bodyText1!.copyWith( + bodyText1: base.bodyText1.copyWith( fontFamily: 'Merriweather', fontSize: 16, fontWeight: FontWeight.w300, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/backdrop_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/backdrop_demo.dart index 0ea7a17e72..dd8c5c8b64 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/backdrop_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/backdrop_demo.dart @@ -12,8 +12,8 @@ import 'package:flutter/material.dart'; class Category { const Category({ this.title, this.assets }); - final String? title; - final List? assets; + final String title; + final List assets; @override String toString() => '$runtimeType("$title")'; } @@ -95,21 +95,21 @@ const List allCategories = [ ]; class CategoryView extends StatelessWidget { - const CategoryView({ Key? key, this.category }) : super(key: key); + const CategoryView({ Key key, this.category }) : super(key: key); - final Category? category; + final Category category; @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); return Scrollbar( child: ListView( - key: PageStorageKey(category), + key: PageStorageKey(category), padding: const EdgeInsets.symmetric( vertical: 16.0, horizontal: 64.0, ), - children: category!.assets!.map((String asset) { + children: category.assets.map((String asset) { return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ @@ -149,7 +149,7 @@ class CategoryView extends StatelessWidget { // BackdropDemo. class BackdropPanel extends StatelessWidget { const BackdropPanel({ - Key? key, + Key key, this.onTap, this.onVerticalDragUpdate, this.onVerticalDragEnd, @@ -157,11 +157,11 @@ class BackdropPanel extends StatelessWidget { this.child, }) : super(key: key); - final VoidCallback? onTap; - final GestureDragUpdateCallback? onVerticalDragUpdate; - final GestureDragEndCallback? onVerticalDragEnd; - final Widget? title; - final Widget? child; + final VoidCallback onTap; + final GestureDragUpdateCallback onVerticalDragUpdate; + final GestureDragEndCallback onVerticalDragEnd; + final Widget title; + final Widget child; @override Widget build(BuildContext context) { @@ -185,7 +185,7 @@ class BackdropPanel extends StatelessWidget { padding: const EdgeInsetsDirectional.only(start: 16.0), alignment: AlignmentDirectional.centerStart, child: DefaultTextStyle( - style: theme.textTheme.subtitle1!, + style: theme.textTheme.subtitle1, child: Tooltip( message: 'Tap to dismiss', child: title, @@ -194,7 +194,7 @@ class BackdropPanel extends StatelessWidget { ), ), const Divider(height: 1.0), - Expanded(child: child!), + Expanded(child: child), ], ), ); @@ -204,15 +204,15 @@ class BackdropPanel extends StatelessWidget { // Cross fades between 'Select a Category' and 'Asset Viewer'. class BackdropTitle extends AnimatedWidget { const BackdropTitle({ - Key? key, - required Animation listenable, + Key key, + Animation listenable, }) : super(key: key, listenable: listenable); @override Widget build(BuildContext context) { final Animation animation = listenable as Animation; return DefaultTextStyle( - style: Theme.of(context).primaryTextTheme.headline6!, + style: Theme.of(context).primaryTextTheme.headline6, softWrap: false, overflow: TextOverflow.ellipsis, child: Stack( @@ -247,7 +247,7 @@ class BackdropDemo extends StatefulWidget { class _BackdropDemoState extends State with SingleTickerProviderStateMixin { final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop'); - late AnimationController _controller; + AnimationController _controller; Category _category = allCategories[0]; @override @@ -283,7 +283,7 @@ class _BackdropDemoState extends State with SingleTickerProviderSt } double get _backdropHeight { - final RenderBox renderBox = _backdropKey.currentContext!.findRenderObject()! as RenderBox; + final RenderBox renderBox = _backdropKey.currentContext.findRenderObject() as RenderBox; return renderBox.size.height; } @@ -294,7 +294,7 @@ class _BackdropDemoState extends State with SingleTickerProviderSt if (_controller.isAnimating || _controller.status == AnimationStatus.completed) return; - _controller.value -= details.primaryDelta! / _backdropHeight; + _controller.value -= details.primaryDelta / (_backdropHeight ?? details.primaryDelta); } void _handleDragEnd(DragEndDetails details) { @@ -343,7 +343,7 @@ class _BackdropDemoState extends State with SingleTickerProviderSt ? Colors.white.withOpacity(0.25) : Colors.transparent, child: ListTile( - title: Text(category.title!), + title: Text(category.title), selected: selected, onTap: () { _changeCategory(category); @@ -359,8 +359,8 @@ class _BackdropDemoState extends State with SingleTickerProviderSt children: [ ListTileTheme( iconColor: theme.primaryIconTheme.color, - textColor: theme.primaryTextTheme.headline6!.color!.withOpacity(0.6), - selectedColor: theme.primaryTextTheme.headline6!.color, + textColor: theme.primaryTextTheme.headline6.color.withOpacity(0.6), + selectedColor: theme.primaryTextTheme.headline6.color, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), child: Column( @@ -375,7 +375,7 @@ class _BackdropDemoState extends State with SingleTickerProviderSt onTap: _toggleBackdropPanelVisibility, onVerticalDragUpdate: _handleDragUpdate, onVerticalDragEnd: _handleDragEnd, - title: Text(_category.title!), + title: Text(_category.title), child: CategoryView(category: _category), ), ), diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/banner_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/banner_demo.dart index 666174be07..49d23ac973 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/banner_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/banner_demo.dart @@ -13,7 +13,7 @@ enum BannerDemoAction { } class BannerDemo extends StatefulWidget { - const BannerDemo({ Key? key }) : super(key: key); + const BannerDemo({ Key key }) : super(key: key); static const String routeName = '/material/banner'; diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart index aeca49c1b2..9449c6457d 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart @@ -92,7 +92,7 @@ class _BottomAppBarDemoState extends State { "When the Scaffold's floating action button location changes, " 'the floating action button animates to its new position. ' 'The BottomAppBar adapts its shape appropriately.'; - _scaffoldMessengerKey.currentState!.showSnackBar( + _scaffoldMessengerKey.currentState.showSnackBar( const SnackBar(content: Text(text)), ); } @@ -111,27 +111,27 @@ class _BottomAppBarDemoState extends State { _ChoiceValue _fabShape = kCircularFab; _ChoiceValue _showNotch = kShowNotchTrue; _ChoiceValue _fabLocation = kFabEndDocked; - Color? _babColor = kBabColors.first.color; + Color _babColor = kBabColors.first.color; - void _onShowNotchChanged(_ChoiceValue? value) { + void _onShowNotchChanged(_ChoiceValue value) { setState(() { - _showNotch = value!; + _showNotch = value; }); } - void _onFabShapeChanged(_ChoiceValue? value) { + void _onFabShapeChanged(_ChoiceValue value) { setState(() { - _fabShape = value!; + _fabShape = value; }); } - void _onFabLocationChanged(_ChoiceValue? value) { + void _onFabLocationChanged(_ChoiceValue value) { setState(() { - _fabLocation = value!; + _fabLocation = value; }); } - void _onBabColorChanged(Color? value) { + void _onBabColorChanged(Color value) { setState(() { _babColor = value; }); @@ -201,8 +201,8 @@ class _BottomAppBarDemoState extends State { ); } - NotchedShape? _selectNotch() { - if (!_showNotch.value!) + NotchedShape _selectNotch() { + if (!_showNotch.value) return null; if (_fabShape == kCircularFab) return const CircularNotchedRectangle(); @@ -215,9 +215,9 @@ class _BottomAppBarDemoState extends State { class _ChoiceValue { const _ChoiceValue({ this.value, this.title, this.label }); - final T? value; - final String? title; - final String? label; // For the Semantics widget that contains title + final T value; + final String title; + final String label; // For the Semantics widget that contains title @override String toString() => '$runtimeType("$title")'; @@ -228,7 +228,7 @@ class _RadioItem extends StatelessWidget { final _ChoiceValue value; final _ChoiceValue groupValue; - final ValueChanged<_ChoiceValue?> onChanged; + final ValueChanged<_ChoiceValue> onChanged; @override Widget build(BuildContext context) { @@ -256,7 +256,7 @@ class _RadioItem extends StatelessWidget { onChanged(value); }, child: Text( - value.title!, + value.title, style: theme.textTheme.subtitle1, ), ), @@ -272,7 +272,7 @@ class _RadioItem extends StatelessWidget { class _NamedColor { const _NamedColor(this.color, this.name); - final Color? color; + final Color color; final String name; } @@ -280,8 +280,8 @@ class _ColorsItem extends StatelessWidget { const _ColorsItem(this.colors, this.selectedColor, this.onChanged); final List<_NamedColor> colors; - final Color? selectedColor; - final ValueChanged onChanged; + final Color selectedColor; + final ValueChanged onChanged; @override Widget build(BuildContext context) { @@ -340,9 +340,9 @@ class _DemoBottomAppBar extends StatelessWidget { this.shape, }); - final Color? color; - final FloatingActionButtonLocation? fabLocation; - final NotchedShape? shape; + final Color color; + final FloatingActionButtonLocation fabLocation; + final NotchedShape shape; static final List kCenterLocations = [ FloatingActionButtonLocation.centerDocked, @@ -421,8 +421,8 @@ class _DiamondFab extends StatelessWidget { this.onPressed, }); - final Widget? child; - final VoidCallback? onPressed; + final Widget child; + final VoidCallback onPressed; @override Widget build(BuildContext context) { @@ -436,7 +436,7 @@ class _DiamondFab extends StatelessWidget { height: 56.0, child: IconTheme.merge( data: IconThemeData(color: Theme.of(context).accentIconTheme.color), - child: child!, + child: child, ), ), ), @@ -449,8 +449,8 @@ class _DiamondNotchedRectangle implements NotchedShape { const _DiamondNotchedRectangle(); @override - Path getOuterPath(Rect host, Rect? guest) { - if (!host.overlaps(guest!)) + Path getOuterPath(Rect host, Rect guest) { + if (!host.overlaps(guest)) return Path()..addRect(host); assert(guest.width > 0.0); @@ -492,12 +492,12 @@ class _DiamondBorder extends ShapeBorder { } @override - Path getInnerPath(Rect rect, { TextDirection? textDirection }) { + Path getInnerPath(Rect rect, { TextDirection textDirection }) { return getOuterPath(rect, textDirection: textDirection); } @override - Path getOuterPath(Rect rect, { TextDirection? textDirection }) { + Path getOuterPath(Rect rect, { TextDirection textDirection }) { return Path() ..moveTo(rect.left + rect.width / 2.0, rect.top) ..lineTo(rect.right, rect.top + rect.height / 2.0) @@ -507,11 +507,11 @@ class _DiamondBorder extends ShapeBorder { } @override - void paint(Canvas canvas, Rect rect, { TextDirection? textDirection }) { } + void paint(Canvas canvas, Rect rect, { TextDirection textDirection }) { } // This border doesn't support scaling. @override ShapeBorder scale(double t) { - return this; + return null; } } diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart index 67d8ea072b..838c60a49b 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart @@ -8,11 +8,11 @@ import '../../gallery/demo.dart'; class NavigationIconView { NavigationIconView({ - required Widget icon, - Widget? activeIcon, - String? title, - Color? color, - required TickerProvider vsync, + Widget icon, + Widget activeIcon, + String title, + Color color, + TickerProvider vsync, }) : _icon = icon, _color = color, _title = title, @@ -32,14 +32,14 @@ class NavigationIconView { } final Widget _icon; - final Color? _color; - final String? _title; + final Color _color; + final String _title; final BottomNavigationBarItem item; final AnimationController controller; - late Animation _animation; + Animation _animation; FadeTransition transition(BottomNavigationBarType type, BuildContext context) { - Color? iconColor; + Color iconColor; if (type == BottomNavigationBarType.shifting) { iconColor = _color; } else { @@ -79,8 +79,8 @@ class CustomIcon extends StatelessWidget { final IconThemeData iconTheme = IconTheme.of(context); return Container( margin: const EdgeInsets.all(4.0), - width: iconTheme.size! - 8.0, - height: iconTheme.size! - 8.0, + width: iconTheme.size - 8.0, + height: iconTheme.size - 8.0, color: iconTheme.color, ); } @@ -92,10 +92,10 @@ class CustomInactiveIcon extends StatelessWidget { final IconThemeData iconTheme = IconTheme.of(context); return Container( margin: const EdgeInsets.all(4.0), - width: iconTheme.size! - 8.0, - height: iconTheme.size! - 8.0, + width: iconTheme.size - 8.0, + height: iconTheme.size - 8.0, decoration: BoxDecoration( - border: Border.all(color: iconTheme.color!, width: 2.0), + border: Border.all(color: iconTheme.color, width: 2.0), ), ); } @@ -112,7 +112,7 @@ class _BottomNavigationDemoState extends State with TickerProviderStateMixin { int _currentIndex = 0; BottomNavigationBarType _type = BottomNavigationBarType.shifting; - late List _navigationViews; + List _navigationViews; @override void initState() { diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/buttons_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/buttons_demo.dart index 186a83e272..b73b114c58 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/buttons_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/buttons_demo.dart @@ -53,7 +53,7 @@ class ButtonsDemo extends StatefulWidget { } class _ButtonsDemoState extends State { - OutlinedBorder? _buttonShape; + OutlinedBorder _buttonShape; @override Widget build(BuildContext context) { @@ -118,7 +118,7 @@ class _ButtonsDemoState extends State { ); } - Widget buildElevatedButton(OutlinedBorder? shape) { + Widget buildElevatedButton(OutlinedBorder shape) { final ButtonStyle style = ElevatedButton.styleFrom(shape: shape); return Align( alignment: const Alignment(0.0, -0.2), @@ -156,7 +156,7 @@ class _ButtonsDemoState extends State { style: style, icon: const Icon(Icons.add, size: 18.0), label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 2'), - onPressed: () {}, + onPressed: null, ), ], ), @@ -165,7 +165,7 @@ class _ButtonsDemoState extends State { ); } - Widget buildTextButton(OutlinedBorder? shape) { + Widget buildTextButton(OutlinedBorder shape) { final ButtonStyle style = ElevatedButton.styleFrom(shape: shape); return Align( alignment: const Alignment(0.0, -0.2), @@ -203,7 +203,7 @@ class _ButtonsDemoState extends State { style: style, icon: const Icon(Icons.add_circle_outline, size: 18.0), label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 4'), - onPressed: () {}, + onPressed: null, ), ], ), @@ -212,7 +212,7 @@ class _ButtonsDemoState extends State { ); } - Widget buildOutlinedButton(OutlinedBorder? shape) { + Widget buildOutlinedButton(OutlinedBorder shape) { final ButtonStyle style = ElevatedButton.styleFrom(shape: shape); return Align( alignment: const Alignment(0.0, -0.2), @@ -260,9 +260,9 @@ class _ButtonsDemoState extends State { } // https://en.wikipedia.org/wiki/Free_Four - String? dropdown1Value = 'Free'; - String? dropdown2Value; - String? dropdown3Value = 'Four'; + String dropdown1Value = 'Free'; + String dropdown2Value; + String dropdown3Value = 'Four'; Widget buildDropdownButton() { return Padding( @@ -274,7 +274,7 @@ class _ButtonsDemoState extends State { title: const Text('Simple dropdown:'), trailing: DropdownButton( value: dropdown1Value, - onChanged: (String? newValue) { + onChanged: (String newValue) { setState(() { dropdown1Value = newValue; }); @@ -295,7 +295,7 @@ class _ButtonsDemoState extends State { trailing: DropdownButton( value: dropdown2Value, hint: const Text('Choose'), - onChanged: (String? newValue) { + onChanged: (String newValue) { setState(() { dropdown2Value = newValue; }); @@ -315,7 +315,7 @@ class _ButtonsDemoState extends State { title: const Text('Scrollable dropdown:'), trailing: DropdownButton( value: dropdown3Value, - onChanged: (String? newValue) { + onChanged: (String newValue) { setState(() { dropdown3Value = newValue; }); diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/cards_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/cards_demo.dart index 8233c517ba..60ccc6e6ce 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/cards_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/cards_demo.dart @@ -17,14 +17,19 @@ enum CardDemoType { class TravelDestination { const TravelDestination({ - required this.assetName, - required this.assetPackage, - required this.title, - required this.description, - required this.city, - required this.location, + @required this.assetName, + @required this.assetPackage, + @required this.title, + @required this.description, + @required this.city, + @required this.location, this.type = CardDemoType.standard, - }); + }) : assert(assetName != null), + assert(assetPackage != null), + assert(title != null), + assert(description != null), + assert(city != null), + assert(location != null); final String assetName; final String assetPackage; @@ -65,13 +70,14 @@ const List destinations = [ ]; class TravelDestinationItem extends StatelessWidget { - const TravelDestinationItem({ Key? key, required this.destination, this.shape }) - : super(key: key); + const TravelDestinationItem({ Key key, @required this.destination, this.shape }) + : assert(destination != null), + super(key: key); // This height will allow for all the Card's content to fit comfortably within the card. static const double height = 338.0; final TravelDestination destination; - final ShapeBorder? shape; + final ShapeBorder shape; @override Widget build(BuildContext context) { @@ -100,13 +106,14 @@ class TravelDestinationItem extends StatelessWidget { } class TappableTravelDestinationItem extends StatelessWidget { - const TappableTravelDestinationItem({ Key? key, required this.destination, this.shape }) - : super(key: key); + const TappableTravelDestinationItem({ Key key, @required this.destination, this.shape }) + : assert(destination != null), + super(key: key); // This height will allow for all the Card's content to fit comfortably within the card. static const double height = 298.0; final TravelDestination destination; - final ShapeBorder? shape; + final ShapeBorder shape; @override Widget build(BuildContext context) { @@ -144,11 +151,12 @@ class TappableTravelDestinationItem extends StatelessWidget { } class SelectableTravelDestinationItem extends StatefulWidget { - const SelectableTravelDestinationItem({ Key? key, required this.destination, this.shape }) - : super(key: key); + const SelectableTravelDestinationItem({ Key key, @required this.destination, this.shape }) + : assert(destination != null), + super(key: key); final TravelDestination destination; - final ShapeBorder? shape; + final ShapeBorder shape; @override _SelectableTravelDestinationItemState createState() => _SelectableTravelDestinationItemState(); @@ -223,11 +231,11 @@ class _SelectableTravelDestinationItemState extends State { - ShapeBorder? _shape; + ShapeBorder _shape; @override Widget build(BuildContext context) { @@ -376,7 +385,7 @@ class _CardsDemoState extends State { child: ListView( padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0), children: destinations.map((TravelDestination destination) { - Widget? child; + Widget child; switch (destination.type) { case CardDemoType.standard: child = TravelDestinationItem(destination: destination, shape: _shape); diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/chip_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/chip_demo.dart index 935015b90c..8ec3515977 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/chip_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/chip_demo.dart @@ -88,13 +88,13 @@ const Map> _materialActions = >{ class _ChipsTile extends StatelessWidget { const _ChipsTile({ - Key? key, + Key key, this.label, this.children, }) : super(key: key); - final String? label; - final List? children; + final String label; + final List children; // Wraps a list of chips into a ListTile for display as a section in the demo. @override @@ -107,11 +107,11 @@ class _ChipsTile extends StatelessWidget { Container( padding: const EdgeInsets.only(top: 16.0, bottom: 4.0), alignment: Alignment.center, - child: Text(label!, textAlign: TextAlign.start), + child: Text(label, textAlign: TextAlign.start), ), - if (children!.isNotEmpty) + if (children.isNotEmpty) Wrap( - children: children!.map((Widget chip) { + children: children.map((Widget chip) { return Padding( padding: const EdgeInsets.all(2.0), child: chip, @@ -125,7 +125,7 @@ class _ChipsTile extends StatelessWidget { alignment: Alignment.center, constraints: const BoxConstraints(minWidth: 48.0, minHeight: 48.0), padding: const EdgeInsets.all(8.0), - child: Text('None', style: Theme.of(context).textTheme.caption!.copyWith(fontStyle: FontStyle.italic)), + child: Text('None', style: Theme.of(context).textTheme.caption.copyWith(fontStyle: FontStyle.italic)), ), ), ], @@ -188,7 +188,7 @@ class _ChipDemoState extends State { } String _capitalize(String name) { - assert(name.isNotEmpty); + assert(name != null && name.isNotEmpty); return name.substring(0, 1).toUpperCase() + name.substring(1); } @@ -209,7 +209,7 @@ class _ChipDemoState extends State { AssetImage _nameToAvatar(String name) { assert(_avatars.containsKey(name)); return AssetImage( - _avatars[name]!, + _avatars[name], package: 'flutter_gallery_assets', ); } @@ -218,7 +218,7 @@ class _ChipDemoState extends State { if (_selectedAction.isEmpty) { return ''; } - return _capitalize(_results[_selectedAction]!) + '!'; + return _capitalize(_results[_selectedAction]) + '!'; } @override @@ -285,11 +285,11 @@ class _ChipDemoState extends State { }).toList(); Set allowedActions = {}; - if (_selectedMaterial.isNotEmpty) { + if (_selectedMaterial != null && _selectedMaterial.isNotEmpty) { for (final String tool in _selectedTools) { - allowedActions.addAll(_toolActions[tool]!); + allowedActions.addAll(_toolActions[tool]); } - allowedActions = allowedActions.intersection(_materialActions[_selectedMaterial]!); + allowedActions = allowedActions.intersection(_materialActions[_selectedMaterial]); } final List actionChips = allowedActions.map((String name) { diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/data_table_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/data_table_demo.dart index 51747dd065..07f090cc31 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/data_table_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/data_table_demo.dart @@ -18,7 +18,7 @@ class Dessert { final int calcium; final int iron; - bool? selected = false; + bool selected = false; } class DessertDataSource extends DataTableSource { @@ -96,17 +96,17 @@ class DessertDataSource extends DataTableSource { int _selectedCount = 0; @override - DataRow? getRow(int index) { + DataRow getRow(int index) { assert(index >= 0); if (index >= _desserts.length) return null; final Dessert dessert = _desserts[index]; return DataRow.byIndex( index: index, - selected: dessert.selected!, - onSelectChanged: (bool? value) { + selected: dessert.selected, + onSelectChanged: (bool value) { if (dessert.selected != value) { - _selectedCount += value! ? 1 : -1; + _selectedCount += value ? 1 : -1; assert(_selectedCount >= 0); dessert.selected = value; notifyListeners(); @@ -134,10 +134,10 @@ class DessertDataSource extends DataTableSource { @override int get selectedRowCount => _selectedCount; - void _selectAll(bool? checked) { + void _selectAll(bool checked) { for (final Dessert dessert in _desserts) dessert.selected = checked; - _selectedCount = checked! ? _desserts.length : 0; + _selectedCount = checked ? _desserts.length : 0; notifyListeners(); } } @@ -150,8 +150,8 @@ class DataTableDemo extends StatefulWidget { } class _DataTableDemoState extends State { - int? _rowsPerPage = PaginatedDataTable.defaultRowsPerPage; - int? _sortColumnIndex; + int _rowsPerPage = PaginatedDataTable.defaultRowsPerPage; + int _sortColumnIndex; bool _sortAscending = true; final DessertDataSource _dessertsDataSource = DessertDataSource(); @@ -178,8 +178,8 @@ class _DataTableDemoState extends State { children: [ PaginatedDataTable( header: const Text('Nutrition'), - rowsPerPage: _rowsPerPage!, - onRowsPerPageChanged: (int? value) { setState(() { _rowsPerPage = value; }); }, + rowsPerPage: _rowsPerPage, + onRowsPerPageChanged: (int value) { setState(() { _rowsPerPage = value; }); }, sortColumnIndex: _sortColumnIndex, sortAscending: _sortAscending, onSelectAll: _dessertsDataSource._selectAll, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/date_and_time_picker_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/date_and_time_picker_demo.dart index 3c89b74460..33307c2edf 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/date_and_time_picker_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/date_and_time_picker_demo.dart @@ -9,7 +9,7 @@ import '../../gallery/demo.dart'; class _InputDropdown extends StatelessWidget { const _InputDropdown({ - Key? key, + Key key, this.child, this.labelText, this.valueText, @@ -17,11 +17,11 @@ class _InputDropdown extends StatelessWidget { this.onPressed, }) : super(key: key); - final String? labelText; - final String? valueText; - final TextStyle? valueStyle; - final VoidCallback? onPressed; - final Widget? child; + final String labelText; + final String valueText; + final TextStyle valueStyle; + final VoidCallback onPressed; + final Widget child; @override Widget build(BuildContext context) { @@ -36,7 +36,7 @@ class _InputDropdown extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.min, children: [ - Text(valueText!, style: valueStyle), + Text(valueText, style: valueStyle), Icon(Icons.arrow_drop_down, color: Theme.of(context).brightness == Brightness.light ? Colors.grey.shade700 : Colors.white70, ), @@ -49,7 +49,7 @@ class _InputDropdown extends StatelessWidget { class _DateTimePicker extends StatelessWidget { const _DateTimePicker({ - Key? key, + Key key, this.labelText, this.selectedDate, this.selectedTime, @@ -57,35 +57,35 @@ class _DateTimePicker extends StatelessWidget { this.selectTime, }) : super(key: key); - final String? labelText; - final DateTime? selectedDate; - final TimeOfDay? selectedTime; - final ValueChanged? selectDate; - final ValueChanged? selectTime; + final String labelText; + final DateTime selectedDate; + final TimeOfDay selectedTime; + final ValueChanged selectDate; + final ValueChanged selectTime; Future _selectDate(BuildContext context) async { - final DateTime? picked = await showDatePicker( + final DateTime picked = await showDatePicker( context: context, - initialDate: selectedDate!, + initialDate: selectedDate, firstDate: DateTime(2015, 8), lastDate: DateTime(2101), ); if (picked != null && picked != selectedDate) - selectDate!(picked); + selectDate(picked); } Future _selectTime(BuildContext context) async { - final TimeOfDay? picked = await showTimePicker( + final TimeOfDay picked = await showTimePicker( context: context, - initialTime: selectedTime!, + initialTime: selectedTime, ); if (picked != null && picked != selectedTime) - selectTime!(picked); + selectTime(picked); } @override Widget build(BuildContext context) { - final TextStyle? valueStyle = Theme.of(context).textTheme.headline6; + final TextStyle valueStyle = Theme.of(context).textTheme.headline6; return Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ @@ -93,7 +93,7 @@ class _DateTimePicker extends StatelessWidget { flex: 4, child: _InputDropdown( labelText: labelText, - valueText: DateFormat.yMMMd().format(selectedDate!), + valueText: DateFormat.yMMMd().format(selectedDate), valueStyle: valueStyle, onPressed: () { _selectDate(context); }, ), @@ -102,7 +102,7 @@ class _DateTimePicker extends StatelessWidget { Expanded( flex: 3, child: _InputDropdown( - valueText: selectedTime!.format(context), + valueText: selectedTime.format(context), valueStyle: valueStyle, onPressed: () { _selectTime(context); }, ), @@ -125,7 +125,7 @@ class _DateAndTimePickerDemoState extends State { DateTime _toDate = DateTime.now(); TimeOfDay _toTime = const TimeOfDay(hour: 8, minute: 28); final List _allActivities = ['hiking', 'swimming', 'boating', 'fishing']; - String? _activity = 'fishing'; + String _activity = 'fishing'; @override Widget build(BuildContext context) { @@ -153,7 +153,7 @@ class _DateAndTimePickerDemoState extends State { decoration: const InputDecoration( labelText: 'Location', ), - style: Theme.of(context).textTheme.headline4!.copyWith(fontSize: 20.0), + style: Theme.of(context).textTheme.headline4.copyWith(fontSize: 20.0), ), _DateTimePicker( labelText: 'From', @@ -195,7 +195,7 @@ class _DateAndTimePickerDemoState extends State { isEmpty: _activity == null, child: DropdownButton( value: _activity, - onChanged: (String? newValue) { + onChanged: (String newValue) { setState(() { _activity = newValue; }); diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/dialog_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/dialog_demo.dart index b2fe440395..0561ec7492 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/dialog_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/dialog_demo.dart @@ -21,12 +21,12 @@ const String _alertWithTitleText = 'data to Google, even when no apps are running.'; class DialogDemoItem extends StatelessWidget { - const DialogDemoItem({ Key? key, this.icon, this.color, this.text, this.onPressed }) : super(key: key); + const DialogDemoItem({ Key key, this.icon, this.color, this.text, this.onPressed }) : super(key: key); - final IconData? icon; - final Color? color; - final String? text; - final VoidCallback? onPressed; + final IconData icon; + final Color color; + final String text; + final VoidCallback onPressed; @override Widget build(BuildContext context) { @@ -39,7 +39,7 @@ class DialogDemoItem extends StatelessWidget { Icon(icon, size: 36.0, color: color), Padding( padding: const EdgeInsets.only(left: 16.0), - child: Text(text!), + child: Text(text), ), ], ), @@ -56,7 +56,7 @@ class DialogDemo extends StatefulWidget { class DialogDemoState extends State { - TimeOfDay? _selectedTime; + TimeOfDay _selectedTime; @override void initState() { @@ -65,12 +65,12 @@ class DialogDemoState extends State { _selectedTime = TimeOfDay(hour: now.hour, minute: now.minute); } - void showDemoDialog({ required BuildContext context, Widget? child }) { + void showDemoDialog({ BuildContext context, Widget child }) { showDialog( context: context, - builder: (BuildContext context) => child!, + builder: (BuildContext context) => child, ) - .then((T? value) { // The value passed to Navigator.pop() or null. + .then((T value) { // The value passed to Navigator.pop() or null. if (value != null) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text('You selected: $value'), @@ -82,7 +82,7 @@ class DialogDemoState extends State { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - final TextStyle dialogTextStyle = theme.textTheme.subtitle1!.copyWith(color: theme.textTheme.caption!.color); + final TextStyle dialogTextStyle = theme.textTheme.subtitle1.copyWith(color: theme.textTheme.caption.color); return Scaffold( appBar: AppBar( @@ -176,9 +176,9 @@ class DialogDemoState extends State { onPressed: () { showTimePicker( context: context, - initialTime: _selectedTime!, + initialTime: _selectedTime, ) - .then((TimeOfDay? value) { + .then((TimeOfDay value) { if (value != null && value != _selectedTime) { _selectedTime = value; ScaffoldMessenger.of(context).showSnackBar(SnackBar( diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/drawer_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/drawer_demo.dart index 841a1e3deb..22c7a64265 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/drawer_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/drawer_demo.dart @@ -33,9 +33,9 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { curve: Curves.fastOutSlowIn, )); - late AnimationController _controller; - late Animation _drawerContentsOpacity; - late Animation _drawerDetailsPosition; + AnimationController _controller; + Animation _drawerContentsOpacity; + Animation _drawerDetailsPosition; bool _showDrawerContents = true; @override @@ -58,7 +58,7 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { super.dispose(); } - IconData? _backIcon() { + IconData _backIcon() { switch (Theme.of(context).platform) { case TargetPlatform.android: case TargetPlatform.fuchsia: @@ -69,6 +69,8 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { case TargetPlatform.macOS: return Icons.arrow_back_ios; } + assert(false); + return null; } void _showNotImplementedMessage() { @@ -209,7 +211,7 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { body: Center( child: InkWell( onTap: () { - _scaffoldKey.currentState!.openDrawer(); + _scaffoldKey.currentState.openDrawer(); }, child: Semantics( button: true, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/expansion_panels_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/expansion_panels_demo.dart index f76f861fe0..710905e8bf 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/expansion_panels_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/expansion_panels_demo.dart @@ -14,7 +14,7 @@ enum Location { } typedef DemoItemBodyBuilder = Widget Function(DemoItem item); -typedef ValueToString = String? Function(T value); +typedef ValueToString = String Function(T value); class DualHeaderWithHint extends StatelessWidget { const DualHeaderWithHint({ @@ -24,10 +24,10 @@ class DualHeaderWithHint extends StatelessWidget { this.showHint, }); - final String? name; - final String? value; - final String? hint; - final bool? showHint; + final String name; + final String value; + final String hint; + final bool showHint; Widget _crossFade(Widget first, Widget second, bool isExpanded) { return AnimatedCrossFade( @@ -56,8 +56,8 @@ class DualHeaderWithHint extends StatelessWidget { fit: BoxFit.scaleDown, alignment: Alignment.centerLeft, child: Text( - name!, - style: textTheme.bodyText2!.copyWith(fontSize: 15.0), + name, + style: textTheme.bodyText2.copyWith(fontSize: 15.0), ), ), ), @@ -67,9 +67,9 @@ class DualHeaderWithHint extends StatelessWidget { child: Container( margin: const EdgeInsets.only(left: 24.0), child: _crossFade( - Text(value!, style: textTheme.caption!.copyWith(fontSize: 15.0)), - Text(hint!, style: textTheme.caption!.copyWith(fontSize: 15.0)), - showHint!, + Text(value, style: textTheme.caption.copyWith(fontSize: 15.0)), + Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)), + showHint, ), ), ), @@ -87,9 +87,9 @@ class CollapsibleBody extends StatelessWidget { }); final EdgeInsets margin; - final Widget? child; - final VoidCallback? onSave; - final VoidCallback? onCancel; + final Widget child; + final VoidCallback onSave; + final VoidCallback onCancel; @override Widget build(BuildContext context) { @@ -106,8 +106,8 @@ class CollapsibleBody extends StatelessWidget { ) - margin, child: Center( child: DefaultTextStyle( - style: textTheme.caption!.copyWith(fontSize: 15.0), - child: child!, + style: textTheme.caption.copyWith(fontSize: 15.0), + child: child, ), ), ), @@ -149,15 +149,15 @@ class DemoItem { this.value, this.hint, this.builder, - required this.valueToString, + this.valueToString, }) : textController = TextEditingController(text: valueToString(value)); - final String? name; - final String? hint; + final String name; + final String hint; final TextEditingController textController; - final DemoItemBodyBuilder? builder; - final ValueToString valueToString; - T? value; + final DemoItemBodyBuilder builder; + final ValueToString valueToString; + T value; bool isExpanded = false; ExpansionPanelHeaderBuilder get headerBuilder { @@ -171,7 +171,7 @@ class DemoItem { }; } - Widget build() => builder!(this); + Widget build() => builder(this); } class ExpansionPanelsDemo extends StatefulWidget { @@ -182,7 +182,7 @@ class ExpansionPanelsDemo extends StatefulWidget { } class _ExpansionPanelsDemoState extends State { - late List> _demoItems; + List> _demoItems; @override void initState() { @@ -193,7 +193,7 @@ class _ExpansionPanelsDemoState extends State { name: 'Trip', value: 'Caribbean cruise', hint: 'Change trip name', - valueToString: (String? value) => value, + valueToString: (String value) => value, builder: (DemoItem item) { void close() { setState(() { @@ -206,8 +206,8 @@ class _ExpansionPanelsDemoState extends State { builder: (BuildContext context) { return CollapsibleBody( margin: const EdgeInsets.symmetric(horizontal: 16.0), - onSave: () { Form.of(context)!.save(); close(); }, - onCancel: () { Form.of(context)!.reset(); close(); }, + onSave: () { Form.of(context).save(); close(); }, + onCancel: () { Form.of(context).reset(); close(); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), child: TextFormField( @@ -216,7 +216,7 @@ class _ExpansionPanelsDemoState extends State { hintText: item.hint, labelText: item.name, ), - onSaved: (String? value) { item.value = value; }, + onSaved: (String value) { item.value = value; }, ), ), ); @@ -229,7 +229,7 @@ class _ExpansionPanelsDemoState extends State { name: 'Location', value: Location.Bahamas, hint: 'Select location', - valueToString: (Location? location) => location.toString().split('.')[1], + valueToString: (Location location) => location.toString().split('.')[1], builder: (DemoItem item) { void close() { setState(() { @@ -240,11 +240,11 @@ class _ExpansionPanelsDemoState extends State { child: Builder( builder: (BuildContext context) { return CollapsibleBody( - onSave: () { Form.of(context)!.save(); close(); }, - onCancel: () { Form.of(context)!.reset(); close(); }, + onSave: () { Form.of(context).save(); close(); }, + onCancel: () { Form.of(context).reset(); close(); }, child: FormField( initialValue: item.value, - onSaved: (Location? result) { item.value = result; }, + onSaved: (Location result) { item.value = result; }, builder: (FormFieldState field) { return Column( mainAxisSize: MainAxisSize.min, @@ -282,7 +282,7 @@ class _ExpansionPanelsDemoState extends State { name: 'Sun', value: 80.0, hint: 'Select sun level', - valueToString: (double? amount) => '${amount!.round()}', + valueToString: (double amount) => '${amount.round()}', builder: (DemoItem item) { void close() { setState(() { @@ -294,11 +294,11 @@ class _ExpansionPanelsDemoState extends State { child: Builder( builder: (BuildContext context) { return CollapsibleBody( - onSave: () { Form.of(context)!.save(); close(); }, - onCancel: () { Form.of(context)!.reset(); close(); }, + onSave: () { Form.of(context).save(); close(); }, + onCancel: () { Form.of(context).reset(); close(); }, child: FormField( initialValue: item.value, - onSaved: (double? value) { item.value = value; }, + onSaved: (double value) { item.value = value; }, builder: (FormFieldState field) { return Container( // Allow room for the value indicator. @@ -307,9 +307,9 @@ class _ExpansionPanelsDemoState extends State { min: 0.0, max: 100.0, divisions: 5, - activeColor: Colors.orange[100 + (field.value! * 5.0).round()], - label: '${field.value!.round()}', - value: field.value!, + activeColor: Colors.orange[100 + (field.value * 5.0).round()], + label: '${field.value.round()}', + value: field.value, onChanged: field.didChange, ), ); diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart index 5aefbec4ed..cf341b47a0 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart @@ -15,8 +15,9 @@ enum DismissDialogAction { } class DateTimeItem extends StatelessWidget { - DateTimeItem({ Key? key, required DateTime dateTime, required this.onChanged }) - : date = DateTime(dateTime.year, dateTime.month, dateTime.day), + DateTimeItem({ Key key, DateTime dateTime, @required this.onChanged }) + : assert(onChanged != null), + date = DateTime(dateTime.year, dateTime.month, dateTime.day), time = TimeOfDay(hour: dateTime.hour, minute: dateTime.minute), super(key: key); @@ -29,7 +30,7 @@ class DateTimeItem extends StatelessWidget { final ThemeData theme = Theme.of(context); return DefaultTextStyle( - style: theme.textTheme.subtitle1!, + style: theme.textTheme.subtitle1, child: Row( children: [ Expanded( @@ -46,7 +47,7 @@ class DateTimeItem extends StatelessWidget { firstDate: date.subtract(const Duration(days: 30)), lastDate: date.add(const Duration(days: 30)), ) - .then((DateTime? value) { + .then((DateTime value) { if (value != null) onChanged(DateTime(value.year, value.month, value.day, time.hour, time.minute)); }); @@ -73,7 +74,7 @@ class DateTimeItem extends StatelessWidget { context: context, initialTime: time, ) - .then((TimeOfDay? value) { + .then((TimeOfDay value) { if (value != null) onChanged(DateTime(date.year, date.month, date.day, value.hour, value.minute)); }); @@ -100,11 +101,11 @@ class FullScreenDialogDemo extends StatefulWidget { class FullScreenDialogDemoState extends State { DateTime _fromDateTime = DateTime.now(); DateTime _toDateTime = DateTime.now(); - bool? _allDayValue = false; + bool _allDayValue = false; bool _saveNeeded = false; bool _hasLocation = false; bool _hasName = false; - late String _eventName; + String _eventName; Future _onWillPop() async { _saveNeeded = _hasLocation || _hasName || _saveNeeded; @@ -112,9 +113,9 @@ class FullScreenDialogDemoState extends State { return true; final ThemeData theme = Theme.of(context); - final TextStyle dialogTextStyle = theme.textTheme.subtitle1!.copyWith(color: theme.textTheme.caption!.color); + final TextStyle dialogTextStyle = theme.textTheme.subtitle1.copyWith(color: theme.textTheme.caption.color); - return await (showDialog( + return await showDialog( context: context, builder: (BuildContext context) { return AlertDialog( @@ -126,19 +127,19 @@ class FullScreenDialogDemoState extends State { TextButton( child: const Text('CANCEL'), onPressed: () { - Navigator.of(context)!.pop(false); // Pops the confirmation dialog but not the page. + Navigator.of(context).pop(false); // Pops the confirmation dialog but not the page. }, ), TextButton( child: const Text('DISCARD'), onPressed: () { - Navigator.of(context)!.pop(true); // Returning true to _onWillPop will pop again. + Navigator.of(context).pop(true); // Returning true to _onWillPop will pop again. }, ), ], ); }, - ) as Future); + ) ?? false; } @override @@ -150,7 +151,7 @@ class FullScreenDialogDemoState extends State { title: Text(_hasName ? _eventName : 'Event Name TBD'), actions: [ TextButton( - child: Text('SAVE', style: theme.textTheme.bodyText2!.copyWith(color: Colors.white)), + child: Text('SAVE', style: theme.textTheme.bodyText2.copyWith(color: Colors.white)), onPressed: () { Navigator.pop(context, DismissDialogAction.save); }, @@ -237,7 +238,7 @@ class FullScreenDialogDemoState extends State { children: [ Checkbox( value: _allDayValue, - onChanged: (bool? value) { + onChanged: (bool value) { setState(() { _allDayValue = value; _saveNeeded = true; diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/grid_list_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/grid_list_demo.dart index bc887ce9ef..8c8144bd4c 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/grid_list_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/grid_list_demo.dart @@ -26,21 +26,21 @@ class Photo { this.isFavorite = false, }); - final String? assetName; - final String? assetPackage; - final String? title; - final String? caption; + final String assetName; + final String assetPackage; + final String title; + final String caption; bool isFavorite; - String? get tag => assetName; // Assuming that all asset names are unique. + String get tag => assetName; // Assuming that all asset names are unique. - bool get isValid => assetName != null && title != null && caption != null; + bool get isValid => assetName != null && title != null && caption != null && isFavorite != null; } class GridPhotoViewer extends StatefulWidget { - const GridPhotoViewer({ Key? key, this.photo }) : super(key: key); + const GridPhotoViewer({ Key key, this.photo }) : super(key: key); - final Photo? photo; + final Photo photo; @override _GridPhotoViewerState createState() => _GridPhotoViewerState(); @@ -49,25 +49,25 @@ class GridPhotoViewer extends StatefulWidget { class _GridTitleText extends StatelessWidget { const _GridTitleText(this.text); - final String? text; + final String text; @override Widget build(BuildContext context) { return FittedBox( fit: BoxFit.scaleDown, alignment: Alignment.centerLeft, - child: Text(text!), + child: Text(text), ); } } class _GridPhotoViewerState extends State with SingleTickerProviderStateMixin { - late AnimationController _controller; - late Animation _flingAnimation; + AnimationController _controller; + Animation _flingAnimation; Offset _offset = Offset.zero; double _scale = 1.0; - late Offset _normalizedOffset; - late double _previousScale; + Offset _normalizedOffset; + double _previousScale; @override void initState() { @@ -85,11 +85,11 @@ class _GridPhotoViewerState extends State with SingleTickerProv // The maximum offset value is 0,0. If the size of this renderer's box is w,h // then the minimum offset value is w - _scale * w, h - _scale * h. Offset _clampOffset(Offset offset) { - final Size size = context.size!; + final Size size = context.size; final Offset minOffset = Offset(size.width, size.height) * (1.0 - _scale); return Offset( - offset.dx.clamp(minOffset.dx, 0.0), - offset.dy.clamp(minOffset.dy, 0.0), + offset.dx.clamp(minOffset.dx, 0.0) as double, + offset.dy.clamp(minOffset.dy, 0.0) as double, ); } @@ -110,7 +110,7 @@ class _GridPhotoViewerState extends State with SingleTickerProv void _handleOnScaleUpdate(ScaleUpdateDetails details) { setState(() { - _scale = (_previousScale * details.scale).clamp(1.0, 4.0); + _scale = (_previousScale * details.scale).clamp(1.0, 4.0) as double; // Ensure that image location under the focal point stays in the same place despite scaling. _offset = _clampOffset(details.focalPoint - _normalizedOffset * _scale); }); @@ -121,7 +121,7 @@ class _GridPhotoViewerState extends State with SingleTickerProv if (magnitude < _kMinFlingVelocity) return; final Offset direction = details.velocity.pixelsPerSecond / magnitude; - final double distance = (Offset.zero & context.size!).shortestSide; + final double distance = (Offset.zero & context.size).shortestSide; _flingAnimation = _controller.drive(Tween( begin: _offset, end: _clampOffset(_offset + direction * distance), @@ -143,8 +143,8 @@ class _GridPhotoViewerState extends State with SingleTickerProv ..translate(_offset.dx, _offset.dy) ..scale(_scale), child: Image.asset( - widget.photo!.assetName!, - package: widget.photo!.assetPackage, + widget.photo.assetName, + package: widget.photo.assetPackage, fit: BoxFit.cover, ), ), @@ -155,11 +155,13 @@ class _GridPhotoViewerState extends State with SingleTickerProv class GridDemoPhotoItem extends StatelessWidget { GridDemoPhotoItem({ - Key? key, - required this.photo, - required this.tileStyle, - required this.onBannerTap, - }) : assert(photo.isValid), + Key key, + @required this.photo, + @required this.tileStyle, + @required this.onBannerTap, + }) : assert(photo != null && photo.isValid), + assert(tileStyle != null), + assert(onBannerTap != null), super(key: key); final Photo photo; @@ -171,11 +173,11 @@ class GridDemoPhotoItem extends StatelessWidget { builder: (BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(photo.title!), + title: Text(photo.title), ), body: SizedBox.expand( child: Hero( - tag: photo.tag!, + tag: photo.tag, child: GridPhotoViewer(photo: photo), ), ), @@ -191,10 +193,10 @@ class GridDemoPhotoItem extends StatelessWidget { child: GestureDetector( onTap: () { showPhoto(context); }, child: Hero( - key: Key(photo.assetName!), - tag: photo.tag!, + key: Key(photo.assetName), + tag: photo.tag, child: Image.asset( - photo.assetName!, + photo.assetName, package: photo.assetPackage, fit: BoxFit.cover, ), @@ -241,11 +243,13 @@ class GridDemoPhotoItem extends StatelessWidget { child: image, ); } + assert(tileStyle != null); + return null; } } class GridListDemo extends StatefulWidget { - const GridListDemo({ Key? key }) : super(key: key); + const GridListDemo({ Key key }) : super(key: key); static const String routeName = '/material/grid-list'; diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/icons_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/icons_demo.dart index 601e8c371a..a42e82fad4 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/icons_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/icons_demo.dart @@ -109,7 +109,7 @@ class _IconsDemoCard extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - final TextStyle textStyle = theme.textTheme.subtitle1!.copyWith(color: theme.textTheme.caption!.color); + final TextStyle textStyle = theme.textTheme.subtitle1.copyWith(color: theme.textTheme.caption.color); return Card( child: DefaultTextStyle( style: textStyle, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/leave_behind_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/leave_behind_demo.dart index 6c3b974546..53b204422d 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/leave_behind_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/leave_behind_demo.dart @@ -23,17 +23,17 @@ class LeaveBehindItem implements Comparable { LeaveBehindItem.from(LeaveBehindItem item) : index = item.index, name = item.name, subject = item.subject, body = item.body; - final int? index; - final String? name; - final String? subject; - final String? body; + final int index; + final String name; + final String subject; + final String body; @override - int compareTo(LeaveBehindItem other) => index!.compareTo(other.index!); + int compareTo(LeaveBehindItem other) => index.compareTo(other.index); } class LeaveBehindDemo extends StatefulWidget { - const LeaveBehindDemo({ Key? key }) : super(key: key); + const LeaveBehindDemo({ Key key }) : super(key: key); static const String routeName = '/material/leave-behind'; @@ -44,7 +44,7 @@ class LeaveBehindDemo extends StatefulWidget { class LeaveBehindDemoState extends State { DismissDirection _dismissDirection = DismissDirection.horizontal; bool _confirmDismiss = true; - late List leaveBehindItems; + List leaveBehindItems; void initListItems() { leaveBehindItems = List.generate(16, (int index) { @@ -188,12 +188,12 @@ class LeaveBehindDemoState extends State { class _LeaveBehindListItem extends StatelessWidget { const _LeaveBehindListItem({ - Key? key, - required this.item, - required this.onArchive, - required this.onDelete, - required this.dismissDirection, - required this.confirmDismiss, + Key key, + @required this.item, + @required this.onArchive, + @required this.onDelete, + @required this.dismissDirection, + @required this.confirmDismiss, }) : super(key: key); final LeaveBehindItem item; @@ -263,7 +263,7 @@ class _LeaveBehindListItem extends StatelessWidget { border: Border(bottom: BorderSide(color: theme.dividerColor)), ), child: ListTile( - title: Text(item.name!), + title: Text(item.name), subtitle: Text('${item.subject}\n${item.body}'), isThreeLine: true, ), @@ -272,7 +272,7 @@ class _LeaveBehindListItem extends StatelessWidget { ); } - Future _showConfirmationDialog(BuildContext context, String action) { + Future _showConfirmationDialog(BuildContext context, String action) { return showDialog( context: context, barrierDismissible: true, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/list_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/list_demo.dart index 9a32b1373d..45d778143e 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/list_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/list_demo.dart @@ -21,7 +21,7 @@ enum _MaterialListType { } class ListDemo extends StatefulWidget { - const ListDemo({ Key? key }) : super(key: key); + const ListDemo({ Key key }) : super(key: key); static const String routeName = '/material/list'; @@ -32,26 +32,26 @@ class ListDemo extends StatefulWidget { class _ListDemoState extends State { static final GlobalKey scaffoldKey = GlobalKey(); - PersistentBottomSheetController? _bottomSheet; - _MaterialListType? _itemType = _MaterialListType.threeLine; - bool? _dense = false; - bool? _showAvatars = true; - bool? _showIcons = false; - bool? _showDividers = false; + PersistentBottomSheetController _bottomSheet; + _MaterialListType _itemType = _MaterialListType.threeLine; + bool _dense = false; + bool _showAvatars = true; + bool _showIcons = false; + bool _showDividers = false; bool _reverseSort = false; List items = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', ]; - void changeItemType(_MaterialListType? type) { + void changeItemType(_MaterialListType type) { setState(() { _itemType = type; }); - _bottomSheet?.setState!(() { }); + _bottomSheet?.setState(() { }); } void _showConfigurationSheet() { - final PersistentBottomSheetController bottomSheet = scaffoldKey.currentState!.showBottomSheet((BuildContext bottomSheetContext) { + final PersistentBottomSheetController bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) { return Container( decoration: const BoxDecoration( border: Border(top: BorderSide(color: Colors.black26)), @@ -65,7 +65,7 @@ class _ListDemoState extends State { dense: true, title: const Text('One-line'), trailing: Radio<_MaterialListType>( - value: _showAvatars! ? _MaterialListType.oneLineWithAvatar : _MaterialListType.oneLine, + value: _showAvatars ? _MaterialListType.oneLineWithAvatar : _MaterialListType.oneLine, groupValue: _itemType, onChanged: changeItemType, ), @@ -99,14 +99,11 @@ class _ListDemoState extends State { title: const Text('Show avatar'), trailing: Checkbox( value: _showAvatars, - onChanged: (bool? value) { + onChanged: (bool value) { setState(() { _showAvatars = value; }); - final StateSetter? bottomSheetSetState = _bottomSheet?.setState; - if (bottomSheetSetState != null) { - bottomSheetSetState(() { }); - } + _bottomSheet?.setState(() { }); }, ), ), @@ -117,14 +114,11 @@ class _ListDemoState extends State { title: const Text('Show icon'), trailing: Checkbox( value: _showIcons, - onChanged: (bool? value) { + onChanged: (bool value) { setState(() { _showIcons = value; }); - final StateSetter? bottomSheetSetState = _bottomSheet?.setState; - if (bottomSheetSetState != null) { - bottomSheetSetState(() { }); - } + _bottomSheet?.setState(() { }); }, ), ), @@ -135,14 +129,11 @@ class _ListDemoState extends State { title: const Text('Show dividers'), trailing: Checkbox( value: _showDividers, - onChanged: (bool? value) { + onChanged: (bool value) { setState(() { _showDividers = value; }); - final StateSetter? bottomSheetSetState = _bottomSheet?.setState; - if (bottomSheetSetState != null) { - bottomSheetSetState(() { }); - } + _bottomSheet?.setState(() { }); }, ), ), @@ -153,14 +144,11 @@ class _ListDemoState extends State { title: const Text('Dense layout'), trailing: Checkbox( value: _dense, - onChanged: (bool? value) { + onChanged: (bool value) { setState(() { _dense = value; }); - final StateSetter? bottomSheetSetState = _bottomSheet?.setState; - if (bottomSheetSetState != null) { - bottomSheetSetState(() { }); - } + _bottomSheet?.setState(() { }); }, ), ), @@ -174,7 +162,7 @@ class _ListDemoState extends State { _bottomSheet = bottomSheet; }); - _bottomSheet?.closed.whenComplete(() { + _bottomSheet.closed.whenComplete(() { if (mounted) { setState(() { _bottomSheet = null; @@ -184,7 +172,7 @@ class _ListDemoState extends State { } Widget buildListTile(BuildContext context, String item) { - Widget? secondary; + Widget secondary; if (_itemType == _MaterialListType.twoLine) { secondary = const Text('Additional item information.'); } else if (_itemType == _MaterialListType.threeLine) { @@ -196,18 +184,18 @@ class _ListDemoState extends State { child: ListTile( isThreeLine: _itemType == _MaterialListType.threeLine, dense: _dense, - leading: _showAvatars != null ? ExcludeSemantics(child: CircleAvatar(child: Text(item))) : null, + leading: _showAvatars ? ExcludeSemantics(child: CircleAvatar(child: Text(item))) : null, title: Text('This item represents $item.'), subtitle: secondary, - trailing: _showIcons != null ? Icon(Icons.info, color: Theme.of(context).disabledColor) : null, + trailing: _showIcons ? Icon(Icons.info, color: Theme.of(context).disabledColor) : null, ), ); } @override Widget build(BuildContext context) { - final String layoutText = _dense != null ? ' \u2013 Dense' : ''; - String? itemTypeText; + final String layoutText = _dense ? ' \u2013 Dense' : ''; + String itemTypeText; switch (_itemType) { case _MaterialListType.oneLine: case _MaterialListType.oneLineWithAvatar: @@ -219,12 +207,10 @@ class _ListDemoState extends State { case _MaterialListType.threeLine: itemTypeText = 'Three-line'; break; - default: - break; } Iterable listTiles = items.map((String item) => buildListTile(context, item)); - if (_showDividers != null) + if (_showDividers) listTiles = ListTile.divideTiles(context: context, tiles: listTiles); return Scaffold( @@ -256,7 +242,7 @@ class _ListDemoState extends State { ), body: Scrollbar( child: ListView( - padding: EdgeInsets.symmetric(vertical: _dense != null ? 4.0 : 8.0), + padding: EdgeInsets.symmetric(vertical: _dense ? 4.0 : 8.0), children: listTiles.toList(), ), ), diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/menu_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/menu_demo.dart index c66bca38b3..c88627bd8b 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/menu_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/menu_demo.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; import '../../gallery/demo.dart'; class MenuDemo extends StatefulWidget { - const MenuDemo({ Key? key }) : super(key: key); + const MenuDemo({ Key key }) : super(key: key); static const String routeName = '/material/menu'; @@ -20,13 +20,13 @@ class MenuDemoState extends State { final String _simpleValue1 = 'Menu item value one'; final String _simpleValue2 = 'Menu item value two'; final String _simpleValue3 = 'Menu item value three'; - String? _simpleValue; + String _simpleValue; final String _checkedValue1 = 'One'; final String _checkedValue2 = 'Two'; final String _checkedValue3 = 'Free'; final String _checkedValue4 = 'Four'; - late List _checkedValues; + List _checkedValues; @override void initState() { @@ -165,7 +165,7 @@ class MenuDemoState extends State { onSelected: showMenuSelection, child: ListTile( title: const Text('An item with a simple menu'), - subtitle: Text(_simpleValue!), + subtitle: Text(_simpleValue), ), itemBuilder: (BuildContext context) => >[ PopupMenuItem( diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/overscroll_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/overscroll_demo.dart index 235a4cdc31..1b25b727a2 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/overscroll_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/overscroll_demo.dart @@ -11,7 +11,7 @@ import '../../gallery/demo.dart'; enum IndicatorType { overscroll, refresh } class OverscrollDemo extends StatefulWidget { - const OverscrollDemo({ Key? key }) : super(key: key); + const OverscrollDemo({ Key key }) : super(key: key); static const String routeName = '/material/overscroll'; @@ -28,13 +28,13 @@ class OverscrollDemoState extends State { Future _handleRefresh() { final Completer completer = Completer(); Timer(const Duration(seconds: 3), () { completer.complete(); }); - return completer.future.then((_) { + return completer.future.then((_) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: const Text('Refresh complete'), action: SnackBarAction( label: 'RETRY', onPressed: () { - _refreshIndicatorKey.currentState!.show(); + _refreshIndicatorKey.currentState.show(); }, ), )); @@ -52,7 +52,7 @@ class OverscrollDemoState extends State { icon: const Icon(Icons.refresh), tooltip: 'Refresh', onPressed: () { - _refreshIndicatorKey.currentState!.show(); + _refreshIndicatorKey.currentState.show(); }, ), ], diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/page_selector_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/page_selector_demo.dart index c22f5f0165..02b56b4e93 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/page_selector_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/page_selector_demo.dart @@ -9,17 +9,17 @@ import '../../gallery/demo.dart'; class _PageSelector extends StatelessWidget { const _PageSelector({ this.icons }); - final List? icons; + final List icons; void _handleArrowButtonPress(BuildContext context, int delta) { - final TabController controller = DefaultTabController.of(context)!; + final TabController controller = DefaultTabController.of(context); if (!controller.indexIsChanging) - controller.animateTo((controller.index + delta).clamp(0, icons!.length - 1)); + controller.animateTo((controller.index + delta).clamp(0, icons.length - 1) as int); } @override Widget build(BuildContext context) { - final TabController? controller = DefaultTabController.of(context); + final TabController controller = DefaultTabController.of(context); final Color color = Theme.of(context).accentColor; return SafeArea( top: false, @@ -54,7 +54,7 @@ class _PageSelector extends StatelessWidget { color: color, ), child: TabBarView( - children: icons!.map((Icon icon) { + children: icons.map((Icon icon) { return Container( padding: const EdgeInsets.all(12.0), child: Card( diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/persistent_bottom_sheet_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/persistent_bottom_sheet_demo.dart index a1c9d51e3d..3937ff16b2 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/persistent_bottom_sheet_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/persistent_bottom_sheet_demo.dart @@ -16,7 +16,7 @@ class PersistentBottomSheetDemo extends StatefulWidget { class _PersistentBottomSheetDemoState extends State { final GlobalKey _scaffoldKey = GlobalKey(); - VoidCallback? _showBottomSheetCallback; + VoidCallback _showBottomSheetCallback; @override void initState() { @@ -28,7 +28,7 @@ class _PersistentBottomSheetDemoState extends State { setState(() { // disable the button _showBottomSheetCallback = null; }); - _scaffoldKey.currentState!.showBottomSheet((BuildContext context) { + _scaffoldKey.currentState.showBottomSheet((BuildContext context) { final ThemeData themeData = Theme.of(context); return Container( decoration: BoxDecoration( diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/progress_indicator_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/progress_indicator_demo.dart index 7f1b4970ac..1c4a2f4dc1 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/progress_indicator_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/progress_indicator_demo.dart @@ -14,8 +14,8 @@ class ProgressIndicatorDemo extends StatefulWidget { } class _ProgressIndicatorDemoState extends State with SingleTickerProviderStateMixin { - late AnimationController _controller; - late Animation _animation; + AnimationController _controller; + Animation _animation; @override void initState() { @@ -64,7 +64,7 @@ class _ProgressIndicatorDemoState extends State with Sing }); } - Widget _buildIndicators(BuildContext context, Widget? child) { + Widget _buildIndicators(BuildContext context, Widget child) { final List indicators = [ const SizedBox( width: 200.0, @@ -109,7 +109,7 @@ class _ProgressIndicatorDemoState extends State with Sing body: Center( child: SingleChildScrollView( child: DefaultTextStyle( - style: Theme.of(context).textTheme.headline6!, + style: Theme.of(context).textTheme.headline6, child: GestureDetector( onTap: _handleTap, behavior: HitTestBehavior.opaque, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/reorderable_list_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/reorderable_list_demo.dart index d9425d3483..34917c5075 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/reorderable_list_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/reorderable_list_demo.dart @@ -20,7 +20,7 @@ enum _ReorderableListType { } class ReorderableListDemo extends StatefulWidget { - const ReorderableListDemo({ Key? key }) : super(key: key); + const ReorderableListDemo({ Key key }) : super(key: key); static const String routeName = '/material/reorderable-list'; @@ -33,38 +33,38 @@ class _ListItem { final String value; - bool? checkState; + bool checkState; } class _ListDemoState extends State { static final GlobalKey scaffoldKey = GlobalKey(); - PersistentBottomSheetController? _bottomSheet; - _ReorderableListType? _itemType = _ReorderableListType.threeLine; - bool? _reverse = false; + PersistentBottomSheetController _bottomSheet; + _ReorderableListType _itemType = _ReorderableListType.threeLine; + bool _reverse = false; bool _reverseSort = false; final List<_ListItem> _items = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', ].map<_ListItem>((String item) => _ListItem(item, false)).toList(); - void changeItemType(_ReorderableListType? type) { + void changeItemType(_ReorderableListType type) { setState(() { _itemType = type; }); // Rebuild the bottom sheet to reflect the selected list view. - _bottomSheet?.setState!(() { + _bottomSheet?.setState(() { // Trigger a rebuild. }); // Close the bottom sheet to give the user a clear view of the list. _bottomSheet?.close(); } - void changeReverse(bool? newValue) { + void changeReverse(bool newValue) { setState(() { _reverse = newValue; }); // Rebuild the bottom sheet to reflect the selected list view. - _bottomSheet?.setState!(() { + _bottomSheet?.setState(() { // Trigger a rebuild. }); // Close the bottom sheet to give the user a clear view of the list. @@ -73,7 +73,7 @@ class _ListDemoState extends State { void _showConfigurationSheet() { setState(() { - _bottomSheet = scaffoldKey.currentState!.showBottomSheet((BuildContext bottomSheetContext) { + _bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) { return DecoratedBox( decoration: const BoxDecoration( border: Border(top: BorderSide(color: Colors.black26)), @@ -115,7 +115,7 @@ class _ListDemoState extends State { }); // Garbage collect the bottom sheet when it closes. - _bottomSheet?.closed.whenComplete(() { + _bottomSheet.closed.whenComplete(() { if (mounted) { setState(() { _bottomSheet = null; @@ -129,14 +129,14 @@ class _ListDemoState extends State { const Widget secondary = Text( 'Even more additional list item information appears on line three.', ); - late Widget listTile; + Widget listTile; switch (_itemType) { case _ReorderableListType.threeLine: listTile = CheckboxListTile( key: Key(item.value), isThreeLine: true, value: item.checkState ?? false, - onChanged: (bool? newValue) { + onChanged: (bool newValue) { setState(() { item.checkState = newValue; }); @@ -157,11 +157,6 @@ class _ListDemoState extends State { ), ); break; - default: - listTile = Container( - key: Key(item.value), - ); - break; } return listTile; @@ -215,7 +210,7 @@ class _ListDemoState extends State { child: Text('Header of the list', style: Theme.of(context).textTheme.headline5)) : null, onReorder: _onReorder, - reverse: _reverse!, + reverse: _reverse, scrollDirection: _itemType == _ReorderableListType.horizontalAvatar ? Axis.horizontal : Axis.vertical, padding: const EdgeInsets.symmetric(vertical: 8.0), children: _items.map(buildListTile).toList(), diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/scrollable_tabs_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/scrollable_tabs_demo.dart index 17ef3def98..1b90e8af7a 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/scrollable_tabs_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/scrollable_tabs_demo.dart @@ -14,8 +14,8 @@ enum TabsDemoStyle { class _Page { const _Page({ this.icon, this.text }); - final IconData? icon; - final String? text; + final IconData icon; + final String text; } const List<_Page> _allPages = <_Page>[ @@ -43,7 +43,7 @@ class ScrollableTabsDemo extends StatefulWidget { } class ScrollableTabsDemoState extends State with SingleTickerProviderStateMixin { - TabController? _controller; + TabController _controller; TabsDemoStyle _demoStyle = TabsDemoStyle.iconsAndText; bool _customIndicator = false; @@ -55,7 +55,7 @@ class ScrollableTabsDemoState extends State with SingleTicke @override void dispose() { - _controller!.dispose(); + _controller.dispose(); super.dispose(); } @@ -65,7 +65,7 @@ class ScrollableTabsDemoState extends State with SingleTicke }); } - Decoration? getIndicator() { + Decoration getIndicator() { if (!_customIndicator) return const UnderlineTabIndicator(); @@ -117,6 +117,7 @@ class ScrollableTabsDemoState extends State with SingleTicke ), ); } + return null; } @override @@ -160,6 +161,7 @@ class ScrollableTabsDemoState extends State with SingleTicke isScrollable: true, indicator: getIndicator(), tabs: _allPages.map((_Page page) { + assert(_demoStyle != null); switch (_demoStyle) { case TabsDemoStyle.iconsAndText: return Tab(text: page.text, icon: Icon(page.icon)); @@ -167,10 +169,9 @@ class ScrollableTabsDemoState extends State with SingleTicke return Tab(icon: Icon(page.icon)); case TabsDemoStyle.textOnly: return Tab(text: page.text); - default: - return Tab(); } - }).toList() + return null; + }).toList(), ), ), body: TabBarView( diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/search_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/search_demo.dart index 2ef49eba6c..cba1512c8b 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/search_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/search_demo.dart @@ -17,7 +17,7 @@ class _SearchDemoState extends State { final _SearchDemoSearchDelegate _delegate = _SearchDemoSearchDelegate(); final GlobalKey _scaffoldKey = GlobalKey(); - int? _lastIntegerSelected; + int _lastIntegerSelected; @override Widget build(BuildContext context) { @@ -32,7 +32,7 @@ class _SearchDemoState extends State { progress: _delegate.transitionAnimation, ), onPressed: () { - _scaffoldKey.currentState!.openDrawer(); + _scaffoldKey.currentState.openDrawer(); }, ), title: const Text('Numbers'), @@ -41,7 +41,7 @@ class _SearchDemoState extends State { tooltip: 'Search', icon: const Icon(Icons.search), onPressed: () async { - final int? selected = await showSearch( + final int selected = await showSearch( context: context, delegate: _delegate, ); @@ -98,7 +98,7 @@ class _SearchDemoState extends State { floatingActionButton: FloatingActionButton.extended( tooltip: 'Back', // Tests depend on this label to exit the demo. onPressed: () { - Navigator.of(context)!.pop(); + Navigator.of(context).pop(); }, label: const Text('Close demo'), icon: const Icon(Icons.close), @@ -133,7 +133,7 @@ class _SearchDemoState extends State { } } -class _SearchDemoSearchDelegate extends SearchDelegate { +class _SearchDemoSearchDelegate extends SearchDelegate { final List _data = List.generate(100001, (int i) => i).reversed.toList(); final List _history = [42607, 85604, 66374, 44, 174]; @@ -170,7 +170,7 @@ class _SearchDemoSearchDelegate extends SearchDelegate { @override Widget buildResults(BuildContext context) { - final int? searched = int.tryParse(query); + final int searched = int.tryParse(query); if (searched == null || !_data.contains(searched)) { return Center( child: Text( @@ -228,26 +228,26 @@ class _SearchDemoSearchDelegate extends SearchDelegate { class _ResultCard extends StatelessWidget { const _ResultCard({this.integer, this.title, this.searchDelegate}); - final int? integer; - final String? title; - final SearchDelegate? searchDelegate; + final int integer; + final String title; + final SearchDelegate searchDelegate; @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); return GestureDetector( onTap: () { - searchDelegate!.close(context, integer); + searchDelegate.close(context, integer); }, child: Card( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ - Text(title!), + Text(title), Text( '$integer', - style: theme.textTheme.headline5!.copyWith(fontSize: 72.0), + style: theme.textTheme.headline5.copyWith(fontSize: 72.0), ), ], ), @@ -260,33 +260,33 @@ class _ResultCard extends StatelessWidget { class _SuggestionList extends StatelessWidget { const _SuggestionList({this.suggestions, this.query, this.onSelected}); - final List? suggestions; - final String? query; - final ValueChanged? onSelected; + final List suggestions; + final String query; + final ValueChanged onSelected; @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); return ListView.builder( - itemCount: suggestions!.length, + itemCount: suggestions.length, itemBuilder: (BuildContext context, int i) { - final String suggestion = suggestions![i]; + final String suggestion = suggestions[i]; return ListTile( - leading: query!.isEmpty ? const Icon(Icons.history) : const Icon(null), + leading: query.isEmpty ? const Icon(Icons.history) : const Icon(null), title: RichText( text: TextSpan( - text: suggestion.substring(0, query!.length), - style: theme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.bold), + text: suggestion.substring(0, query.length), + style: theme.textTheme.subtitle1.copyWith(fontWeight: FontWeight.bold), children: [ TextSpan( - text: suggestion.substring(query!.length), + text: suggestion.substring(query.length), style: theme.textTheme.subtitle1, ), ], ), ), onTap: () { - onSelected!(suggestion); + onSelected(suggestion); }, ); }, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/selection_controls_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/selection_controls_demo.dart index ef77a6c6d9..dd15ca12d5 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/selection_controls_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/selection_controls_demo.dart @@ -67,13 +67,13 @@ class _SelectionControlsDemoState extends State { ); } - bool? checkboxValueA = true; - bool? checkboxValueB = false; - bool? checkboxValueC; - int? radioValue = 0; + bool checkboxValueA = true; + bool checkboxValueB = false; + bool checkboxValueC; + int radioValue = 0; bool switchValue = false; - void handleRadioValueChanged(int? value) { + void handleRadioValueChanged(int value) { setState(() { radioValue = value; }); @@ -92,7 +92,7 @@ class _SelectionControlsDemoState extends State { label: 'Checkbox A', child: Checkbox( value: checkboxValueA, - onChanged: (bool? value) { + onChanged: (bool value) { setState(() { checkboxValueA = value; }); @@ -103,7 +103,7 @@ class _SelectionControlsDemoState extends State { label: 'Checkbox B', child: Checkbox( value: checkboxValueB, - onChanged: (bool? value) { + onChanged: (bool value) { setState(() { checkboxValueB = value; }); @@ -115,7 +115,7 @@ class _SelectionControlsDemoState extends State { child: Checkbox( value: checkboxValueC, tristate: true, - onChanged: (bool? value) { + onChanged: (bool value) { setState(() { checkboxValueC = value; }); diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/slider_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/slider_demo.dart index b96412debc..fd0f0e5de9 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/slider_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/slider_demo.dart @@ -61,15 +61,15 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape { void paint( PaintingContext context, Offset center, { - required Animation activationAnimation, - required Animation enableAnimation, + @required Animation activationAnimation, + @required Animation enableAnimation, bool isDiscrete = false, bool isEnabled = false, - bool? isOnTop, - required SliderThemeData sliderTheme, - TextDirection? textDirection, - Thumb? thumb, - bool? isPressed, + bool isOnTop, + @required SliderThemeData sliderTheme, + TextDirection textDirection, + Thumb thumb, + bool isPressed, }) { final Canvas canvas = context.canvas; final ColorTween colorTween = ColorTween( @@ -78,7 +78,7 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape { ); final double size = _thumbSize * sizeTween.evaluate(enableAnimation); - late Path thumbPath; + Path thumbPath; switch (textDirection) { case TextDirection.rtl: switch (thumb) { @@ -88,8 +88,6 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape { case Thumb.end: thumbPath = _leftTriangle(size, center); break; - default: - break; } break; case TextDirection.ltr: @@ -100,14 +98,10 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape { case Thumb.end: thumbPath = _rightTriangle(size, center); break; - default: - break; } break; - default: - break; } - canvas.drawPath(thumbPath, Paint()..color = colorTween.evaluate(enableAnimation)!); + canvas.drawPath(thumbPath, Paint()..color = colorTween.evaluate(enableAnimation)); } } @@ -129,16 +123,16 @@ class _CustomThumbShape extends SliderComponentShape { void paint( PaintingContext context, Offset thumbCenter, { - Animation? activationAnimation, - required Animation enableAnimation, - bool? isDiscrete, - TextPainter? labelPainter, - RenderBox? parentBox, - required SliderThemeData sliderTheme, - TextDirection? textDirection, - double? value, - double? textScaleFactor, - Size? sizeWithOverflow, + Animation activationAnimation, + Animation enableAnimation, + bool isDiscrete, + TextPainter labelPainter, + RenderBox parentBox, + SliderThemeData sliderTheme, + TextDirection textDirection, + double value, + double textScaleFactor, + Size sizeWithOverflow, }) { final Canvas canvas = context.canvas; final ColorTween colorTween = ColorTween( @@ -147,7 +141,7 @@ class _CustomThumbShape extends SliderComponentShape { ); final double size = _thumbSize * sizeTween.evaluate(enableAnimation); final Path thumbPath = _downTriangle(size, thumbCenter); - canvas.drawPath(thumbPath, Paint()..color = colorTween.evaluate(enableAnimation)!); + canvas.drawPath(thumbPath, Paint()..color = colorTween.evaluate(enableAnimation)); } } @@ -170,16 +164,16 @@ class _CustomValueIndicatorShape extends SliderComponentShape { void paint( PaintingContext context, Offset thumbCenter, { - required Animation activationAnimation, - required Animation enableAnimation, - bool? isDiscrete, - required TextPainter labelPainter, - RenderBox? parentBox, - required SliderThemeData sliderTheme, - TextDirection? textDirection, - double? value, - double? textScaleFactor, - Size? sizeWithOverflow, + Animation activationAnimation, + Animation enableAnimation, + bool isDiscrete, + TextPainter labelPainter, + RenderBox parentBox, + SliderThemeData sliderTheme, + TextDirection textDirection, + double value, + double textScaleFactor, + Size sizeWithOverflow, }) { final Canvas canvas = context.canvas; final ColorTween enableColor = ColorTween( @@ -193,7 +187,7 @@ class _CustomValueIndicatorShape extends SliderComponentShape { final double size = _indicatorSize * sizeTween.evaluate(enableAnimation); final Offset slideUpOffset = Offset(0.0, -slideUpTween.evaluate(activationAnimation)); final Path thumbPath = _upTriangle(size, thumbCenter + slideUpOffset); - final Color paintColor = enableColor.evaluate(enableAnimation)!.withAlpha((255.0 * activationAnimation.value).round()); + final Color paintColor = enableColor.evaluate(enableAnimation).withAlpha((255.0 * activationAnimation.value).round()); canvas.drawPath( thumbPath, Paint()..color = paintColor, @@ -265,10 +259,10 @@ class _SlidersState extends State<_Sliders> { child: TextField( textAlign: TextAlign.center, onSubmitted: (String value) { - final double? newValue = double.tryParse(value); + final double newValue = double.tryParse(value); if (newValue != null && newValue != _continuousValue) { setState(() { - _continuousValue = newValue.clamp(0.0, 100.0); + _continuousValue = newValue.clamp(0.0, 100.0) as double; }); } }, @@ -332,7 +326,7 @@ class _SlidersState extends State<_Sliders> { valueIndicatorColor: Colors.deepPurpleAccent, thumbShape: _CustomThumbShape(), valueIndicatorShape: _CustomValueIndicatorShape(), - valueIndicatorTextStyle: theme.accentTextTheme.bodyText1!.copyWith(color: theme.colorScheme.onSurface), + valueIndicatorTextStyle: theme.accentTextTheme.bodyText1.copyWith(color: theme.colorScheme.onSurface), ), child: Slider( value: _discreteCustomValue, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/snack_bar_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/snack_bar_demo.dart index 2eb5947fd3..682f85dd5b 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/snack_bar_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/snack_bar_demo.dart @@ -19,7 +19,7 @@ const String _text3 = 'By default snackbars automatically disappear after a few seconds '; class SnackBarDemo extends StatefulWidget { - const SnackBarDemo({ Key? key }) : super(key: key); + const SnackBarDemo({ Key key }) : super(key: key); static const String routeName = '/material/snack-bar'; diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/tabs_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/tabs_demo.dart index b2ff9e77ad..9f94906c9a 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/tabs_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/tabs_demo.dart @@ -13,17 +13,17 @@ const String _kGalleryAssetsPackage = 'flutter_gallery_assets'; class _Page { _Page({ this.label }); - final String? label; - String get id => label!.characters.first; + final String label; + String get id => label.characters.first; @override String toString() => '$runtimeType("$label")'; } class _CardData { const _CardData({ this.title, this.imageAsset, this.imageAssetPackage }); - final String? title; - final String? imageAsset; - final String? imageAssetPackage; + final String title; + final String imageAsset; + final String imageAssetPackage; } final Map<_Page, List<_CardData>> _allPages = <_Page, List<_CardData>>{ @@ -97,8 +97,8 @@ class _CardDataItem extends StatelessWidget { const _CardDataItem({ this.page, this.data }); static const double height = 272.0; - final _Page? page; - final _CardData? data; + final _Page page; + final _CardData data; @override Widget build(BuildContext context) { @@ -110,23 +110,23 @@ class _CardDataItem extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, children: [ Align( - alignment: page!.id == 'H' + alignment: page.id == 'H' ? Alignment.centerLeft : Alignment.centerRight, - child: CircleAvatar(child: Text(page!.id)), + child: CircleAvatar(child: Text(page.id)), ), SizedBox( width: 144.0, height: 144.0, child: Image.asset( - data!.imageAsset!, - package: data!.imageAssetPackage, + data.imageAsset, + package: data.imageAssetPackage, fit: BoxFit.contain, ), ), Center( child: Text( - data!.title!, + data.title, style: Theme.of(context).textTheme.headline6, ), ), @@ -187,7 +187,7 @@ class TabsDemo extends StatelessWidget { itemExtent: _CardDataItem.height, delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { - final _CardData data = _allPages[page]![index]; + final _CardData data = _allPages[page][index]; return Padding( padding: const EdgeInsets.symmetric( vertical: 8.0, @@ -198,7 +198,7 @@ class TabsDemo extends StatelessWidget { ), ); }, - childCount: _allPages[page]!.length, + childCount: _allPages[page].length, ), ), ), diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/tabs_fab_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/tabs_fab_demo.dart index 31bab87f18..9daa09126e 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/tabs_fab_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/tabs_fab_demo.dart @@ -15,13 +15,13 @@ const String _explanatoryText = class _Page { _Page({ this.label, this.colors, this.icon }); - final String? label; - final MaterialColor? colors; - final IconData? icon; + final String label; + final MaterialColor colors; + final IconData icon; - Color get labelColor => colors != null ? colors!.shade300 : Colors.grey.shade300; + Color get labelColor => colors != null ? colors.shade300 : Colors.grey.shade300; bool get fabDefined => colors != null && icon != null; - Color get fabColor => colors!.shade400; + Color get fabColor => colors.shade400; Icon get fabIcon => Icon(icon); Key get fabKey => ValueKey(fabColor); } @@ -44,32 +44,32 @@ class TabsFabDemo extends StatefulWidget { class _TabsFabDemoState extends State with SingleTickerProviderStateMixin { final GlobalKey _scaffoldKey = GlobalKey(); - TabController? _controller; - late _Page _selectedPage; + TabController _controller; + _Page _selectedPage; bool _extendedButtons = false; @override void initState() { super.initState(); _controller = TabController(vsync: this, length: _allPages.length); - _controller!.addListener(_handleTabSelection); + _controller.addListener(_handleTabSelection); _selectedPage = _allPages[0]; } @override void dispose() { - _controller!.dispose(); + _controller.dispose(); super.dispose(); } void _handleTabSelection() { setState(() { - _selectedPage = _allPages[_controller!.index]; + _selectedPage = _allPages[_controller.index]; }); } void _showExplanatoryText() { - _scaffoldKey.currentState!.showBottomSheet((BuildContext context) { + _scaffoldKey.currentState.showBottomSheet((BuildContext context) { return Container( decoration: BoxDecoration( border: Border(top: BorderSide(color: Theme.of(context).dividerColor)) @@ -86,11 +86,11 @@ class _TabsFabDemoState extends State with SingleTickerProviderStat return Builder( builder: (BuildContext context) { return Container( - key: ValueKey(page.label), + key: ValueKey(page.label), padding: const EdgeInsets.fromLTRB(48.0, 48.0, 48.0, 96.0), child: Card( child: Center( - child: Text(page.label!, + child: Text(page.label, style: TextStyle( color: page.labelColor, fontSize: 32.0, @@ -104,7 +104,7 @@ class _TabsFabDemoState extends State with SingleTickerProviderStat ); } - Widget? buildFloatingActionButton(_Page page) { + Widget buildFloatingActionButton(_Page page) { if (!page.fabDefined) return null; @@ -114,7 +114,7 @@ class _TabsFabDemoState extends State with SingleTickerProviderStat tooltip: 'Show explanation', backgroundColor: page.fabColor, icon: page.fabIcon, - label: Text(page.label!.toUpperCase()), + label: Text(page.label.toUpperCase()), onPressed: _showExplanatoryText, ); } @@ -136,7 +136,7 @@ class _TabsFabDemoState extends State with SingleTickerProviderStat title: const Text('FAB per tab'), bottom: TabBar( controller: _controller, - tabs: _allPages.map((_Page page) => Tab(text: page.label!.toUpperCase())).toList(), + tabs: _allPages.map((_Page page) => Tab(text: page.label.toUpperCase())).toList(), ), actions: [ MaterialDemoDocumentationButton(TabsFabDemo.routeName), diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/text_form_field_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/text_form_field_demo.dart index d65bf3e3cd..5c1ccf5c33 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/text_form_field_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/text_form_field_demo.dart @@ -9,7 +9,7 @@ import 'package:flutter/gestures.dart' show DragStartBehavior; import '../../gallery/demo.dart'; class TextFormFieldDemo extends StatefulWidget { - const TextFormFieldDemo({ Key? key }) : super(key: key); + const TextFormFieldDemo({ Key key }) : super(key: key); static const String routeName = '/material/text-form-field'; @@ -18,9 +18,9 @@ class TextFormFieldDemo extends StatefulWidget { } class PersonData { - String? name = ''; - String? phoneNumber = ''; - String? email = ''; + String name = ''; + String phoneNumber = ''; + String email = ''; String password = ''; } @@ -35,13 +35,13 @@ class PasswordField extends StatefulWidget { this.onFieldSubmitted, }); - final Key? fieldKey; - final String? hintText; - final String? labelText; - final String? helperText; - final FormFieldSetter? onSaved; - final FormFieldValidator? validator; - final ValueChanged? onFieldSubmitted; + final Key fieldKey; + final String hintText; + final String labelText; + final String helperText; + final FormFieldSetter onSaved; + final FormFieldValidator validator; + final ValueChanged onFieldSubmitted; @override _PasswordFieldState createState() => _PasswordFieldState(); @@ -99,7 +99,7 @@ class TextFormFieldDemoState extends State { final GlobalKey> _passwordFieldKey = GlobalKey>(); final _UsNumberTextInputFormatter _phoneNumberFormatter = _UsNumberTextInputFormatter(); void _handleSubmitted() { - final FormState form = _formKey.currentState!; + final FormState form = _formKey.currentState; if (!form.validate()) { _autovalidateMode = AutovalidateMode.always; // Start validating on every change. showInSnackBar('Please fix the errors in red before submitting.'); @@ -109,9 +109,9 @@ class TextFormFieldDemoState extends State { } } - String? _validateName(String? value) { + String _validateName(String value) { _formWasEdited = true; - if (value!.isEmpty) + if (value.isEmpty) return 'Name is required.'; final RegExp nameExp = RegExp(r'^[A-Za-z ]+$'); if (!nameExp.hasMatch(value)) @@ -119,18 +119,18 @@ class TextFormFieldDemoState extends State { return null; } - String? _validatePhoneNumber(String? value) { + String _validatePhoneNumber(String value) { _formWasEdited = true; final RegExp phoneExp = RegExp(r'^\(\d\d\d\) \d\d\d\-\d\d\d\d$'); - if (!phoneExp.hasMatch(value!)) + if (!phoneExp.hasMatch(value)) return '(###) ###-#### - Enter a US phone number.'; return null; } - String? _validatePassword(String? value) { + String _validatePassword(String value) { _formWasEdited = true; - final FormFieldState passwordField = _passwordFieldKey.currentState!; - if (passwordField.value == null || passwordField.value!.isEmpty) + final FormFieldState passwordField = _passwordFieldKey.currentState; + if (passwordField.value == null || passwordField.value.isEmpty) return 'Please enter a password.'; if (passwordField.value != value) return "The passwords don't match"; @@ -138,11 +138,11 @@ class TextFormFieldDemoState extends State { } Future _warnUserAboutInvalidData() async { - final FormState? form = _formKey.currentState; + final FormState form = _formKey.currentState; if (form == null || !_formWasEdited || form.validate()) return true; - return await (showDialog( + return await showDialog( context: context, builder: (BuildContext context) { return AlertDialog( @@ -151,16 +151,16 @@ class TextFormFieldDemoState extends State { actions: [ TextButton( child: const Text('YES'), - onPressed: () { Navigator.of(context)!.pop(true); }, + onPressed: () { Navigator.of(context).pop(true); }, ), TextButton( child: const Text('NO'), - onPressed: () { Navigator.of(context)!.pop(false); }, + onPressed: () { Navigator.of(context).pop(false); }, ), ], ); }, - ) as Future); + ) ?? false; } @override @@ -195,7 +195,7 @@ class TextFormFieldDemoState extends State { hintText: 'What do people call you?', labelText: 'Name *', ), - onSaved: (String? value) { person.name = value; }, + onSaved: (String value) { person.name = value; }, validator: _validateName, ), const SizedBox(height: 24.0), @@ -209,7 +209,7 @@ class TextFormFieldDemoState extends State { prefixText: '+1', ), keyboardType: TextInputType.phone, - onSaved: (String? value) { person.phoneNumber = value; }, + onSaved: (String value) { person.phoneNumber = value; }, validator: _validatePhoneNumber, // TextInputFormatters are applied in sequence. inputFormatters: [ @@ -228,7 +228,7 @@ class TextFormFieldDemoState extends State { labelText: 'E-mail', ), keyboardType: TextInputType.emailAddress, - onSaved: (String? value) { person.email = value; }, + onSaved: (String value) { person.email = value; }, ), const SizedBox(height: 24.0), TextFormField( @@ -265,7 +265,7 @@ class TextFormFieldDemoState extends State { ), const SizedBox(height: 24.0), TextFormField( - enabled: person.password.isNotEmpty, + enabled: person.password != null && person.password.isNotEmpty, decoration: const InputDecoration( border: UnderlineInputBorder(), filled: true, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/pesto_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/pesto_demo.dart index 613994e66c..b6838fd56b 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/pesto_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/pesto_demo.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; class PestoDemo extends StatelessWidget { - const PestoDemo({ Key? key }) : super(key: key); + const PestoDemo({ Key key }) : super(key: key); static const String routeName = '/pesto'; @@ -21,7 +21,7 @@ const double _kAppBarHeight = 128.0; const double _kFabHalfSize = 28.0; // TODO(mpcomplete): needs to adapt to screen size const double _kRecipePageMaxWidth = 500.0; -final Set _favoriteRecipes = {}; +final Set _favoriteRecipes = {}; final ThemeData _kTheme = ThemeData( brightness: Brightness.light, @@ -46,10 +46,10 @@ class PestoFavorites extends StatelessWidget { class PestoStyle extends TextStyle { const PestoStyle({ double fontSize = 12.0, - FontWeight? fontWeight, + FontWeight fontWeight, Color color = Colors.black87, - double? letterSpacing, - double? height, + double letterSpacing, + double height, }) : super( inherit: false, color: color, @@ -64,9 +64,9 @@ class PestoStyle extends TextStyle { // Displays a grid of recipe cards. class RecipeGridPage extends StatefulWidget { - const RecipeGridPage({ Key? key, this.recipes }) : super(key: key); + const RecipeGridPage({ Key key, this.recipes }) : super(key: key); - final List? recipes; + final List recipes; @override _RecipeGridPageState createState() => _RecipeGridPageState(); @@ -89,7 +89,7 @@ class _RecipeGridPageState extends State { }, ), body: CustomScrollView( - semanticChildCount: widget.recipes!.length, + semanticChildCount: widget.recipes.length, slivers: [ _buildAppBar(context, statusBarHeight), _buildBody(context, statusBarHeight), @@ -127,7 +127,7 @@ class _RecipeGridPageState extends State { bottom: extraPadding, ), child: Center( - child: PestoLogo(height: logoHeight, t: t.clamp(0.0, 1.0)), + child: PestoLogo(height: logoHeight, t: t.clamp(0.0, 1.0) as double), ), ); }, @@ -153,13 +153,13 @@ class _RecipeGridPageState extends State { ), delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { - final Recipe? recipe = widget.recipes![index]; + final Recipe recipe = widget.recipes[index]; return RecipeCard( recipe: recipe, onTap: () { showRecipePage(context, recipe); }, ); }, - childCount: widget.recipes!.length, + childCount: widget.recipes.length, ), ), ); @@ -172,7 +172,7 @@ class _RecipeGridPageState extends State { )); } - void showRecipePage(BuildContext context, Recipe? recipe) { + void showRecipePage(BuildContext context, Recipe recipe) { Navigator.push(context, MaterialPageRoute( settings: const RouteSettings(name: '/pesto/recipe'), builder: (BuildContext context) { @@ -188,8 +188,8 @@ class _RecipeGridPageState extends State { class PestoLogo extends StatefulWidget { const PestoLogo({this.height, this.t}); - final double? height; - final double? t; + final double height; + final double t; @override _PestoLogoState createState() => _PestoLogoState(); @@ -217,7 +217,7 @@ class _PestoLogoState extends State { return Semantics( namesRoute: true, child: Transform( - transform: Matrix4.identity()..scale(widget.height! / kLogoHeight), + transform: Matrix4.identity()..scale(widget.height / kLogoHeight), alignment: Alignment.topCenter, child: SizedBox( width: kLogoWidth, @@ -225,7 +225,7 @@ class _PestoLogoState extends State { clipBehavior: Clip.none, children: [ Positioned.fromRect( - rect: _imageRectTween.lerp(widget.t!)!, + rect: _imageRectTween.lerp(widget.t), child: Image.asset( _kSmallLogoImage, package: _kGalleryAssetsPackage, @@ -233,9 +233,9 @@ class _PestoLogoState extends State { ), ), Positioned.fromRect( - rect: _textRectTween.lerp(widget.t!)!, + rect: _textRectTween.lerp(widget.t), child: Opacity( - opacity: _textOpacity.transform(widget.t!), + opacity: _textOpacity.transform(widget.t), child: Text('PESTO', style: titleStyle, textAlign: TextAlign.center), ), ), @@ -249,10 +249,10 @@ class _PestoLogoState extends State { // A card with the recipe's image, author, and title. class RecipeCard extends StatelessWidget { - const RecipeCard({ Key? key, this.recipe, this.onTap }) : super(key: key); + const RecipeCard({ Key key, this.recipe, this.onTap }) : super(key: key); - final Recipe? recipe; - final VoidCallback? onTap; + final Recipe recipe; + final VoidCallback onTap; TextStyle get titleStyle => const PestoStyle(fontSize: 24.0, fontWeight: FontWeight.w600); TextStyle get authorStyle => const PestoStyle(fontWeight: FontWeight.w500, color: Colors.black54); @@ -266,14 +266,14 @@ class RecipeCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Hero( - tag: 'packages/$_kGalleryAssetsPackage/${recipe!.imagePath}', + tag: 'packages/$_kGalleryAssetsPackage/${recipe.imagePath}', child: AspectRatio( aspectRatio: 4.0 / 3.0, child: Image.asset( - recipe!.imagePath!, - package: recipe!.imagePackage, + recipe.imagePath, + package: recipe.imagePackage, fit: BoxFit.cover, - semanticLabel: recipe!.name, + semanticLabel: recipe.name, ), ), ), @@ -283,8 +283,8 @@ class RecipeCard extends StatelessWidget { Padding( padding: const EdgeInsets.all(16.0), child: Image.asset( - recipe!.ingredientsImagePath!, - package: recipe!.ingredientsImagePackage, + recipe.ingredientsImagePath, + package: recipe.ingredientsImagePackage, width: 48.0, height: 48.0, ), @@ -294,8 +294,8 @@ class RecipeCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ - Text(recipe!.name!, style: titleStyle, softWrap: false, overflow: TextOverflow.ellipsis), - Text(recipe!.author!, style: authorStyle), + Text(recipe.name, style: titleStyle, softWrap: false, overflow: TextOverflow.ellipsis), + Text(recipe.author, style: authorStyle), ], ), ), @@ -311,9 +311,9 @@ class RecipeCard extends StatelessWidget { // Displays one recipe. Includes the recipe sheet with a background image. class RecipePage extends StatefulWidget { - const RecipePage({ Key? key, this.recipe }) : super(key: key); + const RecipePage({ Key key, this.recipe }) : super(key: key); - final Recipe? recipe; + final Recipe recipe; @override _RecipePageState createState() => _RecipePageState(); @@ -342,10 +342,10 @@ class _RecipePageState extends State { right: 0.0, height: appBarHeight + _kFabHalfSize, child: Hero( - tag: 'packages/$_kGalleryAssetsPackage/${widget.recipe!.imagePath}', + tag: 'packages/$_kGalleryAssetsPackage/${widget.recipe.imagePath}', child: Image.asset( - widget.recipe!.imagePath!, - package: widget.recipe!.imagePackage, + widget.recipe.imagePath, + package: widget.recipe.imagePackage, fit: fullWidth ? BoxFit.fitWidth : BoxFit.cover, ), ), @@ -429,7 +429,7 @@ class _RecipePageState extends State { /// Displays the recipe's name and instructions. class RecipeSheet extends StatelessWidget { - RecipeSheet({ Key? key, this.recipe }) : super(key: key); + RecipeSheet({ Key key, this.recipe }) : super(key: key); final TextStyle titleStyle = const PestoStyle(fontSize: 34.0); final TextStyle descriptionStyle = const PestoStyle(fontSize: 15.0, color: Colors.black54, height: 24.0/15.0); @@ -437,7 +437,7 @@ class RecipeSheet extends StatelessWidget { final TextStyle itemAmountStyle = PestoStyle(fontSize: 15.0, color: _kTheme.primaryColor, height: 24.0/15.0); final TextStyle headingStyle = const PestoStyle(fontSize: 16.0, fontWeight: FontWeight.bold, height: 24.0/15.0); - final Recipe? recipe; + final Recipe recipe; @override Widget build(BuildContext context) { @@ -457,8 +457,8 @@ class RecipeSheet extends StatelessWidget { TableCell( verticalAlignment: TableCellVerticalAlignment.middle, child: Image.asset( - recipe!.ingredientsImagePath!, - package: recipe!.ingredientsImagePackage, + recipe.ingredientsImagePath, + package: recipe.ingredientsImagePackage, width: 32.0, height: 32.0, alignment: Alignment.centerLeft, @@ -467,7 +467,7 @@ class RecipeSheet extends StatelessWidget { ), TableCell( verticalAlignment: TableCellVerticalAlignment.middle, - child: Text(recipe!.name!, style: titleStyle), + child: Text(recipe.name, style: titleStyle), ), ] ), @@ -476,7 +476,7 @@ class RecipeSheet extends StatelessWidget { const SizedBox(), Padding( padding: const EdgeInsets.only(top: 8.0, bottom: 4.0), - child: Text(recipe!.description!, style: descriptionStyle), + child: Text(recipe.description, style: descriptionStyle), ), ] ), @@ -489,8 +489,8 @@ class RecipeSheet extends StatelessWidget { ), ] ), - ...recipe!.ingredients!.map((RecipeIngredient ingredient) { - return _buildItemRow(ingredient.amount!, ingredient.description!); + ...recipe.ingredients.map((RecipeIngredient ingredient) { + return _buildItemRow(ingredient.amount, ingredient.description); }), TableRow( children: [ @@ -501,8 +501,8 @@ class RecipeSheet extends StatelessWidget { ), ] ), - ...recipe!.steps!.map((RecipeStep step) { - return _buildItemRow(step.duration ?? '', step.description!); + ...recipe.steps.map((RecipeStep step) { + return _buildItemRow(step.duration ?? '', step.description); }), ], ), @@ -540,29 +540,29 @@ class Recipe { this.steps, }); - final String? name; - final String? author; - final String? description; - final String? imagePath; - final String? imagePackage; - final String? ingredientsImagePath; - final String? ingredientsImagePackage; - final List? ingredients; - final List? steps; + final String name; + final String author; + final String description; + final String imagePath; + final String imagePackage; + final String ingredientsImagePath; + final String ingredientsImagePackage; + final List ingredients; + final List steps; } class RecipeIngredient { const RecipeIngredient({this.amount, this.description}); - final String? amount; - final String? description; + final String amount; + final String description; } class RecipeStep { const RecipeStep({this.duration, this.description}); - final String? duration; - final String? description; + final String duration; + final String description; } const List kPestoRecipes = [ diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/app.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/app.dart index 2c38d8893e..720634a10a 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/app.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/app.dart @@ -20,7 +20,7 @@ class ShrineApp extends StatefulWidget { class _ShrineAppState extends State with SingleTickerProviderStateMixin { // Controller to coordinate both the opening/closing of backdrop and sliding // of expanding bottom sheet - late AnimationController _controller; + AnimationController _controller; @override void initState() { @@ -55,7 +55,7 @@ class _ShrineAppState extends State with SingleTickerProviderStateMix } } -Route? _getRoute(RouteSettings settings) { +Route _getRoute(RouteSettings settings) { if (settings.name != '/login') { return null; } @@ -98,11 +98,11 @@ ThemeData _buildShrineTheme() { TextTheme _buildShrineTextTheme(TextTheme base) { return base.copyWith( - headline5: base.headline5!.copyWith(fontWeight: FontWeight.w500), - headline6: base.headline6!.copyWith(fontSize: 18.0), - caption: base.caption!.copyWith(fontWeight: FontWeight.w400, fontSize: 14.0), - bodyText1: base.bodyText1!.copyWith(fontWeight: FontWeight.w500, fontSize: 16.0), - button: base.button!.copyWith(fontWeight: FontWeight.w500, fontSize: 14.0), + headline5: base.headline5.copyWith(fontWeight: FontWeight.w500), + headline6: base.headline6.copyWith(fontSize: 18.0), + caption: base.caption.copyWith(fontWeight: FontWeight.w400, fontSize: 14.0), + bodyText1: base.bodyText1.copyWith(fontWeight: FontWeight.w500, fontSize: 16.0), + button: base.button.copyWith(fontWeight: FontWeight.w500, fontSize: 14.0), ).apply( fontFamily: 'Raleway', displayColor: kShrineBrown900, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/backdrop.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/backdrop.dart index 89e05f1b2e..4e85d65242 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/backdrop.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/backdrop.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'package:flutter/material.dart'; +import 'package:meta/meta.dart'; import 'package:flutter_gallery/demo/shrine/login.dart'; @@ -14,37 +15,37 @@ const double _kPeakVelocityProgress = 0.379146; class _TappableWhileStatusIs extends StatefulWidget { const _TappableWhileStatusIs( this.status, { - Key? key, + Key key, this.controller, this.child, }) : super(key: key); - final AnimationController? controller; + final AnimationController controller; final AnimationStatus status; - final Widget? child; + final Widget child; @override _TappableWhileStatusIsState createState() => _TappableWhileStatusIsState(); } class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { - bool? _active; + bool _active; @override void initState() { super.initState(); - widget.controller!.addStatusListener(_handleStatusChange); - _active = widget.controller!.status == widget.status; + widget.controller.addStatusListener(_handleStatusChange); + _active = widget.controller.status == widget.status; } @override void dispose() { - widget.controller!.removeStatusListener(_handleStatusChange); + widget.controller.removeStatusListener(_handleStatusChange); super.dispose(); } void _handleStatusChange(AnimationStatus status) { - final bool value = widget.controller!.status == widget.status; + final bool value = widget.controller.status == widget.status; if (_active != value) { setState(() { _active = value; @@ -55,11 +56,11 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { @override Widget build(BuildContext context) { Widget child = AbsorbPointer( - absorbing: !_active!, + absorbing: !_active, child: widget.child, ); - if (!_active!) { + if (!_active) { child = FocusScope( canRequestFocus: false, debugLabel: '$_TappableWhileStatusIs', @@ -72,13 +73,13 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { class _FrontLayer extends StatelessWidget { const _FrontLayer({ - Key? key, + Key key, this.onTap, this.child, }) : super(key: key); - final VoidCallback? onTap; - final Widget? child; + final VoidCallback onTap; + final Widget child; @override Widget build(BuildContext context) { @@ -99,7 +100,7 @@ class _FrontLayer extends StatelessWidget { ), ), Expanded( - child: child!, + child: child, ), ], ), @@ -109,14 +110,16 @@ class _FrontLayer extends StatelessWidget { class _BackdropTitle extends AnimatedWidget { const _BackdropTitle({ - Key? key, - required Animation listenable, + Key key, + Animation listenable, this.onPress, - required this.frontTitle, - required this.backTitle, - }) : super(key: key, listenable: listenable); + @required this.frontTitle, + @required this.backTitle, + }) : assert(frontTitle != null), + assert(backTitle != null), + super(key: key, listenable: listenable); - final void Function()? onPress; + final void Function() onPress; final Widget frontTitle; final Widget backTitle; @@ -128,7 +131,7 @@ class _BackdropTitle extends AnimatedWidget { ); return DefaultTextStyle( - style: Theme.of(context).primaryTextTheme.headline6!, + style: Theme.of(context).primaryTextTheme.headline6, softWrap: false, overflow: TextOverflow.ellipsis, child: Row(children: [ @@ -198,12 +201,16 @@ class _BackdropTitle extends AnimatedWidget { /// front or back layer is showing. class Backdrop extends StatefulWidget { const Backdrop({ - required this.frontLayer, - required this.backLayer, - required this.frontTitle, - required this.backTitle, - required this.controller, - }); + @required this.frontLayer, + @required this.backLayer, + @required this.frontTitle, + @required this.backTitle, + @required this.controller, + }) : assert(frontLayer != null), + assert(backLayer != null), + assert(frontTitle != null), + assert(backTitle != null), + assert(controller != null); final Widget frontLayer; final Widget backLayer; @@ -217,8 +224,8 @@ class Backdrop extends StatefulWidget { class _BackdropState extends State with SingleTickerProviderStateMixin { final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop'); - AnimationController? _controller; - late Animation _layerAnimation; + AnimationController _controller; + Animation _layerAnimation; @override void initState() { @@ -228,19 +235,19 @@ class _BackdropState extends State with SingleTickerProviderStateMixin @override void dispose() { - _controller!.dispose(); + _controller.dispose(); super.dispose(); } bool get _frontLayerVisible { - final AnimationStatus status = _controller!.status; + final AnimationStatus status = _controller.status; return status == AnimationStatus.completed || status == AnimationStatus.forward; } void _toggleBackdropLayerVisibility() { // Call setState here to update layerAnimation if that's necessary setState(() { - _frontLayerVisible ? _controller!.reverse() : _controller!.forward(); + _frontLayerVisible ? _controller.reverse() : _controller.forward(); }); } @@ -260,7 +267,7 @@ class _BackdropState extends State with SingleTickerProviderStateMixin firstWeight = _kPeakVelocityTime; secondWeight = 1.0 - _kPeakVelocityTime; animation = CurvedAnimation( - parent: _controller!.view, + parent: _controller.view, curve: const Interval(0.0, 0.78), ); } else { @@ -269,7 +276,7 @@ class _BackdropState extends State with SingleTickerProviderStateMixin secondCurve = _kAccelerateCurve.flipped; firstWeight = 1.0 - _kPeakVelocityTime; secondWeight = _kPeakVelocityTime; - animation = _controller!.view; + animation = _controller.view; } return TweenSequence( @@ -344,7 +351,7 @@ class _BackdropState extends State with SingleTickerProviderStateMixin elevation: 0.0, titleSpacing: 0.0, title: _BackdropTitle( - listenable: _controller!.view, + listenable: _controller.view, onPress: _toggleBackdropLayerVisibility, frontTitle: widget.frontTitle, backTitle: widget.backTitle, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/category_menu_page.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/category_menu_page.dart index 891ee40a78..da08a80826 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/category_menu_page.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/category_menu_page.dart @@ -11,22 +11,22 @@ import 'package:flutter_gallery/demo/shrine/model/product.dart'; class CategoryMenuPage extends StatelessWidget { const CategoryMenuPage({ - Key? key, + Key key, this.onCategoryTap, }) : super(key: key); - final VoidCallback? onCategoryTap; + final VoidCallback onCategoryTap; Widget _buildCategory(Category category, BuildContext context) { final String categoryString = category.toString().replaceAll('Category.', '').toUpperCase(); final ThemeData theme = Theme.of(context); return ScopedModelDescendant( - builder: (BuildContext context, Widget? child, AppStateModel model) => + builder: (BuildContext context, Widget child, AppStateModel model) => GestureDetector( onTap: () { model.setCategory(category); if (onCategoryTap != null) { - onCategoryTap!(); + onCategoryTap(); } }, child: model.selectedCategory == category @@ -50,7 +50,7 @@ class CategoryMenuPage extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 16.0), child: Text( categoryString, - style: theme.textTheme.bodyText1!.copyWith( + style: theme.textTheme.bodyText1.copyWith( color: kShrineBrown900.withAlpha(153) ), textAlign: TextAlign.center, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/expanding_bottom_sheet.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/expanding_bottom_sheet.dart index 8b1fc80dd1..d62e9bc4e4 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/expanding_bottom_sheet.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/expanding_bottom_sheet.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:meta/meta.dart'; import 'package:scoped_model/scoped_model.dart'; import 'package:flutter_gallery/demo/shrine/colors.dart'; @@ -25,16 +26,19 @@ const double _kCornerRadius = 24.0; const double _kWidthForCartIcon = 64.0; class ExpandingBottomSheet extends StatefulWidget { - const ExpandingBottomSheet({Key? key, required this.hideController}) - : super(key: key); + const ExpandingBottomSheet({Key key, @required this.hideController}) + : assert(hideController != null), + super(key: key); final AnimationController hideController; @override _ExpandingBottomSheetState createState() => _ExpandingBottomSheetState(); - static _ExpandingBottomSheetState? of(BuildContext context, {bool isNullOk = false}) { - final _ExpandingBottomSheetState? result = context.findAncestorStateOfType<_ExpandingBottomSheetState>(); + static _ExpandingBottomSheetState of(BuildContext context, {bool isNullOk = false}) { + assert(isNullOk != null); + assert(context != null); + final _ExpandingBottomSheetState result = context.findAncestorStateOfType<_ExpandingBottomSheetState>(); if (isNullOk || result != null) { return result; } @@ -49,11 +53,11 @@ class ExpandingBottomSheet extends StatefulWidget { // curve formula. It's quintic, not cubic. But it _can_ be expressed as one // curve followed by another, which we do here. Animation _getEmphasizedEasingAnimation({ - required T begin, - required T peak, - required T end, - required bool isForward, - required Animation parent, + @required T begin, + @required T peak, + @required T end, + @required bool isForward, + @required Animation parent, }) { Curve firstCurve; Curve secondCurve; @@ -94,7 +98,7 @@ Animation _getEmphasizedEasingAnimation({ // Calculates the value where two double Animations should be joined. Used by // callers of _getEmphasisedEasing(). -double _getPeakPoint({required double begin, required double end}) { +double _getPeakPoint({double begin, double end}) { return begin + (end - begin) * _kPeakVelocityProgress; } @@ -107,15 +111,15 @@ class _ExpandingBottomSheetState extends State with Ticker double _width = _kWidthForCartIcon; // Controller for the opening and closing of the ExpandingBottomSheet - late AnimationController _controller; + AnimationController _controller; // Animations for the opening and closing of the ExpandingBottomSheet - late Animation _widthAnimation; - late Animation _heightAnimation; - late Animation _thumbnailOpacityAnimation; - late Animation _cartOpacityAnimation; - late Animation _shapeAnimation; - late Animation _slideAnimation; + Animation _widthAnimation; + Animation _heightAnimation; + Animation _thumbnailOpacityAnimation; + Animation _cartOpacityAnimation; + Animation _shapeAnimation; + Animation _slideAnimation; @override void initState() { @@ -304,7 +308,7 @@ class _ExpandingBottomSheetState extends State with Ticker ); } - Widget _buildCart(BuildContext context, Widget? child) { + Widget _buildCart(BuildContext context, Widget child) { // numProducts is the number of different products in the cart (does not // include multiples of the same product). final AppStateModel model = ScopedModel.of(context); @@ -345,7 +349,7 @@ class _ExpandingBottomSheetState extends State with Ticker } // Builder for the hide and reveal animation when the backdrop opens and closes - Widget _buildSlideAnimation(BuildContext context, Widget? child) { + Widget _buildSlideAnimation(BuildContext context, Widget child) { _slideAnimation = _getEmphasizedEasingAnimation( begin: const Offset(1.0, 0.0), peak: const Offset(_kPeakVelocityProgress, 0.0), @@ -389,7 +393,7 @@ class _ExpandingBottomSheetState extends State with Ticker behavior: HitTestBehavior.opaque, onTap: open, child: ScopedModelDescendant( - builder: (BuildContext context, Widget? child, AppStateModel model) { + builder: (BuildContext context, Widget child, AppStateModel model) { return AnimatedBuilder( builder: _buildCart, animation: _controller, @@ -413,10 +417,10 @@ class _ProductThumbnailRowState extends State { // _list represents what's currently on screen. If _internalList updates, // it will need to be updated to match it. - late _ListModel _list; + _ListModel _list; // _internalList represents the list as it is updated by the AppStateModel. - late List _internalList; + List _internalList; @override void initState() { @@ -432,6 +436,7 @@ class _ProductThumbnailRowState extends State { Product _productWithId(int productId) { final AppStateModel model = ScopedModel.of(context); final Product product = model.getProductById(productId); + assert(product != null); return product; } @@ -505,7 +510,7 @@ class _ProductThumbnailRowState extends State { Widget build(BuildContext context) { _updateLists(); return ScopedModelDescendant( - builder: (BuildContext context, Widget? child, AppStateModel model) => _buildAnimatedList(), + builder: (BuildContext context, Widget child, AppStateModel model) => _buildAnimatedList(), ); } } @@ -524,7 +529,7 @@ class ExtraProductsNumber extends StatelessWidget { final int numProducts = products.length; if (numProducts > 3) { for (int i = 3; i < numProducts; i++) { - overflow += productMap[products[i]]!; + overflow += productMap[products[i]]; } } return overflow; @@ -548,7 +553,7 @@ class ExtraProductsNumber extends StatelessWidget { @override Widget build(BuildContext context) { return ScopedModelDescendant( - builder: (BuildContext builder, Widget? child, AppStateModel model) => _buildOverflow(model, context), + builder: (BuildContext builder, Widget child, AppStateModel model) => _buildOverflow(model, context), ); } } @@ -589,16 +594,18 @@ class ProductThumbnail extends StatelessWidget { // _ListModel manipulates an internal list and an AnimatedList class _ListModel { _ListModel({ - required this.listKey, - required this.removedItemBuilder, - Iterable? initialItems, - }) : _items = initialItems?.toList() ?? []; + @required this.listKey, + @required this.removedItemBuilder, + Iterable initialItems, + }) : assert(listKey != null), + assert(removedItemBuilder != null), + _items = initialItems?.toList() ?? []; final GlobalKey listKey; final Widget Function(int item, BuildContext context, Animation animation) removedItemBuilder; final List _items; - AnimatedListState? get _animatedList => listKey.currentState; + AnimatedListState get _animatedList => listKey.currentState; void add(int product) { _insert(_items.length, product); @@ -606,7 +613,7 @@ class _ListModel { void _insert(int index, int item) { _items.insert(index, item); - _animatedList!.insertItem(index, duration: const Duration(milliseconds: 225)); + _animatedList.insertItem(index, duration: const Duration(milliseconds: 225)); } void remove(int product) { @@ -618,9 +625,11 @@ class _ListModel { void _removeAt(int index) { final int removedItem = _items.removeAt(index); - _animatedList!.removeItem(index, (BuildContext context, Animation animation) { - return removedItemBuilder(removedItem, context, animation); - }); + if (removedItem != null) { + _animatedList.removeItem(index, (BuildContext context, Animation animation) { + return removedItemBuilder(removedItem, context, animation); + }); + } } int get length => _items.length; diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/home.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/home.dart index fb16a0da8a..da3393d7da 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/home.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/home.dart @@ -19,7 +19,7 @@ class ProductPage extends StatelessWidget { @override Widget build(BuildContext context) { return ScopedModelDescendant( - builder: (BuildContext context, Widget? child, AppStateModel model) { + builder: (BuildContext context, Widget child, AppStateModel model) { return AsymmetricView(products: model.getProducts()); }); } @@ -29,18 +29,17 @@ class HomePage extends StatelessWidget { const HomePage({ this.expandingBottomSheet, this.backdrop, - Key? key, + Key key, }) : super(key: key); - final ExpandingBottomSheet? expandingBottomSheet; - final Backdrop? backdrop; + final ExpandingBottomSheet expandingBottomSheet; + final Backdrop backdrop; @override Widget build(BuildContext context) { return Stack( children: [ - if (backdrop != null) - backdrop!, + backdrop, Align(child: expandingBottomSheet, alignment: Alignment.bottomRight), ], ); diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/login.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/login.dart index 3061a41e7d..1f00f99755 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/login.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/login.dart @@ -35,7 +35,7 @@ class _LoginPageState extends State { // The login screen is immediately displayed on top of the Shrine // home screen using onGenerateRoute and so rootNavigator must be // set to true in order to get out of Shrine completely. - Navigator.of(context, rootNavigator: true)!.pop(); + Navigator.of(context, rootNavigator: true).pop(); }, ), ), @@ -95,7 +95,7 @@ class _LoginPageState extends State { // the Shrine home screen using onGenerateRoute and so // rootNavigator must be set to true in order to get out // of Shrine completely. - Navigator.of(context, rootNavigator: true)!.pop(); + Navigator.of(context, rootNavigator: true).pop(); }, child: const Text('CANCEL'), ), @@ -123,15 +123,15 @@ class _LoginPageState extends State { } class PrimaryColorOverride extends StatelessWidget { - const PrimaryColorOverride({Key? key, this.color, this.child}) : super(key: key); + const PrimaryColorOverride({Key key, this.color, this.child}) : super(key: key); - final Color? color; - final Widget? child; + final Color color; + final Widget child; @override Widget build(BuildContext context) { return Theme( - child: child!, + child: child, data: Theme.of(context).copyWith(primaryColor: color), ); } diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/model/app_state_model.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/model/app_state_model.dart index 2c00dbec52..46a5ac915e 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/model/app_state_model.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/model/app_state_model.dart @@ -12,7 +12,7 @@ double _shippingCostPerItem = 7.0; class AppStateModel extends Model { // All the available products. - List? _availableProducts; + List _availableProducts; // The currently selected category of products. Category _selectedCategory = Category.all; @@ -30,7 +30,7 @@ class AppStateModel extends Model { // Totaled prices of the items in the cart. double get subtotalCost { return _productsInCart.keys - .map((int id) => _availableProducts![id].price * _productsInCart[id]!) + .map((int id) => _availableProducts[id].price * _productsInCart[id]) .fold(0.0, (double sum, int e) => sum + e); } @@ -52,9 +52,9 @@ class AppStateModel extends Model { } if (_selectedCategory == Category.all) { - return List.from(_availableProducts!); + return List.from(_availableProducts); } else { - return _availableProducts! + return _availableProducts .where((Product p) => p.category == _selectedCategory) .toList(); } @@ -62,11 +62,10 @@ class AppStateModel extends Model { // Adds a product to the cart. void addProductToCart(int productId) { - final int? value = _productsInCart[productId]; - if (value == null) { + if (!_productsInCart.containsKey(productId)) { _productsInCart[productId] = 1; } else { - _productsInCart[productId] = value+1; + _productsInCart[productId]++; } notifyListeners(); @@ -74,13 +73,11 @@ class AppStateModel extends Model { // Removes an item from the cart. void removeItemFromCart(int productId) { - final int? value = _productsInCart[productId]; - - if (value != null) { + if (_productsInCart.containsKey(productId)) { if (_productsInCart[productId] == 1) { _productsInCart.remove(productId); } else { - _productsInCart[productId] = value - 1; + _productsInCart[productId]--; } } @@ -89,7 +86,7 @@ class AppStateModel extends Model { // Returns the Product instance matching the provided id. Product getProductById(int id) { - return _availableProducts!.firstWhere((Product p) => p.id == id); + return _availableProducts.firstWhere((Product p) => p.id == id); } // Removes everything from the cart. diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/model/product.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/model/product.dart index 8c328b7205..d37b71a488 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/model/product.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/model/product.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:flutter/foundation.dart'; + enum Category { all, accessories, @@ -11,12 +13,16 @@ enum Category { class Product { const Product({ - required this.category, - required this.id, - required this.isFeatured, - required this.name, - required this.price, - }); + @required this.category, + @required this.id, + @required this.isFeatured, + @required this.name, + @required this.price, + }) : assert(category != null), + assert(id != null), + assert(isFeatured != null), + assert(name != null), + assert(price != null); final Category category; final int id; diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/shopping_cart.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/shopping_cart.dart index adcdfbb4ff..0c0573945f 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/shopping_cart.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/shopping_cart.dart @@ -41,7 +41,7 @@ class _ShoppingCartPageState extends State { body: SafeArea( child: Container( child: ScopedModelDescendant( - builder: (BuildContext context, Widget? child, AppStateModel model) { + builder: (BuildContext context, Widget child, AppStateModel model) { return Stack( children: [ ListView( @@ -52,12 +52,12 @@ class _ShoppingCartPageState extends State { width: _leftColumnWidth, child: IconButton( icon: const Icon(Icons.keyboard_arrow_down), - onPressed: () => ExpandingBottomSheet.of(context)!.close(), + onPressed: () => ExpandingBottomSheet.of(context).close(), ), ), Text( 'CART', - style: localTheme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.w600), + style: localTheme.textTheme.subtitle1.copyWith(fontWeight: FontWeight.w600), ), const SizedBox(width: 16.0), Text('${model.totalCartQuantity} ITEMS'), @@ -88,7 +88,7 @@ class _ShoppingCartPageState extends State { ), onPressed: () { model.clearCart(); - ExpandingBottomSheet.of(context)!.close(); + ExpandingBottomSheet.of(context).close(); }, ), ), @@ -105,12 +105,12 @@ class _ShoppingCartPageState extends State { class ShoppingCartSummary extends StatelessWidget { const ShoppingCartSummary({this.model}); - final AppStateModel? model; + final AppStateModel model; @override Widget build(BuildContext context) { - final TextStyle smallAmountStyle = Theme.of(context).textTheme.bodyText2!.copyWith(color: kShrineBrown600); - final TextStyle? largeAmountStyle = Theme.of(context).textTheme.headline4; + final TextStyle smallAmountStyle = Theme.of(context).textTheme.bodyText2.copyWith(color: kShrineBrown600); + final TextStyle largeAmountStyle = Theme.of(context).textTheme.headline4; final NumberFormat formatter = NumberFormat.simpleCurrency( decimalDigits: 2, locale: Localizations.localeOf(context).toString(), @@ -131,7 +131,7 @@ class ShoppingCartSummary extends StatelessWidget { child: Text('TOTAL'), ), Text( - formatter.format(model!.totalCost), + formatter.format(model.totalCost), style: largeAmountStyle, ), ], @@ -143,7 +143,7 @@ class ShoppingCartSummary extends StatelessWidget { child: Text('Subtotal:'), ), Text( - formatter.format(model!.subtotalCost), + formatter.format(model.subtotalCost), style: smallAmountStyle, ), ], @@ -155,7 +155,7 @@ class ShoppingCartSummary extends StatelessWidget { child: Text('Shipping:'), ), Text( - formatter.format(model!.shippingCost), + formatter.format(model.shippingCost), style: smallAmountStyle, ), ], @@ -167,7 +167,7 @@ class ShoppingCartSummary extends StatelessWidget { child: Text('Tax:'), ), Text( - formatter.format(model!.tax), + formatter.format(model.tax), style: smallAmountStyle, ), ], @@ -183,14 +183,14 @@ class ShoppingCartSummary extends StatelessWidget { class ShoppingCartRow extends StatelessWidget { const ShoppingCartRow({ - required this.product, - required this.quantity, + @required this.product, + @required this.quantity, this.onPressed, }); final Product product; - final int? quantity; - final VoidCallback? onPressed; + final int quantity; + final VoidCallback onPressed; @override Widget build(BuildContext context) { @@ -243,7 +243,7 @@ class ShoppingCartRow extends StatelessWidget { ), Text( product.name, - style: localTheme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.w600), + style: localTheme.textTheme.subtitle1.copyWith(fontWeight: FontWeight.w600), ), ], ), diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/asymmetric_view.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/asymmetric_view.dart index 9cbce63fde..147b7a2773 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/asymmetric_view.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/asymmetric_view.dart @@ -8,12 +8,12 @@ import 'package:flutter_gallery/demo/shrine/model/product.dart'; import 'package:flutter_gallery/demo/shrine/supplemental/product_columns.dart'; class AsymmetricView extends StatelessWidget { - const AsymmetricView({Key? key, this.products}) : super(key: key); + const AsymmetricView({Key key, this.products}) : super(key: key); - final List? products; + final List products; List _buildColumns(BuildContext context) { - if (products == null || products!.isEmpty) { + if (products == null || products.isEmpty) { return const []; } @@ -25,23 +25,23 @@ class AsymmetricView extends StatelessWidget { // some kinda awkward math so we use _evenCasesIndex and _oddCasesIndex as // helpers for creating the index of the product list that will correspond // to the index of the list of columns. - return List.generate(_listItemCount(products!.length), (int index) { + return List.generate(_listItemCount(products.length), (int index) { double width = .59 * MediaQuery.of(context).size.width; Widget column; if (index.isEven) { /// Even cases final int bottom = _evenCasesIndex(index); column = TwoProductCardColumn( - bottom: products![bottom], - top: products!.length - 1 >= bottom + 1 - ? products![bottom + 1] + bottom: products[bottom], + top: products.length - 1 >= bottom + 1 + ? products[bottom + 1] : null, ); width += 32.0; } else { /// Odd cases column = OneProductCardColumn( - product: products![_oddCasesIndex(index)], + product: products[_oddCasesIndex(index)], ); } return Container( diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/cut_corners_border.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/cut_corners_border.dart index ef892bec2e..b67d0e715c 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/cut_corners_border.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/cut_corners_border.dart @@ -21,10 +21,10 @@ class CutCornersBorder extends OutlineInputBorder { @override CutCornersBorder copyWith({ - BorderSide? borderSide, - BorderRadius? borderRadius, - double? gapPadding, - double? cut, + BorderSide borderSide, + BorderRadius borderRadius, + double gapPadding, + double cut, }) { return CutCornersBorder( borderSide: borderSide ?? this.borderSide, @@ -37,11 +37,11 @@ class CutCornersBorder extends OutlineInputBorder { final double cut; @override - ShapeBorder? lerpFrom(ShapeBorder? a, double t) { + ShapeBorder lerpFrom(ShapeBorder a, double t) { if (a is CutCornersBorder) { final CutCornersBorder outline = a; return CutCornersBorder( - borderRadius: BorderRadius.lerp(outline.borderRadius, borderRadius, t)!, + borderRadius: BorderRadius.lerp(outline.borderRadius, borderRadius, t), borderSide: BorderSide.lerp(outline.borderSide, borderSide, t), cut: cut, gapPadding: outline.gapPadding, @@ -51,11 +51,11 @@ class CutCornersBorder extends OutlineInputBorder { } @override - ShapeBorder? lerpTo(ShapeBorder? b, double t) { + ShapeBorder lerpTo(ShapeBorder b, double t) { if (b is CutCornersBorder) { final CutCornersBorder outline = b; return CutCornersBorder( - borderRadius: BorderRadius.lerp(borderRadius, outline.borderRadius, t)!, + borderRadius: BorderRadius.lerp(borderRadius, outline.borderRadius, t), borderSide: BorderSide.lerp(borderSide, outline.borderSide, t), cut: cut, gapPadding: outline.gapPadding, @@ -64,10 +64,10 @@ class CutCornersBorder extends OutlineInputBorder { return super.lerpTo(b, t); } - Path _notchedCornerPath(Rect center, [double start = 0.0, double? extent = 0.0]) { + Path _notchedCornerPath(Rect center, [double start = 0.0, double extent = 0.0]) { final Path path = Path(); - if (start > 0.0 || extent! > 0.0) { - path.relativeMoveTo(extent! + start, center.top); + if (start > 0.0 || extent > 0.0) { + path.relativeMoveTo(extent + start, center.top); _notchedSidesAndBottom(center, path); path..lineTo(center.left + cut, center.top)..lineTo(start, center.top); } else { @@ -93,11 +93,12 @@ class CutCornersBorder extends OutlineInputBorder { void paint( Canvas canvas, Rect rect, { - double? gapStart, + double gapStart, double gapExtent = 0.0, double gapPercentage = 0.0, - TextDirection? textDirection, + TextDirection textDirection, }) { + assert(gapExtent != null); assert(gapPercentage >= 0.0 && gapPercentage <= 1.0); final Paint paint = borderSide.toPaint(); @@ -105,10 +106,10 @@ class CutCornersBorder extends OutlineInputBorder { if (gapStart == null || gapExtent <= 0.0 || gapPercentage == 0.0) { canvas.drawPath(_notchedCornerPath(outer.middleRect), paint); } else { - final double? extent = lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage); + final double extent = lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage); switch (textDirection) { case TextDirection.rtl: { - final Path path = _notchedCornerPath(outer.middleRect, gapStart + gapPadding - extent!, extent); + final Path path = _notchedCornerPath(outer.middleRect, gapStart + gapPadding - extent, extent); canvas.drawPath(path, paint); break; } @@ -117,8 +118,6 @@ class CutCornersBorder extends OutlineInputBorder { canvas.drawPath(path, paint); break; } - default: - break; } } } diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/product_card.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/product_card.dart index f7becf5fa2..27b7be5174 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/product_card.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/product_card.dart @@ -11,10 +11,10 @@ import 'package:flutter_gallery/demo/shrine/model/product.dart'; class ProductCard extends StatelessWidget { const ProductCard({ this.imageAspectRatio = 33 / 49, this.product }) - : assert(imageAspectRatio > 0); + : assert(imageAspectRatio == null || imageAspectRatio > 0); final double imageAspectRatio; - final Product? product; + final Product product; static const double kTextBoxHeight = 65.0; @@ -28,16 +28,16 @@ class ProductCard extends StatelessWidget { final ThemeData theme = Theme.of(context); final Image imageWidget = Image.asset( - product!.assetName, - package: product!.assetPackage, + product.assetName, + package: product.assetPackage, fit: BoxFit.cover, ); return ScopedModelDescendant( - builder: (BuildContext context, Widget? child, AppStateModel model) { + builder: (BuildContext context, Widget child, AppStateModel model) { return GestureDetector( onTap: () { - model.addProductToCart(product!.id); + model.addProductToCart(product.id); }, child: child, ); @@ -60,7 +60,7 @@ class ProductCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - product == null ? '' : product!.name, + product == null ? '' : product.name, style: theme.textTheme.button, softWrap: false, overflow: TextOverflow.ellipsis, @@ -68,7 +68,7 @@ class ProductCard extends StatelessWidget { ), const SizedBox(height: 4.0), Text( - product == null ? '' : formatter.format(product!.price), + product == null ? '' : formatter.format(product.price), style: theme.textTheme.caption, ), ], diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/product_columns.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/product_columns.dart index 4aa3e36eef..c989da1015 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/product_columns.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/product_columns.dart @@ -9,11 +9,11 @@ import 'package:flutter_gallery/demo/shrine/supplemental/product_card.dart'; class TwoProductCardColumn extends StatelessWidget { const TwoProductCardColumn({ - required this.bottom, + @required this.bottom, this.top, - }); + }) : assert(bottom != null); - final Product? bottom, top; + final Product bottom, top; @override Widget build(BuildContext context) { @@ -59,7 +59,7 @@ class TwoProductCardColumn extends StatelessWidget { class OneProductCardColumn extends StatelessWidget { const OneProductCardColumn({this.product}); - final Product? product; + final Product product; @override Widget build(BuildContext context) { diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine_demo.dart index 7bb548db33..3c46465712 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine_demo.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gallery/demo/shrine/app.dart'; class ShrineDemo extends StatelessWidget { - const ShrineDemo({ Key? key }) : super(key: key); + const ShrineDemo({ Key key }) : super(key: key); static const String routeName = '/shrine'; // Used by the Gallery app. diff --git a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo.dart index 0f4e88eaab..ad41788e13 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo.dart @@ -9,7 +9,7 @@ import 'transformations_demo_edit_board_point.dart'; import 'transformations_demo_gesture_transformable.dart'; class TransformationsDemo extends StatefulWidget { - const TransformationsDemo({ Key? key }) : super(key: key); + const TransformationsDemo({ Key key }) : super(key: key); static const String routeName = '/transformations'; @@ -107,7 +107,7 @@ class _TransformationsDemoState extends State { TextButton( child: const Text('OK'), onPressed: () { - Navigator.of(context)!.pop(); + Navigator.of(context).pop(); }, ), ], @@ -139,10 +139,10 @@ class _TransformationsDemoState extends State { height: 150, padding: const EdgeInsets.all(12.0), child: EditBoardPoint( - boardPoint: _board.selected!, + boardPoint: _board.selected, onColorSelection: (Color color) { setState(() { - _board = _board.copyWithBoardPointColor(_board.selected!, color); + _board = _board.copyWithBoardPointColor(_board.selected, color); Navigator.pop(context); }); }, @@ -157,7 +157,7 @@ class _TransformationsDemoState extends State { void _onTapUp(TapUpDetails details) { final Offset scenePoint = details.globalPosition; - final BoardPoint? boardPoint = _board.pointToBoardPoint(scenePoint); + final BoardPoint boardPoint = _board.pointToBoardPoint(scenePoint); setState(() { _board = _board.copyWithSelected(boardPoint); }); @@ -171,19 +171,19 @@ class BoardPainter extends CustomPainter { this.board, }); - final Board? board; + final Board board; @override void paint(Canvas canvas, Size size) { - void drawBoardPoint(BoardPoint? boardPoint) { - final Color color = boardPoint!.color.withOpacity( - board!.selected == boardPoint ? 0.2 : 1.0, + void drawBoardPoint(BoardPoint boardPoint) { + final Color color = boardPoint.color.withOpacity( + board.selected == boardPoint ? 0.2 : 1.0, ); - final Vertices vertices = board!.getVerticesForBoardPoint(boardPoint, color); + final Vertices vertices = board.getVerticesForBoardPoint(boardPoint, color); canvas.drawVertices(vertices, BlendMode.color, Paint()); } - board!.forEach(drawBoardPoint); + board.forEach(drawBoardPoint); } // We should repaint whenever the board changes, such as board.selected. diff --git a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_board.dart b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_board.dart index b8806bc5cc..1ff5d6da23 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_board.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_board.dart @@ -11,13 +11,13 @@ import 'package:vector_math/vector_math_64.dart' show Vector3; // The entire state of the hex board and abstraction to get information about // it. Iterable so that all BoardPoints on the board can be iterated over. @immutable -class Board extends Object with IterableMixin { +class Board extends Object with IterableMixin { Board({ - required this.boardRadius, - required this.hexagonRadius, - required this.hexagonMargin, + @required this.boardRadius, + @required this.hexagonRadius, + @required this.hexagonMargin, this.selected, - List? boardPoints, + List boardPoints, }) : assert(boardRadius > 0), assert(hexagonRadius > 0), assert(hexagonMargin >= 0) { @@ -43,7 +43,7 @@ class Board extends Object with IterableMixin { _boardPoints.addAll(boardPoints); } else { // Generate boardPoints for a fresh board. - BoardPoint? boardPoint = _getNextBoardPoint(null); + BoardPoint boardPoint = _getNextBoardPoint(null); while (boardPoint != null) { _boardPoints.add(boardPoint); boardPoint = _getNextBoardPoint(boardPoint); @@ -55,11 +55,11 @@ class Board extends Object with IterableMixin { final double hexagonRadius; // Pixel radius of a hexagon (center to vertex). final double hexagonMargin; // Margin between hexagons. final List positionsForHexagonAtOrigin = []; - final BoardPoint? selected; + final BoardPoint selected; final List _boardPoints = []; @override - Iterator get iterator => _BoardIterator(_boardPoints); + Iterator get iterator => _BoardIterator(_boardPoints); // For a given q axial coordinate, get the range of possible r values // See the definition of BoardPoint for more information about hex grids and @@ -81,7 +81,7 @@ class Board extends Object with IterableMixin { // Get the BoardPoint that comes after the given BoardPoint. If given null, // returns the origin BoardPoint. If given BoardPoint is the last, returns // null. - BoardPoint? _getNextBoardPoint (BoardPoint? boardPoint) { + BoardPoint _getNextBoardPoint (BoardPoint boardPoint) { // If before the first element. if (boardPoint == null) { return BoardPoint(-boardRadius, 0); @@ -121,7 +121,7 @@ class Board extends Object with IterableMixin { // Return the q,r BoardPoint for a point in the scene, where the origin is in // the center of the board in both coordinate systems. If no BoardPoint at the // location, return null. - BoardPoint? pointToBoardPoint(Offset point) { + BoardPoint pointToBoardPoint(Offset point) { final BoardPoint boardPoint = BoardPoint( ((sqrt(3) / 3 * point.dx - 1 / 3 * point.dy) / hexagonRadius).round(), ((2 / 3 * point.dy) / hexagonRadius).round(), @@ -160,7 +160,7 @@ class Board extends Object with IterableMixin { } // Return a new board with the given BoardPoint selected. - Board copyWithSelected(BoardPoint? boardPoint) { + Board copyWithSelected(BoardPoint boardPoint) { if (selected == boardPoint) { return this; } @@ -187,7 +187,7 @@ class Board extends Object with IterableMixin { final List nextBoardPoints = List.from(_boardPoints); nextBoardPoints[boardPointIndex] = nextBoardPoint; - final BoardPoint? selectedBoardPoint = boardPoint == selected + final BoardPoint selectedBoardPoint = boardPoint == selected ? nextBoardPoint : selected; return Board( @@ -200,30 +200,29 @@ class Board extends Object with IterableMixin { } } -class _BoardIterator extends Iterator { +class _BoardIterator extends Iterator { _BoardIterator(this.boardPoints); final List boardPoints; - int? currentIndex; + int currentIndex; @override - BoardPoint? current; + BoardPoint current; @override bool moveNext() { - final int? index = currentIndex; - if (index == null) { + if (currentIndex == null) { currentIndex = 0; } else { - currentIndex = index + 1; + currentIndex++; } - if (currentIndex! >= boardPoints.length) { + if (currentIndex >= boardPoints.length) { current = null; return false; } - current = boardPoints[currentIndex!]; + current = boardPoints[currentIndex]; return true; } } @@ -232,7 +231,9 @@ class _BoardIterator extends Iterator { @immutable class _Range { const _Range(this.min, this.max) - : assert(min <= max); + : assert(min != null), + assert(max != null), + assert(min <= max); final int min; final int max; diff --git a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_color_picker.dart b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_color_picker.dart index 4ecdd76d8f..40b68b1ba2 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_color_picker.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_color_picker.dart @@ -8,14 +8,15 @@ import 'package:flutter/material.dart'; @immutable class ColorPicker extends StatelessWidget { const ColorPicker({ - required this.colors, - required this.selectedColor, + @required this.colors, + @required this.selectedColor, this.onColorSelection, - }); + }) : assert(colors != null), + assert(selectedColor != null); final Set colors; final Color selectedColor; - final ValueChanged? onColorSelection; + final ValueChanged onColorSelection; @override Widget build (BuildContext context) { @@ -27,7 +28,7 @@ class ColorPicker extends StatelessWidget { selected: color == selectedColor, onTap: () { if (onColorSelection != null) { - onColorSelection!(color); + onColorSelection(color); } }, ); @@ -40,14 +41,15 @@ class ColorPicker extends StatelessWidget { @immutable class _ColorPickerSwatch extends StatelessWidget { const _ColorPickerSwatch({ - required this.color, - required this.selected, + @required this.color, + @required this.selected, this.onTap, - }); + }) : assert(color != null), + assert(selected != null); final Color color; final bool selected; - final Function? onTap; + final Function onTap; @override Widget build (BuildContext context) { @@ -59,7 +61,7 @@ class _ColorPickerSwatch extends StatelessWidget { fillColor: color, onPressed: () { if (onTap != null) { - onTap!(); + onTap(); } }, child: !selected ? null : const Icon( diff --git a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_edit_board_point.dart b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_edit_board_point.dart index bb8eb2d8db..126b58f25f 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_edit_board_point.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_edit_board_point.dart @@ -10,13 +10,14 @@ import 'transformations_demo_color_picker.dart'; @immutable class EditBoardPoint extends StatelessWidget { const EditBoardPoint({ - Key? key, - required this.boardPoint, + Key key, + @required this.boardPoint, this.onColorSelection, - }) : super(key: key); + }) : assert(boardPoint != null), + super(key: key); final BoardPoint boardPoint; - final ValueChanged? onColorSelection; + final ValueChanged onColorSelection; @override Widget build (BuildContext context) { diff --git a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_gesture_transformable.dart b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_gesture_transformable.dart index 1424d7bef4..e7f8bad65c 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_gesture_transformable.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_gesture_transformable.dart @@ -14,14 +14,14 @@ import 'transformations_demo_inertial_motion.dart'; @immutable class GestureTransformable extends StatefulWidget { const GestureTransformable({ - Key? key, + Key key, // The child to perform the transformations on. - required this.child, + @required this.child, // The desired visible size of the widget and the area that is receptive to // gestures. If a widget that's as big as possible is desired, then wrap // this in a LayoutBuilder and pass // `Size(constraints.maxWidth, constraints.maxHeight)`. - required this.size, + @required this.size, // The scale will be clamped to between these values. A maxScale of null has // no bounds. minScale must be greater than zero. this.maxScale = 2.5, @@ -71,7 +71,14 @@ class GestureTransformable extends StatefulWidget { this.onScaleStart, this.onScaleUpdate, this.onScaleEnd, - }) : assert(minScale > 0), + }) : assert(child != null), + assert(size != null), + assert(minScale != null), + assert(minScale > 0), + assert(disableTranslation != null), + assert(disableScale != null), + assert(disableRotation != null), + assert(reset != null), assert( !reset || onResetEnd != null, 'Must implement onResetEnd to use reset.', @@ -81,41 +88,41 @@ class GestureTransformable extends StatefulWidget { final Widget child; final Size size; final bool reset; - final GestureTapDownCallback? onTapDown; - final GestureTapUpCallback? onTapUp; - final GestureTapCallback? onTap; - final GestureTapCancelCallback? onTapCancel; - final GestureTapCallback? onDoubleTap; - final GestureLongPressCallback? onLongPress; - final GestureLongPressUpCallback? onLongPressUp; - final GestureDragDownCallback? onVerticalDragDown; - final GestureDragStartCallback? onVerticalDragStart; - final GestureDragUpdateCallback? onVerticalDragUpdate; - final GestureDragEndCallback? onVerticalDragEnd; - final GestureDragCancelCallback? onVerticalDragCancel; - final GestureDragDownCallback? onHorizontalDragDown; - final GestureDragStartCallback? onHorizontalDragStart; - final GestureDragUpdateCallback? onHorizontalDragUpdate; - final GestureDragEndCallback? onHorizontalDragEnd; - final GestureDragCancelCallback? onHorizontalDragCancel; - final GestureDragDownCallback? onPanDown; - final GestureDragStartCallback? onPanStart; - final GestureDragUpdateCallback? onPanUpdate; - final GestureDragEndCallback? onPanEnd; - final GestureDragCancelCallback? onPanCancel; - final VoidCallback? onResetEnd; - final GestureScaleStartCallback? onScaleStart; - final GestureScaleUpdateCallback? onScaleUpdate; - final GestureScaleEndCallback? onScaleEnd; + final GestureTapDownCallback onTapDown; + final GestureTapUpCallback onTapUp; + final GestureTapCallback onTap; + final GestureTapCancelCallback onTapCancel; + final GestureTapCallback onDoubleTap; + final GestureLongPressCallback onLongPress; + final GestureLongPressUpCallback onLongPressUp; + final GestureDragDownCallback onVerticalDragDown; + final GestureDragStartCallback onVerticalDragStart; + final GestureDragUpdateCallback onVerticalDragUpdate; + final GestureDragEndCallback onVerticalDragEnd; + final GestureDragCancelCallback onVerticalDragCancel; + final GestureDragDownCallback onHorizontalDragDown; + final GestureDragStartCallback onHorizontalDragStart; + final GestureDragUpdateCallback onHorizontalDragUpdate; + final GestureDragEndCallback onHorizontalDragEnd; + final GestureDragCancelCallback onHorizontalDragCancel; + final GestureDragDownCallback onPanDown; + final GestureDragStartCallback onPanStart; + final GestureDragUpdateCallback onPanUpdate; + final GestureDragEndCallback onPanEnd; + final GestureDragCancelCallback onPanCancel; + final VoidCallback onResetEnd; + final GestureScaleStartCallback onScaleStart; + final GestureScaleUpdateCallback onScaleUpdate; + final GestureScaleEndCallback onScaleEnd; final double maxScale; final double minScale; - final Rect? boundaryRect; + final Rect boundaryRect; final bool disableTranslation; final bool disableScale; final bool disableRotation; - final Offset? initialTranslation; - final double? initialScale; - final double? initialRotation; + final Offset initialTranslation; + final double initialScale; + final double initialRotation; @override _GestureTransformableState createState() => _GestureTransformableState(); } @@ -130,20 +137,20 @@ enum _GestureType { // This is public only for access from a unit test. class _GestureTransformableState extends State with TickerProviderStateMixin { - Animation? _animation; - late AnimationController _controller; - Animation? _animationReset; - late AnimationController _controllerReset; + Animation _animation; + AnimationController _controller; + Animation _animationReset; + AnimationController _controllerReset; // The translation that will be applied to the scene (not viewport). // A positive x offset moves the scene right, viewport left. // A positive y offset moves the scene down, viewport up. - Offset? _translateFromScene; // Point where a single translation began. - double? _scaleStart; // Scale value at start of scaling gesture. - double? _rotationStart = 0.0; // Rotation at start of rotation gesture. - late Rect _boundaryRect; + Offset _translateFromScene; // Point where a single translation began. + double _scaleStart; // Scale value at start of scaling gesture. + double _rotationStart = 0.0; // Rotation at start of rotation gesture. + Rect _boundaryRect; Matrix4 _transform = Matrix4.identity(); double _currentRotation = 0.0; - _GestureType? gestureType; + _GestureType gestureType; // The transformation matrix that gives the initial home position. Matrix4 get _initialTransform { @@ -176,7 +183,7 @@ class _GestureTransformableState extends State with Ticker // Get the offset of the current widget from the global screen coordinates. // TODO(justinmc): Protect against calling this during first build. static Offset getOffset(BuildContext context) { - final RenderBox renderObject = context.findRenderObject()! as RenderBox; + final RenderBox renderObject = context.findRenderObject() as RenderBox; return renderObject.localToGlobal(Offset.zero); } @@ -213,12 +220,12 @@ class _GestureTransformableState extends State with Ticker return GestureDetector( behavior: HitTestBehavior.opaque, // Necessary when translating off screen onTapDown: widget.onTapDown == null ? null : (TapDownDetails details) { - widget.onTapDown!(TapDownDetails( + widget.onTapDown(TapDownDetails( globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), )); }, onTapUp: widget.onTapUp == null ? null : (TapUpDetails details) { - widget.onTapUp!(TapUpDetails( + widget.onTapUp(TapUpDetails( kind: details.kind, globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), )); @@ -229,51 +236,51 @@ class _GestureTransformableState extends State with Ticker onLongPress: widget.onLongPress, onLongPressUp: widget.onLongPressUp, onVerticalDragDown: widget.onVerticalDragDown == null ? null : (DragDownDetails details) { - widget.onVerticalDragDown!(DragDownDetails( + widget.onVerticalDragDown(DragDownDetails( globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), )); }, onVerticalDragStart: widget.onVerticalDragStart == null ? null : (DragStartDetails details) { - widget.onVerticalDragStart!(DragStartDetails( + widget.onVerticalDragStart(DragStartDetails( globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), )); }, onVerticalDragUpdate: widget.onVerticalDragUpdate == null ? null : (DragUpdateDetails details) { - widget.onVerticalDragUpdate!(DragUpdateDetails( + widget.onVerticalDragUpdate(DragUpdateDetails( globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), )); }, onVerticalDragEnd: widget.onVerticalDragEnd, onVerticalDragCancel: widget.onVerticalDragCancel, onHorizontalDragDown: widget.onHorizontalDragDown == null ? null : (DragDownDetails details) { - widget.onHorizontalDragDown!(DragDownDetails( + widget.onHorizontalDragDown(DragDownDetails( globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), )); }, onHorizontalDragStart: widget.onHorizontalDragStart == null ? null : (DragStartDetails details) { - widget.onHorizontalDragStart!(DragStartDetails( + widget.onHorizontalDragStart(DragStartDetails( globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), )); }, onHorizontalDragUpdate: widget.onHorizontalDragUpdate == null ? null : (DragUpdateDetails details) { - widget.onHorizontalDragUpdate!(DragUpdateDetails( + widget.onHorizontalDragUpdate(DragUpdateDetails( globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), )); }, onHorizontalDragEnd: widget.onHorizontalDragEnd, onHorizontalDragCancel: widget.onHorizontalDragCancel, onPanDown: widget.onPanDown == null ? null : (DragDownDetails details) { - widget.onPanDown!(DragDownDetails( + widget.onPanDown(DragDownDetails( globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), )); }, onPanStart: widget.onPanStart == null ? null : (DragStartDetails details) { - widget.onPanStart!(DragStartDetails( + widget.onPanStart(DragStartDetails( globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), )); }, onPanUpdate: widget.onPanUpdate == null ? null : (DragUpdateDetails details) { - widget.onPanUpdate!(DragUpdateDetails( + widget.onPanUpdate(DragUpdateDetails( globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), )); }, @@ -298,7 +305,7 @@ class _GestureTransformableState extends State with Ticker // Return a new matrix representing the given matrix after applying the given // translation. - Matrix4 matrixTranslate(Matrix4 matrix, Offset? translation) { + Matrix4 matrixTranslate(Matrix4 matrix, Offset translation) { if (widget.disableTranslation || translation == Offset.zero) { return matrix; } @@ -321,7 +328,7 @@ class _GestureTransformableState extends State with Ticker -scale * viewportBoundaries.top, ); final Matrix4 nextMatrix = matrix.clone()..translate( - translation!.dx, + translation.dx, translation.dy, ); final Vector3 nextTranslationVector = nextMatrix.getTranslation(); @@ -343,7 +350,7 @@ class _GestureTransformableState extends State with Ticker // Return a new matrix representing the given matrix after applying the given // scale transform. - Matrix4 matrixScale(Matrix4 matrix, double? scale) { + Matrix4 matrixScale(Matrix4 matrix, double scale) { if (widget.disableScale || scale == 1) { return matrix; } @@ -367,11 +374,11 @@ class _GestureTransformableState extends State with Ticker // Don't allow a scale that results in an overall scale beyond min/max // scale. final double currentScale = _transform.getMaxScaleOnAxis(); - final double totalScale = currentScale * scale!; + final double totalScale = currentScale * scale; final double clampedTotalScale = totalScale.clamp( widget.minScale, widget.maxScale, - ); + ) as double; final double clampedScale = clampedTotalScale / currentScale; return matrix..scale(clampedScale); } @@ -379,21 +386,21 @@ class _GestureTransformableState extends State with Ticker // Return a new matrix representing the given matrix after applying the given // rotation transform. // Rotating the scene cannot cause the viewport to view beyond _boundaryRect. - Matrix4 matrixRotate(Matrix4 matrix, double? rotation, Offset focalPoint) { + Matrix4 matrixRotate(Matrix4 matrix, double rotation, Offset focalPoint) { if (widget.disableRotation || rotation == 0) { return matrix; } final Offset focalPointScene = fromViewport(focalPoint, matrix); return matrix ..translate(focalPointScene.dx, focalPointScene.dy) - ..rotateZ(-rotation!) + ..rotateZ(-rotation) ..translate(-focalPointScene.dx, -focalPointScene.dy); } // Handle the start of a gesture of _GestureType. void _onScaleStart(ScaleStartDetails details) { if (widget.onScaleStart != null) { - widget.onScaleStart!(details); + widget.onScaleStart(details); } if (_controller.isAnimating) { @@ -418,7 +425,7 @@ class _GestureTransformableState extends State with Ticker void _onScaleUpdate(ScaleUpdateDetails details) { double scale = _transform.getMaxScaleOnAxis(); if (widget.onScaleUpdate != null) { - widget.onScaleUpdate!(ScaleUpdateDetails( + widget.onScaleUpdate(ScaleUpdateDetails( focalPoint: fromViewport(details.focalPoint, _transform), scale: details.scale, rotation: details.rotation, @@ -446,7 +453,7 @@ class _GestureTransformableState extends State with Ticker // details.scale gives us the amount to change the scale as of the // start of this gesture, so calculate the amount to scale as of the // previous call to _onScaleUpdate. - final double desiredScale = _scaleStart! * details.scale; + final double desiredScale = _scaleStart * details.scale; final double scaleChange = desiredScale / scale; _transform = matrixScale(_transform, scaleChange); scale = _transform.getMaxScaleOnAxis(); @@ -461,13 +468,13 @@ class _GestureTransformableState extends State with Ticker ); _transform = matrixTranslate(_transform, focalPointSceneNext - focalPointScene); } else if (gestureType == _GestureType.rotate && details.rotation != 0.0) { - final double desiredRotation = _rotationStart! + details.rotation; + final double desiredRotation = _rotationStart + details.rotation; _transform = matrixRotate(_transform, _currentRotation - desiredRotation, details.focalPoint); _currentRotation = desiredRotation; } else if (_translateFromScene != null && details.scale == 1.0) { // Translate so that the same point in the scene is underneath the // focal point before and after the movement. - final Offset translationChange = focalPointScene - _translateFromScene!; + final Offset translationChange = focalPointScene - _translateFromScene; _transform = matrixTranslate(_transform, translationChange); _translateFromScene = fromViewport(details.focalPoint, _transform); } @@ -477,7 +484,7 @@ class _GestureTransformableState extends State with Ticker // Handle the end of a gesture of _GestureType. void _onScaleEnd(ScaleEndDetails details) { if (widget.onScaleEnd != null) { - widget.onScaleEnd!(details); + widget.onScaleEnd(details); } setState(() { _scaleStart = null; @@ -503,7 +510,7 @@ class _GestureTransformableState extends State with Ticker end: inertialMotion.finalPosition, ).animate(_controller); _controller.duration = Duration(milliseconds: inertialMotion.duration.toInt()); - _animation!.addListener(_onAnimate); + _animation.addListener(_onAnimate); _controller.fling(); } @@ -515,7 +522,7 @@ class _GestureTransformableState extends State with Ticker final Vector3 translationVector = _transform.getTranslation(); final Offset translation = Offset(translationVector.x, translationVector.y); final Offset translationScene = fromViewport(translation, _transform); - final Offset animationScene = fromViewport(_animation!.value, _transform); + final Offset animationScene = fromViewport(_animation.value, _transform); final Offset translationChangeScene = animationScene - translationScene; _transform = matrixTranslate(_transform, translationChangeScene); }); @@ -529,13 +536,13 @@ class _GestureTransformableState extends State with Ticker // Handle reset to home transform animation. void _onAnimateReset() { setState(() { - _transform = _animationReset!.value; + _transform = _animationReset.value; }); if (!_controllerReset.isAnimating) { _animationReset?.removeListener(_onAnimateReset); _animationReset = null; _controllerReset.reset(); - widget.onResetEnd!(); + widget.onResetEnd(); } } @@ -547,7 +554,7 @@ class _GestureTransformableState extends State with Ticker end: _initialTransform, ).animate(_controllerReset); _controllerReset.duration = const Duration(milliseconds: 400); - _animationReset!.addListener(_onAnimateReset); + _animationReset.addListener(_onAnimateReset); _controllerReset.forward(); } @@ -557,7 +564,7 @@ class _GestureTransformableState extends State with Ticker _animationReset?.removeListener(_onAnimateReset); _animationReset = null; _controllerReset.reset(); - widget.onResetEnd!(); + widget.onResetEnd(); } @override diff --git a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_inertial_motion.dart b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_inertial_motion.dart index b160d759d2..3b741e7329 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_inertial_motion.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_inertial_motion.dart @@ -60,7 +60,7 @@ class InertialMotion { // Solve the equation of motion to find the position at a given point in time // in one dimension. - double _getPosition({required double r0, required double v0, required int t, required double a}) { + double _getPosition({double r0, double v0, int t, double a}) { // Stop movement when it would otherwise reverse direction. final double stopTime = (v0 / a).abs(); if (t > stopTime) { diff --git a/dev/integration_tests/flutter_gallery/lib/demo/typography_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/typography_demo.dart index 017fdda401..5395fc660c 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/typography_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/typography_demo.dart @@ -6,11 +6,14 @@ import 'package:flutter/material.dart'; class TextStyleItem extends StatelessWidget { const TextStyleItem({ - Key? key, - required this.name, - required this.style, - required this.text, - }) : super(key: key); + Key key, + @required this.name, + @required this.style, + @required this.text, + }) : assert(name != null), + assert(style != null), + assert(text != null), + super(key: key); final String name; final TextStyle style; @@ -19,7 +22,7 @@ class TextStyleItem extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - final TextStyle nameStyle = theme.textTheme.caption!.copyWith(color: theme.textTheme.caption!.color); + final TextStyle nameStyle = theme.textTheme.caption.copyWith(color: theme.textTheme.caption.color); return Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 16.0), child: Row( @@ -46,17 +49,17 @@ class TypographyDemo extends StatelessWidget { final TextTheme textTheme = Theme.of(context).textTheme; final List styleItems = [ if (MediaQuery.of(context).size.width > 500.0) - TextStyleItem(name: 'Headline 1', style: textTheme.headline1!, text: 'Light 112sp'), - TextStyleItem(name: 'Headline 2', style: textTheme.headline2!, text: 'Regular 56sp'), - TextStyleItem(name: 'Headline 3', style: textTheme.headline3!, text: 'Regular 45sp'), - TextStyleItem(name: 'Headline 4', style: textTheme.headline4!, text: 'Regular 34sp'), - TextStyleItem(name: 'Headline 5', style: textTheme.headline5!, text: 'Regular 24sp'), - TextStyleItem(name: 'Headline 6', style: textTheme.headline6!, text: 'Medium 20sp'), - TextStyleItem(name: 'Subtitle 1', style: textTheme.subtitle1!, text: 'Regular 16sp'), - TextStyleItem(name: 'Body 1', style: textTheme.bodyText1!, text: 'Medium 14sp'), - TextStyleItem(name: 'Body 2', style: textTheme.bodyText2!, text: 'Regular 14sp'), - TextStyleItem(name: 'Caption', style: textTheme.caption!, text: 'Regular 12sp'), - TextStyleItem(name: 'Button', style: textTheme.button!, text: 'MEDIUM (ALL CAPS) 14sp'), + TextStyleItem(name: 'Headline 1', style: textTheme.headline1, text: 'Light 112sp'), + TextStyleItem(name: 'Headline 2', style: textTheme.headline2, text: 'Regular 56sp'), + TextStyleItem(name: 'Headline 3', style: textTheme.headline3, text: 'Regular 45sp'), + TextStyleItem(name: 'Headline 4', style: textTheme.headline4, text: 'Regular 34sp'), + TextStyleItem(name: 'Headline 5', style: textTheme.headline5, text: 'Regular 24sp'), + TextStyleItem(name: 'Headline 6', style: textTheme.headline6, text: 'Medium 20sp'), + TextStyleItem(name: 'Subtitle 1', style: textTheme.subtitle1, text: 'Regular 16sp'), + TextStyleItem(name: 'Body 1', style: textTheme.bodyText1, text: 'Medium 14sp'), + TextStyleItem(name: 'Body 2', style: textTheme.bodyText2, text: 'Regular 14sp'), + TextStyleItem(name: 'Caption', style: textTheme.caption, text: 'Regular 12sp'), + TextStyleItem(name: 'Button', style: textTheme.button, text: 'MEDIUM (ALL CAPS) 14sp'), ]; return Scaffold( diff --git a/dev/integration_tests/flutter_gallery/lib/demo/video_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/video_demo.dart index 43e032ad76..7a187ba999 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/video_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/video_demo.dart @@ -11,11 +11,11 @@ import 'package:video_player/video_player.dart'; import 'package:device_info/device_info.dart'; class VideoCard extends StatelessWidget { - const VideoCard({ Key? key, this.controller, this.title, this.subtitle }) : super(key: key); + const VideoCard({ Key key, this.controller, this.title, this.subtitle }) : super(key: key); - final VideoPlayerController? controller; - final String? title; - final String? subtitle; + final VideoPlayerController controller; + final String title; + final String subtitle; Widget _buildInlineVideo() { return Padding( @@ -24,7 +24,7 @@ class VideoCard extends StatelessWidget { child: AspectRatio( aspectRatio: 3 / 2, child: Hero( - tag: controller!, + tag: controller, child: VideoPlayerLoading(controller), ), ), @@ -35,13 +35,13 @@ class VideoCard extends StatelessWidget { Widget _buildFullScreenVideo() { return Scaffold( appBar: AppBar( - title: Text(title!), + title: Text(title), ), body: Center( child: AspectRatio( aspectRatio: 3 / 2, child: Hero( - tag: controller!, + tag: controller, child: VideoPlayPause(controller), ), ), @@ -66,11 +66,11 @@ class VideoCard extends StatelessWidget { ); route.completed.then((void value) { - controller!.setVolume(0.0); + controller.setVolume(0.0); }); - controller!.setVolume(1.0); - Navigator.of(context)!.push(route); + controller.setVolume(1.0); + Navigator.of(context).push(route); } return SafeArea( @@ -79,7 +79,7 @@ class VideoCard extends StatelessWidget { child: Card( child: Column( children: [ - ListTile(title: Text(title!), subtitle: Text(subtitle!)), + ListTile(title: Text(title), subtitle: Text(subtitle)), GestureDetector( onTap: pushFullScreenWidget, child: _buildInlineVideo(), @@ -94,24 +94,24 @@ class VideoCard extends StatelessWidget { class VideoPlayerLoading extends StatefulWidget { const VideoPlayerLoading(this.controller); - final VideoPlayerController? controller; + final VideoPlayerController controller; @override _VideoPlayerLoadingState createState() => _VideoPlayerLoadingState(); } class _VideoPlayerLoadingState extends State { - bool? _initialized; + bool _initialized; @override void initState() { super.initState(); - _initialized = widget.controller!.value.isInitialized; - widget.controller!.addListener(() { + _initialized = widget.controller.value.isInitialized; + widget.controller.addListener(() { if (!mounted) { return; } - final bool controllerInitialized = widget.controller!.value.isInitialized; + final bool controllerInitialized = widget.controller.value.isInitialized; if (_initialized != controllerInitialized) { setState(() { _initialized = controllerInitialized; @@ -122,12 +122,12 @@ class _VideoPlayerLoadingState extends State { @override Widget build(BuildContext context) { - if (_initialized!) { - return VideoPlayer(widget.controller!); + if (_initialized) { + return VideoPlayer(widget.controller); } return Stack( children: [ - VideoPlayer(widget.controller!), + VideoPlayer(widget.controller), const Center(child: CircularProgressIndicator()), ], fit: StackFit.expand, @@ -138,7 +138,7 @@ class _VideoPlayerLoadingState extends State { class VideoPlayPause extends StatefulWidget { const VideoPlayPause(this.controller); - final VideoPlayerController? controller; + final VideoPlayerController controller; @override State createState() => _VideoPlayPauseState(); @@ -152,20 +152,20 @@ class _VideoPlayPauseState extends State { }; } - FadeAnimation? imageFadeAnimation; - late VoidCallback listener; + FadeAnimation imageFadeAnimation; + VoidCallback listener; - VideoPlayerController? get controller => widget.controller; + VideoPlayerController get controller => widget.controller; @override void initState() { super.initState(); - controller!.addListener(listener); + controller.addListener(listener); } @override void deactivate() { - controller!.removeListener(listener); + controller.removeListener(listener); super.deactivate(); } @@ -178,19 +178,19 @@ class _VideoPlayPauseState extends State { GestureDetector( child: VideoPlayerLoading(controller), onTap: () { - if (!controller!.value.isInitialized) { + if (!controller.value.isInitialized) { return; } - if (controller!.value.isPlaying) { + if (controller.value.isPlaying) { imageFadeAnimation = const FadeAnimation( child: Icon(Icons.pause, size: 100.0), ); - controller!.pause(); + controller.pause(); } else { imageFadeAnimation = const FadeAnimation( child: Icon(Icons.play_arrow, size: 100.0), ); - controller!.play(); + controller.play(); } }, ), @@ -206,7 +206,7 @@ class FadeAnimation extends StatefulWidget { this.duration = const Duration(milliseconds: 500), }); - final Widget? child; + final Widget child; final Duration duration; @override @@ -214,7 +214,7 @@ class FadeAnimation extends StatefulWidget { } class _FadeAnimationState extends State with SingleTickerProviderStateMixin { - late AnimationController animationController; + AnimationController animationController; @override void initState() { @@ -268,15 +268,15 @@ class ConnectivityOverlay extends StatefulWidget { this.connectedCompleter, }); - final Widget? child; - final Completer? connectedCompleter; + final Widget child; + final Completer connectedCompleter; @override _ConnectivityOverlayState createState() => _ConnectivityOverlayState(); } class _ConnectivityOverlayState extends State { - StreamSubscription? connectivitySubscription; + StreamSubscription connectivitySubscription; bool connected = true; static const SnackBar errorSnackBar = SnackBar( @@ -308,8 +308,8 @@ class _ConnectivityOverlayState extends State { // Assume connectivity // TODO(ditman): Remove this shortcut when `connectivity` support for web // lands, https://github.com/flutter/flutter/issues/46735 - if (!widget.connectedCompleter!.isCompleted) { - widget.connectedCompleter!.complete(); + if (!widget.connectedCompleter.isCompleted) { + widget.connectedCompleter.complete(null); } return; } @@ -321,8 +321,8 @@ class _ConnectivityOverlayState extends State { if (connectivityResult == ConnectivityResult.none) { ScaffoldMessenger.of(context).showSnackBar(errorSnackBar); } else { - if (!widget.connectedCompleter!.isCompleted) { - widget.connectedCompleter!.complete(); + if (!widget.connectedCompleter.isCompleted) { + widget.connectedCompleter.complete(null); } } }, @@ -336,11 +336,11 @@ class _ConnectivityOverlayState extends State { } @override - Widget build(BuildContext context) => widget.child!; + Widget build(BuildContext context) => widget.child; } class VideoDemo extends StatefulWidget { - const VideoDemo({ Key? key }) : super(key: key); + const VideoDemo({ Key key }) : super(key: key); static const String routeName = '/video'; @@ -389,7 +389,7 @@ class _VideoDemoState extends State with SingleTickerProviderStateMix initController(butterflyController, 'butterfly'); initController(beeController, 'bee'); - isIOSSimulator().then((bool result) { + isIOSSimulator().then((bool result) { isSupported = !result; }); } diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/about.dart b/dev/integration_tests/flutter_gallery/lib/gallery/about.dart index b2167c357d..144cfdf48f 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/about.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/about.dart @@ -23,19 +23,19 @@ class _LinkTextSpan extends TextSpan { // manage the recognizer from outside the TextSpan, e.g. in the State of a // stateful widget that then hands the recognizer to the TextSpan. - _LinkTextSpan({ TextStyle? style, String? url, String? text }) : super( + _LinkTextSpan({ TextStyle style, String url, String text }) : super( style: style, text: text ?? url, recognizer: TapGestureRecognizer()..onTap = () { - launch(url!, forceSafariVC: false); + launch(url, forceSafariVC: false); } ); } void showGalleryAboutDialog(BuildContext context) { final ThemeData themeData = Theme.of(context); - final TextStyle? aboutTextStyle = themeData.textTheme.bodyText1; - final TextStyle linkStyle = themeData.textTheme.bodyText1!.copyWith(color: themeData.accentColor); + final TextStyle aboutTextStyle = themeData.textTheme.bodyText1; + final TextStyle linkStyle = themeData.textTheme.bodyText1.copyWith(color: themeData.accentColor); showAboutDialog( context: context, diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/app.dart b/dev/integration_tests/flutter_gallery/lib/gallery/app.dart index 2ccfca8d89..228d3c56fd 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/app.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/app.dart @@ -22,7 +22,7 @@ import 'updater.dart'; class GalleryApp extends StatefulWidget { const GalleryApp({ - Key? key, + Key key, this.updateUrlFetcher, this.enablePerformanceOverlay = true, this.enableRasterCacheImagesCheckerboard = true, @@ -31,11 +31,11 @@ class GalleryApp extends StatefulWidget { this.testMode = false, }) : super(key: key); - final UpdateUrlFetcher? updateUrlFetcher; + final UpdateUrlFetcher updateUrlFetcher; final bool enablePerformanceOverlay; final bool enableRasterCacheImagesCheckerboard; final bool enableOffscreenLayersCheckerboard; - final VoidCallback? onSendFeedback; + final VoidCallback onSendFeedback; final bool testMode; @override @@ -43,9 +43,9 @@ class GalleryApp extends StatefulWidget { } class _GalleryAppState extends State { - GalleryOptions? _options; - Timer? _timeDilationTimer; - late AppStateModel model; + GalleryOptions _options; + Timer _timeDilationTimer; + AppStateModel model; Map _buildRoutes() { // For a different example of how to set up an application routing table @@ -71,7 +71,7 @@ class _GalleryAppState extends State { @override void reassemble() { - _options = _options!.copyWith(platform: defaultTargetPlatform); + _options = _options.copyWith(platform: defaultTargetPlatform); super.reassemble(); } @@ -84,7 +84,7 @@ class _GalleryAppState extends State { void _handleOptionsChanged(GalleryOptions newOptions) { setState(() { - if (_options!.timeDilation != newOptions.timeDilation) { + if (_options.timeDilation != newOptions.timeDilation) { _timeDilationTimer?.cancel(); _timeDilationTimer = null; if (newOptions.timeDilation > 1.0) { @@ -108,7 +108,7 @@ class _GalleryAppState extends State { builder: (BuildContext context) { return MediaQuery( data: MediaQuery.of(context).copyWith( - textScaleFactor: _options!.textScaleFactor!.scale, + textScaleFactor: _options.textScaleFactor.scale, ), child: child, ); @@ -131,7 +131,7 @@ class _GalleryAppState extends State { if (widget.updateUrlFetcher != null) { home = Updater( - updateUrlFetcher: widget.updateUrlFetcher!, + updateUrlFetcher: widget.updateUrlFetcher, child: home, ); } @@ -139,18 +139,18 @@ class _GalleryAppState extends State { return ScopedModel( model: model, child: MaterialApp( - theme: kLightGalleryTheme.copyWith(platform: _options!.platform, visualDensity: _options!.visualDensity!.visualDensity), - darkTheme: kDarkGalleryTheme.copyWith(platform: _options!.platform, visualDensity: _options!.visualDensity!.visualDensity), - themeMode: _options!.themeMode, + theme: kLightGalleryTheme.copyWith(platform: _options.platform, visualDensity: _options.visualDensity.visualDensity), + darkTheme: kDarkGalleryTheme.copyWith(platform: _options.platform, visualDensity: _options.visualDensity.visualDensity), + themeMode: _options.themeMode, title: 'Flutter Gallery', color: Colors.grey, - showPerformanceOverlay: _options!.showPerformanceOverlay, - checkerboardOffscreenLayers: _options!.showOffscreenLayersCheckerboard, - checkerboardRasterCacheImages: _options!.showRasterCacheImagesCheckerboard, + showPerformanceOverlay: _options.showPerformanceOverlay, + checkerboardOffscreenLayers: _options.showOffscreenLayersCheckerboard, + checkerboardRasterCacheImages: _options.showRasterCacheImagesCheckerboard, routes: _buildRoutes(), - builder: (BuildContext context, Widget? child) { + builder: (BuildContext context, Widget child) { return Directionality( - textDirection: _options!.textDirection, + textDirection: _options.textDirection, child: _applyTextScaleFactor( // Specifically use a blank Cupertino theme here and do not transfer // over the Material primary color etc except the brightness to @@ -160,7 +160,7 @@ class _GalleryAppState extends State { data: CupertinoThemeData( brightness: Theme.of(context).brightness, ), - child: child!, + child: child, ); }), ), diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/backdrop.dart b/dev/integration_tests/flutter_gallery/lib/gallery/backdrop.dart index 7d740fa258..527657c45e 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/backdrop.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/backdrop.dart @@ -26,37 +26,37 @@ final Animatable _kFrontHeadingBevelRadius = BorderRadiusTween( class _TappableWhileStatusIs extends StatefulWidget { const _TappableWhileStatusIs( this.status, { - Key? key, + Key key, this.controller, this.child, }) : super(key: key); - final AnimationController? controller; + final AnimationController controller; final AnimationStatus status; - final Widget? child; + final Widget child; @override _TappableWhileStatusIsState createState() => _TappableWhileStatusIsState(); } class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { - bool? _active; + bool _active; @override void initState() { super.initState(); - widget.controller!.addStatusListener(_handleStatusChange); - _active = widget.controller!.status == widget.status; + widget.controller.addStatusListener(_handleStatusChange); + _active = widget.controller.status == widget.status; } @override void dispose() { - widget.controller!.removeStatusListener(_handleStatusChange); + widget.controller.removeStatusListener(_handleStatusChange); super.dispose(); } void _handleStatusChange(AnimationStatus status) { - final bool value = widget.controller!.status == widget.status; + final bool value = widget.controller.status == widget.status; if (_active != value) { setState(() { _active = value; @@ -67,11 +67,11 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { @override Widget build(BuildContext context) { Widget child = AbsorbPointer( - absorbing: !_active!, + absorbing: !_active, child: widget.child, ); - if (!_active!) { + if (!_active) { child = FocusScope( canRequestFocus: false, debugLabel: '$_TappableWhileStatusIs', @@ -84,16 +84,16 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { class _CrossFadeTransition extends AnimatedWidget { const _CrossFadeTransition({ - Key? key, + Key key, this.alignment = Alignment.center, - required Animation progress, + Animation progress, this.child0, this.child1, }) : super(key: key, listenable: progress); final AlignmentGeometry alignment; - final Widget? child0; - final Widget? child1; + final Widget child0; + final Widget child1; @override Widget build(BuildContext context) { @@ -135,15 +135,15 @@ class _CrossFadeTransition extends AnimatedWidget { class _BackAppBar extends StatelessWidget { const _BackAppBar({ - Key? key, + Key key, this.leading = const SizedBox(width: 56.0), - required this.title, + @required this.title, this.trailing, - }) : super(key: key); + }) : assert(leading != null), assert(title != null), super(key: key); final Widget leading; final Widget title; - final Widget? trailing; + final Widget trailing; @override Widget build(BuildContext context) { @@ -151,7 +151,7 @@ class _BackAppBar extends StatelessWidget { return IconTheme.merge( data: theme.primaryIconTheme, child: DefaultTextStyle( - style: theme.primaryTextTheme.headline6!, + style: theme.primaryTextTheme.headline6, child: SizedBox( height: _kBackAppBarHeight, child: Row( @@ -188,12 +188,12 @@ class Backdrop extends StatefulWidget { this.backLayer, }); - final Widget? frontAction; - final Widget? frontTitle; - final Widget? frontLayer; - final Widget? frontHeading; - final Widget? backTitle; - final Widget? backLayer; + final Widget frontAction; + final Widget frontTitle; + final Widget frontLayer; + final Widget frontHeading; + final Widget backTitle; + final Widget backLayer; @override _BackdropState createState() => _BackdropState(); @@ -201,8 +201,8 @@ class Backdrop extends StatefulWidget { class _BackdropState extends State with SingleTickerProviderStateMixin { final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop'); - AnimationController? _controller; - late Animation _frontOpacity; + AnimationController _controller; + Animation _frontOpacity; static final Animatable _frontOpacityTween = Tween(begin: 0.2, end: 1.0) .chain(CurveTween(curve: const Interval(0.0, 0.4, curve: Curves.easeInOut))); @@ -215,7 +215,7 @@ class _BackdropState extends State with SingleTickerProviderStateMixin value: 1.0, vsync: this, ); - _controller!.addStatusListener((AnimationStatus status) { + _controller.addStatusListener((AnimationStatus status) { setState(() { // This is intentionally left empty. The state change itself takes // place inside the AnimationController, so there's nothing to update. @@ -223,47 +223,47 @@ class _BackdropState extends State with SingleTickerProviderStateMixin // state from the AnimationController. }); }); - _frontOpacity = _controller!.drive(_frontOpacityTween); + _frontOpacity = _controller.drive(_frontOpacityTween); } @override void dispose() { - _controller!.dispose(); + _controller.dispose(); super.dispose(); } double get _backdropHeight { // Warning: this can be safely called from the event handlers but it may // not be called at build time. - final RenderBox renderBox = _backdropKey.currentContext!.findRenderObject()! as RenderBox; + final RenderBox renderBox = _backdropKey.currentContext.findRenderObject() as RenderBox; return math.max(0.0, renderBox.size.height - _kBackAppBarHeight - _kFrontClosedHeight); } void _handleDragUpdate(DragUpdateDetails details) { - _controller!.value -= details.primaryDelta! / _backdropHeight; + _controller.value -= details.primaryDelta / (_backdropHeight ?? details.primaryDelta); } void _handleDragEnd(DragEndDetails details) { - if (_controller!.isAnimating || _controller!.status == AnimationStatus.completed) + if (_controller.isAnimating || _controller.status == AnimationStatus.completed) return; final double flingVelocity = details.velocity.pixelsPerSecond.dy / _backdropHeight; if (flingVelocity < 0.0) - _controller!.fling(velocity: math.max(2.0, -flingVelocity)); + _controller.fling(velocity: math.max(2.0, -flingVelocity)); else if (flingVelocity > 0.0) - _controller!.fling(velocity: math.min(-2.0, -flingVelocity)); + _controller.fling(velocity: math.min(-2.0, -flingVelocity)); else - _controller!.fling(velocity: _controller!.value < 0.5 ? -2.0 : 2.0); + _controller.fling(velocity: _controller.value < 0.5 ? -2.0 : 2.0); } void _toggleFrontLayer() { - final AnimationStatus status = _controller!.status; + final AnimationStatus status = _controller.status; final bool isOpen = status == AnimationStatus.completed || status == AnimationStatus.forward; - _controller!.fling(velocity: isOpen ? -2.0 : 2.0); + _controller.fling(velocity: isOpen ? -2.0 : 2.0); } Widget _buildStack(BuildContext context, BoxConstraints constraints) { - final Animation frontRelativeRect = _controller!.drive(RelativeRectTween( + final Animation frontRelativeRect = _controller.drive(RelativeRectTween( begin: RelativeRect.fromLTRB(0.0, constraints.biggest.height - _kFrontClosedHeight, 0.0, 0.0), end: const RelativeRect.fromLTRB(0.0, _kBackAppBarHeight, 0.0, 0.0), )); @@ -275,9 +275,9 @@ class _BackdropState extends State with SingleTickerProviderStateMixin crossAxisAlignment: CrossAxisAlignment.stretch, children: [ _BackAppBar( - leading: widget.frontAction!, + leading: widget.frontAction, title: _CrossFadeTransition( - progress: _controller!, + progress: _controller, alignment: AlignmentDirectional.centerStart, child0: Semantics(namesRoute: true, child: widget.frontTitle), child1: Semantics(namesRoute: true, child: widget.backTitle), @@ -287,7 +287,7 @@ class _BackdropState extends State with SingleTickerProviderStateMixin tooltip: 'Toggle options page', icon: AnimatedIcon( icon: AnimatedIcons.close_menu, - progress: _controller!, + progress: _controller, ), ), ), @@ -296,8 +296,8 @@ class _BackdropState extends State with SingleTickerProviderStateMixin AnimationStatus.dismissed, controller: _controller, child: Visibility( - child: widget.backLayer!, - visible: _controller!.status != AnimationStatus.completed, + child: widget.backLayer, + visible: _controller.status != AnimationStatus.completed, maintainState: true, ), ), @@ -308,14 +308,14 @@ class _BackdropState extends State with SingleTickerProviderStateMixin PositionedTransition( rect: frontRelativeRect, child: AnimatedBuilder( - animation: _controller!, - builder: (BuildContext context, Widget? child) { + animation: _controller, + builder: (BuildContext context, Widget child) { return PhysicalShape( elevation: 12.0, color: Theme.of(context).canvasColor, clipper: ShapeBorderClipper( shape: BeveledRectangleBorder( - borderRadius: _kFrontHeadingBevelRadius.transform(_controller!.value), + borderRadius: _kFrontHeadingBevelRadius.transform(_controller.value), ), ), clipBehavior: Clip.antiAlias, diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/demo.dart b/dev/integration_tests/flutter_gallery/lib/gallery/demo.dart index c6cdcd4627..e3efe2c049 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/demo.dart @@ -20,11 +20,11 @@ class ComponentDemoTabData { this.documentationUrl, }); - final Widget? demoWidget; - final String? exampleCodeTag; - final String? description; - final String? tabName; - final String? documentationUrl; + final Widget demoWidget; + final String exampleCodeTag; + final String description; + final String tabName; + final String documentationUrl; @override bool operator==(Object other) { @@ -49,14 +49,14 @@ class TabbedComponentDemoScaffold extends StatelessWidget { this.showExampleCodeAction = true, }); - final List? demos; - final String? title; - final List? actions; + final List demos; + final String title; + final List actions; final bool isScrollable; final bool showExampleCodeAction; void _showExampleCode(BuildContext context) { - final String? tag = demos![DefaultTabController.of(context)!.index].exampleCodeTag; + final String tag = demos[DefaultTabController.of(context).index].exampleCodeTag; if (tag != null) { Navigator.push(context, MaterialPageRoute( builder: (BuildContext context) => FullScreenCodeDialog(exampleCodeTag: tag) @@ -65,7 +65,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget { } Future _showApiDocumentation(BuildContext context) async { - final String? url = demos![DefaultTabController.of(context)!.index].documentationUrl; + final String url = demos[DefaultTabController.of(context).index].documentationUrl; if (url == null) return; @@ -92,10 +92,10 @@ class TabbedComponentDemoScaffold extends StatelessWidget { @override Widget build(BuildContext context) { return DefaultTabController( - length: demos!.length, + length: demos.length, child: Scaffold( appBar: AppBar( - title: Text(title!), + title: Text(title), actions: [ ...?actions, Builder( @@ -119,11 +119,11 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ], bottom: TabBar( isScrollable: isScrollable, - tabs: demos!.map((ComponentDemoTabData data) => Tab(text: data.tabName)).toList(), + tabs: demos.map((ComponentDemoTabData data) => Tab(text: data.tabName)).toList(), ), ), body: TabBarView( - children: demos!.map((ComponentDemoTabData demo) { + children: demos.map((ComponentDemoTabData demo) { return SafeArea( top: false, bottom: false, @@ -131,11 +131,11 @@ class TabbedComponentDemoScaffold extends StatelessWidget { children: [ Padding( padding: const EdgeInsets.all(16.0), - child: Text(demo.description!, + child: Text(demo.description, style: Theme.of(context).textTheme.subtitle1, ), ), - Expanded(child: demo.demoWidget!), + Expanded(child: demo.demoWidget), ], ), ); @@ -149,7 +149,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget { class FullScreenCodeDialog extends StatefulWidget { const FullScreenCodeDialog({ this.exampleCodeTag }); - final String? exampleCodeTag; + final String exampleCodeTag; @override FullScreenCodeDialogState createState() => FullScreenCodeDialogState(); @@ -157,11 +157,11 @@ class FullScreenCodeDialog extends StatefulWidget { class FullScreenCodeDialogState extends State { - String? _exampleCode; + String _exampleCode; @override void didChangeDependencies() { - getExampleCode(widget.exampleCodeTag, DefaultAssetBundle.of(context)).then((String? code) { + getExampleCode(widget.exampleCodeTag, DefaultAssetBundle.of(context)).then((String code) { if (mounted) { setState(() { _exampleCode = code ?? 'Example code not found'; @@ -215,7 +215,7 @@ class FullScreenCodeDialogState extends State { } class MaterialDemoDocumentationButton extends StatelessWidget { - MaterialDemoDocumentationButton(String routeName, { Key? key }) + MaterialDemoDocumentationButton(String routeName, { Key key }) : documentationUrl = kDemoDocumentationUrl[routeName], assert( kDemoDocumentationUrl[routeName] != null, @@ -223,20 +223,20 @@ class MaterialDemoDocumentationButton extends StatelessWidget { ), super(key: key); - final String? documentationUrl; + final String documentationUrl; @override Widget build(BuildContext context) { return IconButton( icon: const Icon(Icons.library_books), tooltip: 'API documentation', - onPressed: () => launch(documentationUrl!, forceWebView: true), + onPressed: () => launch(documentationUrl, forceWebView: true), ); } } class CupertinoDemoDocumentationButton extends StatelessWidget { - CupertinoDemoDocumentationButton(String routeName, { Key? key }) + CupertinoDemoDocumentationButton(String routeName, { Key key }) : documentationUrl = kDemoDocumentationUrl[routeName], assert( kDemoDocumentationUrl[routeName] != null, @@ -244,7 +244,7 @@ class CupertinoDemoDocumentationButton extends StatelessWidget { ), super(key: key); - final String? documentationUrl; + final String documentationUrl; @override Widget build(BuildContext context) { @@ -254,7 +254,7 @@ class CupertinoDemoDocumentationButton extends StatelessWidget { label: 'API documentation', child: const Icon(CupertinoIcons.book), ), - onPressed: () => launch(documentationUrl!, forceWebView: true), + onPressed: () => launch(documentationUrl, forceWebView: true), ); } } diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/demos.dart b/dev/integration_tests/flutter_gallery/lib/gallery/demos.dart index 81ed41d272..5f8eec6e25 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/demos.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/demos.dart @@ -10,8 +10,8 @@ import 'icons.dart'; @immutable class GalleryDemoCategory { const GalleryDemoCategory._({ - required this.name, - required this.icon, + @required this.name, + @required this.icon, }); final String name; @@ -64,22 +64,25 @@ const GalleryDemoCategory _kMedia = GalleryDemoCategory._( class GalleryDemo { const GalleryDemo({ - required this.title, - required this.icon, + @required this.title, + @required this.icon, this.subtitle, - required this.category, - required this.routeName, + @required this.category, + @required this.routeName, this.documentationUrl, - required this.buildRoute, - }); + @required this.buildRoute, + }) : assert(title != null), + assert(category != null), + assert(routeName != null), + assert(buildRoute != null); final String title; final IconData icon; - final String? subtitle; + final String subtitle; final GalleryDemoCategory category; final String routeName; final WidgetBuilder buildRoute; - final String? documentationUrl; + final String documentationUrl; @override String toString() { @@ -578,7 +581,7 @@ final Map> kGalleryCategoryToDemos = }, ); -final Map kDemoDocumentationUrl = { +final Map kDemoDocumentationUrl = { for (final GalleryDemo demo in kAllGalleryDemos) if (demo.documentationUrl != null) demo.routeName: demo.documentationUrl, }; diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/example_code.dart b/dev/integration_tests/flutter_gallery/lib/gallery/example_code.dart index 1a00a3bcc9..d68761d852 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/example_code.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/example_code.dart @@ -9,7 +9,7 @@ import 'package:flutter/material.dart'; class ButtonsDemo { void setState(VoidCallback callback) { } - late BuildContext context; + BuildContext context; void buttons() { @@ -90,12 +90,12 @@ const TextButton( // START buttons_dropdown // Member variable holding value. -String? dropdownValue; +String dropdownValue; // Dropdown button with string values. DropdownButton( value: dropdownValue, - onChanged: (String? newValue) { + onChanged: (String newValue) { // null indicates the user didn't select a // new value. setState(() { @@ -116,7 +116,7 @@ DropdownButton( // START buttons_icon // Member variable holding toggle value. -late bool value; +bool value; // Toggleable icon button. IconButton( @@ -152,12 +152,12 @@ class SelectionControls { // START selectioncontrols_checkbox // Member variable holding the checkbox's value. -bool? checkboxValue = false; +bool checkboxValue = false; // Create a checkbox. Checkbox( value: checkboxValue, - onChanged: (bool? value) { + onChanged: (bool value) { setState(() { checkboxValue = value; }); @@ -168,7 +168,7 @@ Checkbox( Checkbox( tristate: true, value: checkboxValue, - onChanged: (bool? value) { + onChanged: (bool value) { setState(() { checkboxValue = value; }); @@ -184,10 +184,10 @@ const Checkbox(value: false, onChanged: null); // START selectioncontrols_radio // Member variable holding value. -int? radioValue = 0; +int radioValue = 0; // Method setting value. -void handleRadioValueChanged(int? value) { +void handleRadioValueChanged(int value) { setState(() { radioValue = value; }); diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/example_code_parser.dart b/dev/integration_tests/flutter_gallery/lib/gallery/example_code_parser.dart index cab344adcf..eef18858f9 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/example_code_parser.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/example_code_parser.dart @@ -7,22 +7,23 @@ import 'package:flutter/services.dart'; const String _kStartTag = '// START '; const String _kEndTag = '// END'; -Map? _exampleCode; +Map _exampleCode; -Future getExampleCode(String? tag, AssetBundle bundle) async { +Future getExampleCode(String tag, AssetBundle bundle) async { if (_exampleCode == null) await _parseExampleCode(bundle); - return _exampleCode![tag]; + return _exampleCode[tag]; } Future _parseExampleCode(AssetBundle bundle) async { - final String code = await bundle.loadString('lib/gallery/example_code.dart'); - _exampleCode = {}; + final String code = await bundle.loadString('lib/gallery/example_code.dart') ?? + '// lib/gallery/example_code.dart not found\n'; + _exampleCode = {}; final List lines = code.split('\n'); - List? codeBlock; - String? codeTag; + List codeBlock; + String codeTag; for (final String line in lines) { if (codeBlock == null) { @@ -38,7 +39,7 @@ Future _parseExampleCode(AssetBundle bundle) async { // Inside a block. if (line.startsWith(_kEndTag)) { // Add the block. - _exampleCode![codeTag] = codeBlock.join('\n'); + _exampleCode[codeTag] = codeBlock.join('\n'); codeBlock = null; codeTag = null; } else { diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/home.dart b/dev/integration_tests/flutter_gallery/lib/gallery/home.dart index 9c1f3b3dc2..52e435e276 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/home.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/home.dart @@ -18,7 +18,7 @@ const double _kDemoItemHeight = 64.0; const Duration _kFrontLayerSwitchDuration = Duration(milliseconds: 300); class _FlutterLogo extends StatelessWidget { - const _FlutterLogo({ Key? key }) : super(key: key); + const _FlutterLogo({ Key key }) : super(key: key); @override Widget build(BuildContext context) { @@ -41,13 +41,13 @@ class _FlutterLogo extends StatelessWidget { class _CategoryItem extends StatelessWidget { const _CategoryItem({ - Key? key, + Key key, this.category, this.onTap, }) : super (key: key); - final GalleryDemoCategory? category; - final VoidCallback? onTap; + final GalleryDemoCategory category; + final VoidCallback onTap; @override Widget build(BuildContext context) { @@ -70,7 +70,7 @@ class _CategoryItem extends StatelessWidget { Padding( padding: const EdgeInsets.all(6.0), child: Icon( - category!.icon, + category.icon, size: 60.0, color: isDark ? Colors.white : _kFlutterBlue, ), @@ -80,9 +80,9 @@ class _CategoryItem extends StatelessWidget { height: 48.0, alignment: Alignment.center, child: Text( - category!.name, + category.name, textAlign: TextAlign.center, - style: theme.textTheme.subtitle1!.copyWith( + style: theme.textTheme.subtitle1.copyWith( fontFamily: 'GoogleSans', color: isDark ? Colors.white : _kFlutterBlue, ), @@ -97,18 +97,18 @@ class _CategoryItem extends StatelessWidget { class _CategoriesPage extends StatelessWidget { const _CategoriesPage({ - Key? key, + Key key, this.categories, this.onCategoryTap, }) : super(key: key); - final Iterable? categories; - final ValueChanged? onCategoryTap; + final Iterable categories; + final ValueChanged onCategoryTap; @override Widget build(BuildContext context) { const double aspectRatio = 160.0 / 180.0; - final List categoriesList = categories!.toList(); + final List categoriesList = categories.toList(); final int columnCount = (MediaQuery.of(context).orientation == Orientation.portrait) ? 2 : 3; return Semantics( @@ -122,7 +122,7 @@ class _CategoriesPage extends StatelessWidget { builder: (BuildContext context, BoxConstraints constraints) { final double columnWidth = constraints.biggest.width / columnCount.toDouble(); final double rowHeight = math.min(225.0, columnWidth * aspectRatio); - final int rowCount = (categories!.length + columnCount - 1) ~/ columnCount; + final int rowCount = (categories.length + columnCount - 1) ~/ columnCount; // This repaint boundary prevents the inner contents of the front layer // from repainting when the backdrop toggle triggers a repaint on the @@ -133,7 +133,7 @@ class _CategoriesPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.stretch, children: List.generate(rowCount, (int rowIndex) { final int columnCountForRow = rowIndex == rowCount - 1 - ? categories!.length - columnCount * math.max(0, rowCount - 1) + ? categories.length - columnCount * math.max(0, rowCount - 1) : columnCount; return Row( @@ -147,7 +147,7 @@ class _CategoriesPage extends StatelessWidget { child: _CategoryItem( category: category, onTap: () { - onCategoryTap!(category); + onCategoryTap(category); }, ), ); @@ -164,17 +164,17 @@ class _CategoriesPage extends StatelessWidget { } class _DemoItem extends StatelessWidget { - const _DemoItem({ Key? key, this.demo }) : super(key: key); + const _DemoItem({ Key key, this.demo }) : super(key: key); - final GalleryDemo? demo; + final GalleryDemo demo; void _launchDemo(BuildContext context) { - if (demo != null) { + if (demo.routeName != null) { Timeline.instantSync('Start Transition', arguments: { 'from': '/', - 'to': demo!.routeName, + 'to': demo.routeName, }); - Navigator.pushNamed(context, demo!.routeName); + Navigator.pushNamed(context, demo.routeName); } } @@ -199,7 +199,7 @@ class _DemoItem extends StatelessWidget { height: 56.0, alignment: Alignment.center, child: Icon( - demo!.icon, + demo.icon, size: 24.0, color: isDark ? Colors.white : _kFlutterBlue, ), @@ -210,15 +210,15 @@ class _DemoItem extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Text( - demo!.title, - style: theme.textTheme.subtitle1!.copyWith( + demo.title, + style: theme.textTheme.subtitle1.copyWith( color: isDark ? Colors.white : const Color(0xFF202124), ), ), - if (demo!.subtitle != null) + if (demo.subtitle != null) Text( - demo!.subtitle!, - style: theme.textTheme.bodyText2!.copyWith( + demo.subtitle, + style: theme.textTheme.bodyText2.copyWith( color: isDark ? Colors.white : const Color(0xFF60646B) ), ), @@ -236,7 +236,7 @@ class _DemoItem extends StatelessWidget { class _DemosPage extends StatelessWidget { const _DemosPage(this.category); - final GalleryDemoCategory? category; + final GalleryDemoCategory category; @override Widget build(BuildContext context) { @@ -248,13 +248,13 @@ class _DemosPage extends StatelessWidget { child: Semantics( scopesRoute: true, namesRoute: true, - label: category!.name, + label: category.name, explicitChildNodes: true, child: ListView( dragStartBehavior: DragStartBehavior.down, - key: PageStorageKey(category!.name), + key: PageStorageKey(category.name), padding: EdgeInsets.only(top: 8.0, bottom: windowBottomPadding), - children: kGalleryCategoryToDemos[category!]!.map((GalleryDemo demo) { + children: kGalleryCategoryToDemos[category].map((GalleryDemo demo) { return _DemoItem(demo: demo); }).toList(), ), @@ -265,12 +265,12 @@ class _DemosPage extends StatelessWidget { class GalleryHome extends StatefulWidget { const GalleryHome({ - Key? key, + Key key, this.testMode = false, this.optionsPage, }) : super(key: key); - final Widget? optionsPage; + final Widget optionsPage; final bool testMode; // In checked mode our MaterialApp will show the default "debug" banner. @@ -283,10 +283,10 @@ class GalleryHome extends StatefulWidget { class _GalleryHomeState extends State with SingleTickerProviderStateMixin { static final GlobalKey _scaffoldKey = GlobalKey(); - late AnimationController _controller; - GalleryDemoCategory? _category; + AnimationController _controller; + GalleryDemoCategory _category; - static Widget _topHomeLayout(Widget? currentChild, List previousChildren) { + static Widget _topHomeLayout(Widget currentChild, List previousChildren) { return Stack( children: [ ...previousChildren, @@ -357,7 +357,7 @@ class _GalleryHomeState extends State with SingleTickerProviderStat duration: _kFrontLayerSwitchDuration, child: _category == null ? const Text('Flutter gallery') - : Text(_category!.name), + : Text(_category.name), ), frontHeading: widget.testMode ? null : Container(height: 24.0), frontLayer: AnimatedSwitcher( diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/options.dart b/dev/integration_tests/flutter_gallery/lib/gallery/options.dart index 6e7220d459..b7ca9d9a8f 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/options.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/options.dart @@ -21,26 +21,26 @@ class GalleryOptions { this.showPerformanceOverlay = false, }); - final ThemeMode? themeMode; - final GalleryTextScaleValue? textScaleFactor; - final GalleryVisualDensityValue? visualDensity; + final ThemeMode themeMode; + final GalleryTextScaleValue textScaleFactor; + final GalleryVisualDensityValue visualDensity; final TextDirection textDirection; final double timeDilation; - final TargetPlatform? platform; + final TargetPlatform platform; final bool showPerformanceOverlay; final bool showRasterCacheImagesCheckerboard; final bool showOffscreenLayersCheckerboard; GalleryOptions copyWith({ - ThemeMode? themeMode, - GalleryTextScaleValue? textScaleFactor, - GalleryVisualDensityValue? visualDensity, - TextDirection? textDirection, - double? timeDilation, - TargetPlatform? platform, - bool? showPerformanceOverlay, - bool? showRasterCacheImagesCheckerboard, - bool? showOffscreenLayersCheckerboard, + ThemeMode themeMode, + GalleryTextScaleValue textScaleFactor, + GalleryVisualDensityValue visualDensity, + TextDirection textDirection, + double timeDilation, + TargetPlatform platform, + bool showPerformanceOverlay, + bool showRasterCacheImagesCheckerboard, + bool showOffscreenLayersCheckerboard, }) { return GalleryOptions( themeMode: themeMode ?? this.themeMode, @@ -93,9 +93,9 @@ const double _kItemHeight = 48.0; const EdgeInsetsDirectional _kItemPadding = EdgeInsetsDirectional.only(start: 56.0); class _OptionsItem extends StatelessWidget { - const _OptionsItem({ Key? key, this.child }) : super(key: key); + const _OptionsItem({ Key key, this.child }) : super(key: key); - final Widget? child; + final Widget child; @override Widget build(BuildContext context) { @@ -112,7 +112,7 @@ class _OptionsItem extends StatelessWidget { overflow: TextOverflow.fade, child: IconTheme( data: Theme.of(context).primaryIconTheme, - child: child!, + child: child, ), ), ), @@ -127,7 +127,7 @@ class _BooleanItem extends StatelessWidget { final bool value; final ValueChanged onChanged; // [switchKey] is used for accessing the switch from driver tests. - final Key? switchKey; + final Key switchKey; @override Widget build(BuildContext context) { @@ -153,7 +153,7 @@ class _ActionItem extends StatelessWidget { const _ActionItem(this.text, this.onTap); final String text; - final VoidCallback? onTap; + final VoidCallback onTap; @override Widget build(BuildContext context) { @@ -167,10 +167,10 @@ class _ActionItem extends StatelessWidget { } class _TextButton extends StatelessWidget { - const _TextButton({ Key? key, this.onPressed, this.child }) : super(key: key); + const _TextButton({ Key key, this.onPressed, this.child }) : super(key: key); - final VoidCallback? onPressed; - final Widget? child; + final VoidCallback onPressed; + final Widget child; @override Widget build(BuildContext context) { @@ -182,7 +182,7 @@ class _TextButton extends StatelessWidget { padding: EdgeInsets.zero, ), onPressed: onPressed, - child: child!, + child: child, ); } } @@ -197,7 +197,7 @@ class _Heading extends StatelessWidget { final ThemeData theme = Theme.of(context); return _OptionsItem( child: DefaultTextStyle( - style: theme.textTheme.headline6!.copyWith( + style: theme.textTheme.headline6.copyWith( fontFamily: 'GoogleSans', color: theme.colorScheme.onPrimary, fontWeight: FontWeight.w700, @@ -214,8 +214,8 @@ class _Heading extends StatelessWidget { class _ThemeModeItem extends StatelessWidget { const _ThemeModeItem(this.options, this.onOptionsChanged); - final GalleryOptions? options; - final ValueChanged? onOptionsChanged; + final GalleryOptions options; + final ValueChanged onOptionsChanged; static final Map modeLabels = { ThemeMode.system: 'System Default', @@ -234,7 +234,7 @@ class _ThemeModeItem extends StatelessWidget { children: [ const Text('Theme'), Text( - modeLabels[options!.themeMode!]!, + modeLabels[options.themeMode], style: Theme.of(context).primaryTextTheme.bodyText2, ), ], @@ -243,18 +243,18 @@ class _ThemeModeItem extends StatelessWidget { PopupMenuButton( padding: const EdgeInsetsDirectional.only(end: 16.0), icon: const Icon(Icons.arrow_drop_down), - initialValue: options!.themeMode, + initialValue: options.themeMode, itemBuilder: (BuildContext context) { return ThemeMode.values.map>((ThemeMode mode) { return PopupMenuItem( value: mode, - child: Text(modeLabels[mode]!), + child: Text(modeLabels[mode]), ); }).toList(); }, onSelected: (ThemeMode mode) { - onOptionsChanged!( - options!.copyWith(themeMode: mode), + onOptionsChanged( + options.copyWith(themeMode: mode), ); }, ), @@ -267,8 +267,8 @@ class _ThemeModeItem extends StatelessWidget { class _TextScaleFactorItem extends StatelessWidget { const _TextScaleFactorItem(this.options, this.onOptionsChanged); - final GalleryOptions? options; - final ValueChanged? onOptionsChanged; + final GalleryOptions options; + final ValueChanged onOptionsChanged; @override Widget build(BuildContext context) { @@ -281,7 +281,7 @@ class _TextScaleFactorItem extends StatelessWidget { children: [ const Text('Text size'), Text( - options!.textScaleFactor!.label, + options.textScaleFactor.label, style: Theme.of(context).primaryTextTheme.bodyText2, ), ], @@ -299,8 +299,8 @@ class _TextScaleFactorItem extends StatelessWidget { }).toList(); }, onSelected: (GalleryTextScaleValue scaleValue) { - onOptionsChanged!( - options!.copyWith(textScaleFactor: scaleValue), + onOptionsChanged( + options.copyWith(textScaleFactor: scaleValue), ); }, ), @@ -313,8 +313,8 @@ class _TextScaleFactorItem extends StatelessWidget { class _VisualDensityItem extends StatelessWidget { const _VisualDensityItem(this.options, this.onOptionsChanged); - final GalleryOptions? options; - final ValueChanged? onOptionsChanged; + final GalleryOptions options; + final ValueChanged onOptionsChanged; @override Widget build(BuildContext context) { @@ -327,7 +327,7 @@ class _VisualDensityItem extends StatelessWidget { children: [ const Text('Visual density'), Text( - options!.visualDensity!.label, + options.visualDensity.label, style: Theme.of(context).primaryTextTheme.bodyText2, ), ], @@ -345,8 +345,8 @@ class _VisualDensityItem extends StatelessWidget { }).toList(); }, onSelected: (GalleryVisualDensityValue densityValue) { - onOptionsChanged!( - options!.copyWith(visualDensity: densityValue), + onOptionsChanged( + options.copyWith(visualDensity: densityValue), ); }, ), @@ -359,17 +359,17 @@ class _VisualDensityItem extends StatelessWidget { class _TextDirectionItem extends StatelessWidget { const _TextDirectionItem(this.options, this.onOptionsChanged); - final GalleryOptions? options; - final ValueChanged? onOptionsChanged; + final GalleryOptions options; + final ValueChanged onOptionsChanged; @override Widget build(BuildContext context) { return _BooleanItem( 'Force RTL', - options!.textDirection == TextDirection.rtl, + options.textDirection == TextDirection.rtl, (bool value) { - onOptionsChanged!( - options!.copyWith( + onOptionsChanged( + options.copyWith( textDirection: value ? TextDirection.rtl : TextDirection.ltr, ), ); @@ -382,17 +382,17 @@ class _TextDirectionItem extends StatelessWidget { class _TimeDilationItem extends StatelessWidget { const _TimeDilationItem(this.options, this.onOptionsChanged); - final GalleryOptions? options; - final ValueChanged? onOptionsChanged; + final GalleryOptions options; + final ValueChanged onOptionsChanged; @override Widget build(BuildContext context) { return _BooleanItem( 'Slow motion', - options!.timeDilation != 1.0, + options.timeDilation != 1.0, (bool value) { - onOptionsChanged!( - options!.copyWith( + onOptionsChanged( + options.copyWith( timeDilation: value ? 20.0 : 1.0, ), ); @@ -405,10 +405,10 @@ class _TimeDilationItem extends StatelessWidget { class _PlatformItem extends StatelessWidget { const _PlatformItem(this.options, this.onOptionsChanged); - final GalleryOptions? options; - final ValueChanged? onOptionsChanged; + final GalleryOptions options; + final ValueChanged onOptionsChanged; - String? _platformLabel(TargetPlatform? platform) { + String _platformLabel(TargetPlatform platform) { switch(platform) { case TargetPlatform.android: return 'Mountain View'; @@ -422,10 +422,9 @@ class _PlatformItem extends StatelessWidget { return 'Material Desktop (macOS)'; case TargetPlatform.windows: return 'Material Desktop (Windows)'; - default: - assert(false); - return null; } + assert(false); + return null; } @override @@ -439,7 +438,7 @@ class _PlatformItem extends StatelessWidget { children: [ const Text('Platform mechanics'), Text( - _platformLabel(options!.platform)!, + _platformLabel(options.platform), style: Theme.of(context).primaryTextTheme.bodyText2, ), ], @@ -452,13 +451,13 @@ class _PlatformItem extends StatelessWidget { return TargetPlatform.values.map((TargetPlatform platform) { return PopupMenuItem( value: platform, - child: Text(_platformLabel(platform)!), + child: Text(_platformLabel(platform)), ); }).toList(); }, onSelected: (TargetPlatform platform) { - onOptionsChanged!( - options!.copyWith(platform: platform), + onOptionsChanged( + options.copyWith(platform: platform), ); }, ), @@ -470,46 +469,51 @@ class _PlatformItem extends StatelessWidget { class GalleryOptionsPage extends StatelessWidget { const GalleryOptionsPage({ - Key? key, + Key key, this.options, this.onOptionsChanged, this.onSendFeedback, }) : super(key: key); - final GalleryOptions? options; - final ValueChanged? onOptionsChanged; - final VoidCallback? onSendFeedback; + final GalleryOptions options; + final ValueChanged onOptionsChanged; + final VoidCallback onSendFeedback; List _enabledDiagnosticItems() { // Boolean showFoo options with a value of null: don't display // the showFoo option at all. - if (options == null) + if (options.showOffscreenLayersCheckerboard == null && + options.showRasterCacheImagesCheckerboard == null && + options.showPerformanceOverlay == null) return const []; return [ const Divider(), const _Heading('Diagnostics'), - _BooleanItem( - 'Highlight offscreen layers', - options!.showOffscreenLayersCheckerboard, - (bool value) { - onOptionsChanged!(options!.copyWith(showOffscreenLayersCheckerboard: value)); - }, - ), - _BooleanItem( - 'Highlight raster cache images', - options!.showRasterCacheImagesCheckerboard, - (bool value) { - onOptionsChanged!(options!.copyWith(showRasterCacheImagesCheckerboard: value)); - }, - ), - _BooleanItem( - 'Show performance overlay', - options!.showPerformanceOverlay, - (bool value) { - onOptionsChanged!(options!.copyWith(showPerformanceOverlay: value)); - }, - ), + if (options.showOffscreenLayersCheckerboard != null) + _BooleanItem( + 'Highlight offscreen layers', + options.showOffscreenLayersCheckerboard, + (bool value) { + onOptionsChanged(options.copyWith(showOffscreenLayersCheckerboard: value)); + }, + ), + if (options.showRasterCacheImagesCheckerboard != null) + _BooleanItem( + 'Highlight raster cache images', + options.showRasterCacheImagesCheckerboard, + (bool value) { + onOptionsChanged(options.copyWith(showRasterCacheImagesCheckerboard: value)); + }, + ), + if (options.showPerformanceOverlay != null) + _BooleanItem( + 'Show performance overlay', + options.showPerformanceOverlay, + (bool value) { + onOptionsChanged(options.copyWith(showPerformanceOverlay: value)); + }, + ), ]; } @@ -518,7 +522,7 @@ class GalleryOptionsPage extends StatelessWidget { final ThemeData theme = Theme.of(context); return DefaultTextStyle( - style: theme.primaryTextTheme.subtitle1!, + style: theme.primaryTextTheme.subtitle1, child: ListView( padding: const EdgeInsets.only(bottom: 124.0), children: [ diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/scales.dart b/dev/integration_tests/flutter_gallery/lib/gallery/scales.dart index 93163f806a..bf32601282 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/scales.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/scales.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; class GalleryTextScaleValue { const GalleryTextScaleValue(this.scale, this.label); - final double? scale; + final double scale; final String label; @override diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/syntax_highlighter.dart b/dev/integration_tests/flutter_gallery/lib/gallery/syntax_highlighter.dart index dea3bf6825..a2023b270d 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/syntax_highlighter.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/syntax_highlighter.dart @@ -43,14 +43,14 @@ class SyntaxHighlighterStyle { ); } - final TextStyle? baseStyle; - final TextStyle? numberStyle; - final TextStyle? commentStyle; - final TextStyle? keywordStyle; - final TextStyle? stringStyle; - final TextStyle? punctuationStyle; - final TextStyle? classStyle; - final TextStyle? constantStyle; + final TextStyle baseStyle; + final TextStyle numberStyle; + final TextStyle commentStyle; + final TextStyle keywordStyle; + final TextStyle stringStyle; + final TextStyle punctuationStyle; + final TextStyle classStyle; + final TextStyle constantStyle; } abstract class SyntaxHighlighter { @@ -63,7 +63,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { _style ??= SyntaxHighlighterStyle.darkThemeStyle(); } - SyntaxHighlighterStyle? _style; + SyntaxHighlighterStyle _style; static const List _keywords = [ 'abstract', 'as', 'assert', 'async', 'await', 'break', 'case', 'catch', @@ -79,15 +79,15 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { 'int', 'double', 'num', 'bool', ]; - String? _src; - late StringScanner _scanner; + String _src; + StringScanner _scanner; - late List<_HighlightSpan> _spans; + List<_HighlightSpan> _spans; @override - TextSpan format(String? src) { + TextSpan format(String src) { _src = src; - _scanner = StringScanner(_src!); + _scanner = StringScanner(_src); if (_generateSpans()) { // Successfully parsed the code @@ -96,20 +96,20 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { for (final _HighlightSpan span in _spans) { if (currentPosition != span.start) - formattedText.add(TextSpan(text: _src!.substring(currentPosition, span.start))); + formattedText.add(TextSpan(text: _src.substring(currentPosition, span.start))); - formattedText.add(TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src!))); + formattedText.add(TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src))); currentPosition = span.end; } - if (currentPosition != _src!.length) - formattedText.add(TextSpan(text: _src!.substring(currentPosition, _src!.length))); + if (currentPosition != _src.length) + formattedText.add(TextSpan(text: _src.substring(currentPosition, _src.length))); - return TextSpan(style: _style!.baseStyle, children: formattedText); + return TextSpan(style: _style.baseStyle, children: formattedText); } else { // Parsing failed, return with only basic formatting - return TextSpan(style: _style!.baseStyle, text: src); + return TextSpan(style: _style.baseStyle, text: src); } } @@ -124,23 +124,23 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) { _spans.add(_HighlightSpan( _HighlightType.comment, - _scanner.lastMatch!.start, - _scanner.lastMatch!.end, + _scanner.lastMatch.start, + _scanner.lastMatch.end, )); continue; } // Line comments if (_scanner.scan('//')) { - final int startComment = _scanner.lastMatch!.start; + final int startComment = _scanner.lastMatch.start; bool eof = false; int endComment; if (_scanner.scan(RegExp(r'.*\n'))) { - endComment = _scanner.lastMatch!.end - 1; + endComment = _scanner.lastMatch.end - 1; } else { eof = true; - endComment = _src!.length; + endComment = _src.length; } _spans.add(_HighlightSpan( @@ -159,8 +159,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { if (_scanner.scan(RegExp(r'r".*"'))) { _spans.add(_HighlightSpan( _HighlightType.string, - _scanner.lastMatch!.start, - _scanner.lastMatch!.end, + _scanner.lastMatch.start, + _scanner.lastMatch.end, )); continue; } @@ -169,8 +169,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { if (_scanner.scan(RegExp(r"r'.*'"))) { _spans.add(_HighlightSpan( _HighlightType.string, - _scanner.lastMatch!.start, - _scanner.lastMatch!.end, + _scanner.lastMatch.start, + _scanner.lastMatch.end, )); continue; } @@ -179,8 +179,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) { _spans.add(_HighlightSpan( _HighlightType.string, - _scanner.lastMatch!.start, - _scanner.lastMatch!.end, + _scanner.lastMatch.start, + _scanner.lastMatch.end, )); continue; } @@ -189,8 +189,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) { _spans.add(_HighlightSpan( _HighlightType.string, - _scanner.lastMatch!.start, - _scanner.lastMatch!.end, + _scanner.lastMatch.start, + _scanner.lastMatch.end, )); continue; } @@ -199,8 +199,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) { _spans.add(_HighlightSpan( _HighlightType.string, - _scanner.lastMatch!.start, - _scanner.lastMatch!.end, + _scanner.lastMatch.start, + _scanner.lastMatch.end, )); continue; } @@ -209,8 +209,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) { _spans.add(_HighlightSpan( _HighlightType.string, - _scanner.lastMatch!.start, - _scanner.lastMatch!.end, + _scanner.lastMatch.start, + _scanner.lastMatch.end, )); continue; } @@ -219,8 +219,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { if (_scanner.scan(RegExp(r'\d+\.\d+'))) { _spans.add(_HighlightSpan( _HighlightType.number, - _scanner.lastMatch!.start, - _scanner.lastMatch!.end, + _scanner.lastMatch.start, + _scanner.lastMatch.end, )); continue; } @@ -229,8 +229,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { if (_scanner.scan(RegExp(r'\d+'))) { _spans.add(_HighlightSpan( _HighlightType.number, - _scanner.lastMatch!.start, - _scanner.lastMatch!.end) + _scanner.lastMatch.start, + _scanner.lastMatch.end) ); continue; } @@ -239,8 +239,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) { _spans.add(_HighlightSpan( _HighlightType.punctuation, - _scanner.lastMatch!.start, - _scanner.lastMatch!.end, + _scanner.lastMatch.start, + _scanner.lastMatch.end, )); continue; } @@ -249,17 +249,17 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { if (_scanner.scan(RegExp(r'@\w+'))) { _spans.add(_HighlightSpan( _HighlightType.keyword, - _scanner.lastMatch!.start, - _scanner.lastMatch!.end, + _scanner.lastMatch.start, + _scanner.lastMatch.end, )); continue; } // Words if (_scanner.scan(RegExp(r'\w+'))) { - _HighlightType? type; + _HighlightType type; - String word = _scanner.lastMatch![0]!; + String word = _scanner.lastMatch[0]; if (word.startsWith('_')) word = word.substring(1); @@ -275,8 +275,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { if (type != null) { _spans.add(_HighlightSpan( type, - _scanner.lastMatch!.start, - _scanner.lastMatch!.end, + _scanner.lastMatch.start, + _scanner.lastMatch.end, )); } } @@ -335,22 +335,22 @@ class _HighlightSpan { return src.substring(start, end); } - TextStyle? textStyle(SyntaxHighlighterStyle? style) { + TextStyle textStyle(SyntaxHighlighterStyle style) { if (type == _HighlightType.number) - return style!.numberStyle; + return style.numberStyle; else if (type == _HighlightType.comment) - return style!.commentStyle; + return style.commentStyle; else if (type == _HighlightType.keyword) - return style!.keywordStyle; + return style.keywordStyle; else if (type == _HighlightType.string) - return style!.stringStyle; + return style.stringStyle; else if (type == _HighlightType.punctuation) - return style!.punctuationStyle; + return style.punctuationStyle; else if (type == _HighlightType.klass) - return style!.classStyle; + return style.classStyle; else if (type == _HighlightType.constant) - return style!.constantStyle; + return style.constantStyle; else - return style!.baseStyle; + return style.baseStyle; } } diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/themes.dart b/dev/integration_tests/flutter_gallery/lib/gallery/themes.dart index 8d7163e284..ac4c41e9f7 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/themes.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/themes.dart @@ -9,7 +9,7 @@ final ThemeData kDarkGalleryTheme = _buildDarkTheme(); TextTheme _buildTextTheme(TextTheme base) { return base.copyWith( - headline6: base.headline6!.copyWith( + headline6: base.headline6.copyWith( fontFamily: 'GoogleSans', ), ); diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/updater.dart b/dev/integration_tests/flutter_gallery/lib/gallery/updater.dart index ce15012726..02d4e22884 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/updater.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/updater.dart @@ -9,11 +9,12 @@ import 'package:url_launcher/url_launcher.dart'; typedef UpdateUrlFetcher = Future Function(); class Updater extends StatefulWidget { - const Updater({ required this.updateUrlFetcher, this.child, Key? key }) - : super(key: key); + const Updater({ @required this.updateUrlFetcher, this.child, Key key }) + : assert(updateUrlFetcher != null), + super(key: key); final UpdateUrlFetcher updateUrlFetcher; - final Widget? child; + final Widget child; @override State createState() => UpdaterState(); @@ -26,25 +27,27 @@ class UpdaterState extends State { _checkForUpdates(); } - static DateTime? _lastUpdateCheck; + static DateTime _lastUpdateCheck; Future _checkForUpdates() async { // Only prompt once a day if (_lastUpdateCheck != null && - DateTime.now().difference(_lastUpdateCheck!) < const Duration(days: 1)) { + DateTime.now().difference(_lastUpdateCheck) < const Duration(days: 1)) { return; // We already checked for updates recently } _lastUpdateCheck = DateTime.now(); final String updateUrl = await widget.updateUrlFetcher(); - final bool? wantsUpdate = await showDialog(context: context, builder: _buildDialog); - if (wantsUpdate != null && wantsUpdate) - launch(updateUrl); + if (updateUrl != null) { + final bool wantsUpdate = await showDialog(context: context, builder: _buildDialog); + if (wantsUpdate != null && wantsUpdate) + launch(updateUrl); + } } Widget _buildDialog(BuildContext context) { final ThemeData theme = Theme.of(context); final TextStyle dialogTextStyle = - theme.textTheme.subtitle1!.copyWith(color: theme.textTheme.caption!.color); + theme.textTheme.subtitle1.copyWith(color: theme.textTheme.caption.color); return AlertDialog( title: const Text('Update Flutter Gallery?'), content: Text('A newer version is available.', style: dialogTextStyle), @@ -66,5 +69,5 @@ class UpdaterState extends State { } @override - Widget build(BuildContext context) => widget.child!; + Widget build(BuildContext context) => widget.child; } diff --git a/dev/integration_tests/flutter_gallery/pubspec.yaml b/dev/integration_tests/flutter_gallery/pubspec.yaml index 0837f508e3..952fd1a786 100644 --- a/dev/integration_tests/flutter_gallery/pubspec.yaml +++ b/dev/integration_tests/flutter_gallery/pubspec.yaml @@ -2,23 +2,20 @@ name: flutter_gallery environment: # The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite. - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=2.2.2 <3.0.0" dependencies: flutter: sdk: flutter collection: 1.15.0-nullsafety.5 device_info: 2.0.0-nullsafety.1 - intl: 0.17.0-nullsafety.2 + intl: 0.16.1 connectivity: 3.0.0-nullsafety.1 string_scanner: 1.1.0-nullsafety.3 url_launcher: 6.0.0-nullsafety.1 cupertino_icons: 1.0.0 video_player: 2.0.0-nullsafety.2 - scoped_model: - git: - url: https://github.com/kevmoo/scoped_model.git - ref: null_safety + scoped_model: 1.1.0 shrine_images: 1.1.2 # Also update dev/benchmarks/complex_layout/pubspec.yaml @@ -27,7 +24,6 @@ dependencies: characters: 1.1.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" connectivity_macos: 0.1.0+7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" connectivity_platform_interface: 2.0.0-nullsafety.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" device_info_platform_interface: 2.0.0-nullsafety.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -64,6 +60,7 @@ dev_dependencies: async: 2.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" cli_util: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" coverage: 0.14.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -276,4 +273,4 @@ flutter: - asset: packages/flutter_gallery_assets/fonts/merriweather/Merriweather-Regular.ttf - asset: packages/flutter_gallery_assets/fonts/merriweather/Merriweather-Light.ttf -# PUBSPEC CHECKSUM: 7977 +# PUBSPEC CHECKSUM: b589 diff --git a/dev/integration_tests/flutter_gallery/test/calculator/logic.dart b/dev/integration_tests/flutter_gallery/test/calculator/logic.dart index d8b07fd833..ebfd0958a7 100644 --- a/dev/integration_tests/flutter_gallery/test/calculator/logic.dart +++ b/dev/integration_tests/flutter_gallery/test/calculator/logic.dart @@ -10,80 +10,80 @@ import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; void main() { test('Test order of operations: 12 + 3 * 4 = 24', () { CalcExpression expression = CalcExpression.empty(); - expression = expression.appendDigit(1)!; - expression = expression.appendDigit(2)!; - expression = expression.appendOperation(Operation.Addition)!; - expression = expression.appendDigit(3)!; - expression = expression.appendOperation(Operation.Multiplication)!; - expression = expression.appendDigit(4)!; - expression = expression.computeResult()!; + expression = expression.appendDigit(1); + expression = expression.appendDigit(2); + expression = expression.appendOperation(Operation.Addition); + expression = expression.appendDigit(3); + expression = expression.appendOperation(Operation.Multiplication); + expression = expression.appendDigit(4); + expression = expression.computeResult(); expect(expression.state, equals(ExpressionState.Result)); expect(expression.toString(), equals('24')); }); test('Test floating point 0.1 + 0.2 = 0.3', () { CalcExpression expression = CalcExpression.empty(); - expression = expression.appendDigit(0)!; - expression = expression.appendPoint()!; - expression = expression.appendDigit(1)!; - expression = expression.appendOperation(Operation.Addition)!; - expression = expression.appendDigit(0)!; - expression = expression.appendPoint()!; - expression = expression.appendDigit(2)!; - expression = expression.computeResult()!; + expression = expression.appendDigit(0); + expression = expression.appendPoint(); + expression = expression.appendDigit(1); + expression = expression.appendOperation(Operation.Addition); + expression = expression.appendDigit(0); + expression = expression.appendPoint(); + expression = expression.appendDigit(2); + expression = expression.computeResult(); expect(expression.state, equals(ExpressionState.Result)); expect(expression.toString(), equals('0.3')); }); test('Test floating point 1.0/10.0 = 0.1', () { CalcExpression expression = CalcExpression.empty(); - expression = expression.appendDigit(1)!; - expression = expression.appendPoint()!; - expression = expression.appendDigit(0)!; - expression = expression.appendOperation(Operation.Division)!; - expression = expression.appendDigit(1)!; - expression = expression.appendDigit(0)!; - expression = expression.appendPoint()!; - expression = expression.appendDigit(0)!; - expression = expression.computeResult()!; + expression = expression.appendDigit(1); + expression = expression.appendPoint(); + expression = expression.appendDigit(0); + expression = expression.appendOperation(Operation.Division); + expression = expression.appendDigit(1); + expression = expression.appendDigit(0); + expression = expression.appendPoint(); + expression = expression.appendDigit(0); + expression = expression.computeResult(); expect(expression.state, equals(ExpressionState.Result)); expect(expression.toString(), equals('0.1')); }); test('Test 1/0 = Infinity', () { CalcExpression expression = CalcExpression.empty(); - expression = expression.appendDigit(1)!; - expression = expression.appendOperation(Operation.Division)!; - expression = expression.appendDigit(0)!; - expression = expression.computeResult()!; + expression = expression.appendDigit(1); + expression = expression.appendOperation(Operation.Division); + expression = expression.appendDigit(0); + expression = expression.computeResult(); expect(expression.state, equals(ExpressionState.Result)); expect(expression.toString(), equals('Infinity')); }); test('Test use result in next calculation: 1 + 1 = 2 + 1 = 3 + 1 = 4', () { CalcExpression expression = CalcExpression.empty(); - expression = expression.appendDigit(1)!; - expression = expression.appendOperation(Operation.Addition)!; - expression = expression.appendDigit(1)!; - expression = expression.computeResult()!; - expression = expression.appendOperation(Operation.Addition)!; - expression = expression.appendDigit(1)!; - expression = expression.computeResult()!; - expression = expression.appendOperation(Operation.Addition)!; - expression = expression.appendDigit(1)!; - expression = expression.computeResult()!; + expression = expression.appendDigit(1); + expression = expression.appendOperation(Operation.Addition); + expression = expression.appendDigit(1); + expression = expression.computeResult(); + expression = expression.appendOperation(Operation.Addition); + expression = expression.appendDigit(1); + expression = expression.computeResult(); + expression = expression.appendOperation(Operation.Addition); + expression = expression.appendDigit(1); + expression = expression.computeResult(); expect(expression.state, equals(ExpressionState.Result)); expect(expression.toString(), equals('4')); }); test('Test minus -3 - -2 = -1', () { CalcExpression expression = CalcExpression.empty(); - expression = expression.appendMinus()!; - expression = expression.appendDigit(3)!; - expression = expression.appendMinus()!; - expression = expression.appendMinus()!; - expression = expression.appendDigit(2)!; - expression = expression.computeResult()!; + expression = expression.appendMinus(); + expression = expression.appendDigit(3); + expression = expression.appendMinus(); + expression = expression.appendMinus(); + expression = expression.appendDigit(2); + expression = expression.computeResult(); expect(expression.state, equals(ExpressionState.Result)); expect(expression.toString(), equals('-1')); }); diff --git a/dev/integration_tests/flutter_gallery/test/demo/cupertino/cupertino_navigation_demo_test.dart b/dev/integration_tests/flutter_gallery/test/demo/cupertino/cupertino_navigation_demo_test.dart index 2202a32a7b..e1698fb9d1 100644 --- a/dev/integration_tests/flutter_gallery/test/demo/cupertino/cupertino_navigation_demo_test.dart +++ b/dev/integration_tests/flutter_gallery/test/demo/cupertino/cupertino_navigation_demo_test.dart @@ -37,7 +37,5 @@ void main() { find.byType(CupertinoNavigationDemo), matchesGoldenFile('cupertino_navigation_demo.screen.2.png'), ); - }, - // TODO(egarciad): https://github.com/flutter/flutter/issues/69994 - skip: true); + }); } diff --git a/dev/integration_tests/flutter_gallery/test/drawer_test.dart b/dev/integration_tests/flutter_gallery/test/drawer_test.dart index 54efbd8179..d45c97501c 100644 --- a/dev/integration_tests/flutter_gallery/test/drawer_test.dart +++ b/dev/integration_tests/flutter_gallery/test/drawer_test.dart @@ -32,8 +32,8 @@ void main() { // Verify theme settings MaterialApp app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp; - expect(app.theme!.brightness, equals(Brightness.light)); - expect(app.darkTheme!.brightness, equals(Brightness.dark)); + expect(app.theme.brightness, equals(Brightness.light)); + expect(app.darkTheme.brightness, equals(Brightness.dark)); // Switch to the dark theme: first menu button, choose 'Dark' await tester.tap(find.byIcon(Icons.arrow_drop_down).first); @@ -63,7 +63,7 @@ void main() { expect(app.themeMode, ThemeMode.system); // Verify density settings - expect(app.theme!.visualDensity, equals(const VisualDensity())); + expect(app.theme.visualDensity, equals(const VisualDensity())); // Popup the density menu: third menu button, choose 'Compact' await tester.tap(find.byIcon(Icons.arrow_drop_down).at(2)); @@ -71,7 +71,7 @@ void main() { await tester.tap(find.text('Compact')); await tester.pumpAndSettle(); app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp; - expect(app.theme!.visualDensity, equals(VisualDensity.compact)); + expect(app.theme.visualDensity, equals(VisualDensity.compact)); await tester.tap(find.byIcon(Icons.arrow_drop_down).at(2)); await tester.pumpAndSettle(); @@ -81,10 +81,10 @@ void main() { )); await tester.pumpAndSettle(); app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp; - expect(app.theme!.visualDensity, equals(const VisualDensity())); + expect(app.theme.visualDensity, equals(const VisualDensity())); // Verify platform settings - expect(app.theme!.platform, equals(TargetPlatform.android)); + expect(app.theme.platform, equals(TargetPlatform.android)); // Popup the platform menu: fourth menu button, choose 'Cupertino' await tester.tap(find.byIcon(Icons.arrow_drop_down).at(3)); @@ -92,7 +92,7 @@ void main() { await tester.tap(find.text('Cupertino').at(1)); await tester.pumpAndSettle(); app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp; - expect(app.theme!.platform, equals(TargetPlatform.iOS)); + expect(app.theme.platform, equals(TargetPlatform.iOS)); // Verify the font scale. final Size origTextSize = tester.getSize(find.text('Text size')); diff --git a/dev/integration_tests/flutter_gallery/test/example_code_parser_test.dart b/dev/integration_tests/flutter_gallery/test/example_code_parser_test.dart index ef4ec9c5b6..0af4796207 100644 --- a/dev/integration_tests/flutter_gallery/test/example_code_parser_test.dart +++ b/dev/integration_tests/flutter_gallery/test/example_code_parser_test.dart @@ -12,13 +12,13 @@ void main() { test('Flutter gallery example code parser test', () async { final TestAssetBundle bundle = TestAssetBundle(); - final String? codeSnippet0 = await getExampleCode('test_0', bundle); + final String codeSnippet0 = await getExampleCode('test_0', bundle); expect(codeSnippet0, 'test 0 0\ntest 0 1'); - final String? codeSnippet1 = await getExampleCode('test_1', bundle); + final String codeSnippet1 = await getExampleCode('test_1', bundle); expect(codeSnippet1, 'test 1 0\ntest 1 1'); - final String? codeSnippet3 = await getExampleCode('test_2_windows_breaks', bundle); + final String codeSnippet3 = await getExampleCode('test_2_windows_breaks', bundle); expect(codeSnippet3, 'windows test 2 0\nwindows test 2 1'); }); } @@ -41,15 +41,13 @@ test 1 1 class TestAssetBundle extends AssetBundle { @override - Future load(String key) async { - return ByteData.sublistView(Uint8List(0)); - } + Future load(String key) async => null; @override Future loadString(String key, { bool cache = true }) async { if (key == 'lib/gallery/example_code.dart') return testCodeFile; - return ''; + return null; } @override diff --git a/dev/integration_tests/flutter_gallery/test/live_smoketest.dart b/dev/integration_tests/flutter_gallery/test/live_smoketest.dart index f7118bc663..a7e5bcfe93 100644 --- a/dev/integration_tests/flutter_gallery/test/live_smoketest.dart +++ b/dev/integration_tests/flutter_gallery/test/live_smoketest.dart @@ -60,11 +60,11 @@ Future main() async { print('Starting app...'); runApp(const GalleryApp(testMode: true)); - final _LiveWidgetController controller = _LiveWidgetController(WidgetsBinding.instance!); + final _LiveWidgetController controller = _LiveWidgetController(WidgetsBinding.instance); for (final GalleryDemoCategory category in kAllGalleryDemoCategories) { print('Tapping "${category.name}" section...'); await controller.tap(find.text(category.name)); - for (final GalleryDemo demo in kGalleryCategoryToDemos[category]!) { + for (final GalleryDemo demo in kGalleryCategoryToDemos[category]) { final Finder demoItem = find.text(demo.title); print('Scrolling to "${demo.title}"...'); await controller.scrollIntoView(demoItem, alignment: 0.5); @@ -110,10 +110,10 @@ class _LiveWidgetController extends LiveWidgetController { bool frameSync = true; /// Waits until at the end of a frame the provided [condition] is [true]. - Future _waitUntilFrame(bool condition(), [Completer? completer]) { + Future _waitUntilFrame(bool condition(), [Completer completer]) { completer ??= Completer(); if (!condition()) { - SchedulerBinding.instance!.addPostFrameCallback((Duration timestamp) { + SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) { _waitUntilFrame(condition, completer); }); } else { @@ -133,11 +133,11 @@ class _LiveWidgetController extends LiveWidgetController { } @override - Future tap(Finder finder, { int? pointer, int buttons = kPrimaryButton }) async { + Future tap(Finder finder, { int pointer, int buttons = kPrimaryButton }) async { await super.tap(await _waitForElement(finder), pointer: pointer, buttons: buttons); } - Future scrollIntoView(Finder finder, {required double alignment}) async { + Future scrollIntoView(Finder finder, {double alignment}) async { final Finder target = await _waitForElement(finder); await Scrollable.ensureVisible(target.evaluate().single, duration: const Duration(milliseconds: 100), alignment: alignment); } diff --git a/dev/integration_tests/flutter_gallery/test/smoke_test.dart b/dev/integration_tests/flutter_gallery/test/smoke_test.dart index 49db18392b..2e01ab928a 100644 --- a/dev/integration_tests/flutter_gallery/test/smoke_test.dart +++ b/dev/integration_tests/flutter_gallery/test/smoke_test.dart @@ -77,9 +77,9 @@ Future smokeDemo(WidgetTester tester, GalleryDemo demo) async { // Verify that the dumps are pretty. final String routeName = demo.routeName; - verifyToStringOutput('debugDumpApp', routeName, WidgetsBinding.instance!.renderViewElement!.toStringDeep()); - verifyToStringOutput('debugDumpRenderTree', routeName, RendererBinding.instance?.renderView.toStringDeep() ?? ''); - verifyToStringOutput('debugDumpLayerTree', routeName, RendererBinding.instance?.renderView.debugLayer?.toStringDeep() ?? ''); + verifyToStringOutput('debugDumpApp', routeName, WidgetsBinding.instance.renderViewElement.toStringDeep()); + verifyToStringOutput('debugDumpRenderTree', routeName, RendererBinding.instance?.renderView?.toStringDeep()); + verifyToStringOutput('debugDumpLayerTree', routeName, RendererBinding.instance?.renderView?.debugLayer?.toStringDeep()); // Scroll the demo around a bit more. await tester.flingFrom(const Offset(400.0, 300.0), const Offset(0.0, 400.0), 1000.0); @@ -161,7 +161,7 @@ Future smokeGallery(WidgetTester tester) async { await Scrollable.ensureVisible(tester.element(find.text(category.name)), alignment: 0.5); await tester.tap(find.text(category.name)); await tester.pumpAndSettle(); - for (final GalleryDemo demo in kGalleryCategoryToDemos[category]!) { + for (final GalleryDemo demo in kGalleryCategoryToDemos[category]) { await Scrollable.ensureVisible(tester.element(find.text(demo.title)), alignment: 0.0); await smokeDemo(tester, demo); tester.binding.debugAssertNoTransientCallbacks('A transient callback was still active after running $demo'); @@ -179,8 +179,8 @@ void main() { testWidgets('Flutter Gallery app smoke test', smokeGallery); testWidgets('Flutter Gallery app smoke test with semantics', (WidgetTester tester) async { - RendererBinding.instance!.setSemanticsEnabled(true); + RendererBinding.instance.setSemanticsEnabled(true); await smokeGallery(tester); - RendererBinding.instance!.setSemanticsEnabled(false); + RendererBinding.instance.setSemanticsEnabled(false); }); } diff --git a/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_test.dart b/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_test.dart index f009c17e38..9e6c1e21e2 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_test.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. // @dart = 2.9 - import 'package:flutter_driver/flutter_driver.dart'; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; diff --git a/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_web_test.dart b/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_web_test.dart index 70234e7eec..528f334501 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_web_test.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_web_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. // @dart = 2.9 - import 'package:flutter_driver/flutter_driver.dart'; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; diff --git a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf.dart b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf.dart index 09f8a3cd2f..ae88a38d95 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf.dart @@ -47,7 +47,7 @@ class _MessageHandler { } void main() { - enableFlutterDriverExtension(handler: _MessageHandler().call); + enableFlutterDriverExtension(handler: _MessageHandler()); // As in lib/main.dart: overriding https://github.com/flutter/flutter/issues/13736 // for better visual effect at the cost of performance. runApp(const GalleryApp(testMode: true)); diff --git a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e_test.dart b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e_test.dart index f0a9277b87..1d2eeecd1c 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e_test.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. // @dart = 2.9 - import 'package:integration_test/integration_test_driver.dart' as driver; Future main() => driver.integrationDriver( diff --git a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_hybrid_test.dart b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_hybrid_test.dart index 8b758d838b..572a03b487 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_hybrid_test.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_hybrid_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. // @dart = 2.9 - import 'transitions_perf_test.dart' as transitions_perf_test; void main([List args = const []]) => transitions_perf_test.main( diff --git a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_test.dart b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_test.dart index 0a89c921c5..ea97a6f01a 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_test.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. // @dart = 2.9 - import 'dart:convert' show JsonEncoder, json; import 'package:file/file.dart'; diff --git a/dev/tools/pubspec.yaml b/dev/tools/pubspec.yaml index bee0b8a0da..d1df30ab6e 100644 --- a/dev/tools/pubspec.yaml +++ b/dev/tools/pubspec.yaml @@ -11,13 +11,12 @@ dependencies: flutter_tools: path: '../../packages/flutter_tools' http: 0.12.2 - intl: 0.17.0-nullsafety.2 + intl: 0.16.1 meta: 1.3.0-nullsafety.6 path: 1.8.0-nullsafety.3 process: 4.0.0-nullsafety.4 charcode: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.15.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -71,4 +70,4 @@ dev_dependencies: webkit_inspection_protocol: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" -# PUBSPEC CHECKSUM: 27b7 +# PUBSPEC CHECKSUM: 52ad diff --git a/packages/_flutter_web_build_script/pubspec.yaml b/packages/_flutter_web_build_script/pubspec.yaml index bfdec7e849..5c4fc3fdc4 100644 --- a/packages/_flutter_web_build_script/pubspec.yaml +++ b/packages/_flutter_web_build_script/pubspec.yaml @@ -66,7 +66,7 @@ dependencies: protobuf: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pubspec_parse: 0.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.1.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" scratch_space: 0.0.4+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf: 0.7.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -93,4 +93,4 @@ dartdoc: # Exclude this package from the hosted API docs. nodoc: true -# PUBSPEC CHECKSUM: 3ea3 +# PUBSPEC CHECKSUM: a6fe diff --git a/packages/flutter_driver/pubspec.yaml b/packages/flutter_driver/pubspec.yaml index 6396e5aa98..ca62cf3fd6 100644 --- a/packages/flutter_driver/pubspec.yaml +++ b/packages/flutter_driver/pubspec.yaml @@ -47,7 +47,7 @@ dependencies: web_socket_channel: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: - quiver: 2.1.5 + quiver: 2.1.4+1 test: 1.16.0-nullsafety.9 _fe_analyzer_shared: 7.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -81,4 +81,4 @@ dev_dependencies: webkit_inspection_protocol: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" -# PUBSPEC CHECKSUM: 96df +# PUBSPEC CHECKSUM: 153b diff --git a/packages/flutter_localizations/pubspec.yaml b/packages/flutter_localizations/pubspec.yaml index 38891cb1ba..a6d39eacb8 100644 --- a/packages/flutter_localizations/pubspec.yaml +++ b/packages/flutter_localizations/pubspec.yaml @@ -9,10 +9,9 @@ dependencies: flutter: sdk: flutter - intl: 0.17.0-nullsafety.2 + intl: 0.16.1 characters: 1.1.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.15.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.3.0-nullsafety.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.8.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -27,6 +26,7 @@ dev_dependencies: async: 2.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" fake_async: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" matcher: 0.12.10-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.8.0-nullsafety.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -36,4 +36,4 @@ dev_dependencies: term_glyph: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_api: 0.2.19-nullsafety.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" -# PUBSPEC CHECKSUM: 82fa +# PUBSPEC CHECKSUM: db22 diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart index c385a9678e..a343c965a9 100644 --- a/packages/flutter_tools/lib/src/commands/update_packages.dart +++ b/packages/flutter_tools/lib/src/commands/update_packages.dart @@ -36,7 +36,6 @@ const Map _kManuallyPinnedDependencies = { 'charcode': '1.2.0-nullsafety.3', 'clock': '1.1.0-nullsafety.3', 'collection': '1.15.0-nullsafety.5', - 'intl': '0.17.0-nullsafety.2', 'fake_async': '1.2.0-nullsafety.3', 'js': '0.6.3-nullsafety.3', 'matcher': '0.12.10-nullsafety.3', diff --git a/packages/flutter_tools/lib/src/localizations/gen_l10n_templates.dart b/packages/flutter_tools/lib/src/localizations/gen_l10n_templates.dart index 239b5fd3b8..0a6cfc7660 100644 --- a/packages/flutter_tools/lib/src/localizations/gen_l10n_templates.dart +++ b/packages/flutter_tools/lib/src/localizations/gen_l10n_templates.dart @@ -47,7 +47,7 @@ import 'package:intl/intl.dart' as intl; /// # Internationalization support. /// flutter_localizations: /// sdk: flutter -/// intl: 0.17.0-nullsafety.2 +/// intl: 0.16.1 /// /// # rest of dependencies /// ``` diff --git a/packages/flutter_tools/pubspec.yaml b/packages/flutter_tools/pubspec.yaml index c0ccca407e..e538fed92a 100644 --- a/packages/flutter_tools/pubspec.yaml +++ b/packages/flutter_tools/pubspec.yaml @@ -20,7 +20,7 @@ dependencies: flutter_template_images: 1.0.1 html: 0.14.0+4 http: 0.12.2 - intl: 0.17.0-nullsafety.2 + intl: 0.16.1 meta: 1.3.0-nullsafety.6 multicast_dns: 0.2.2 mustache_template: 1.0.0+1 @@ -49,7 +49,7 @@ dependencies: mime: 0.9.7 logging: 0.11.4 http_multi_server: 2.2.0 - devtools_server: 0.9.4 + devtools_server: 0.9.3+4 convert: 2.1.1 async: 2.5.0-nullsafety.3 @@ -71,8 +71,8 @@ dependencies: cli_util: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" csslib: 0.16.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - devtools: 0.9.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - devtools_shared: 0.9.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + devtools: 0.9.3+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + devtools_shared: 0.9.3+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" fixnum: 0.10.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -85,7 +85,7 @@ dependencies: pedantic: 1.10.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" petitparser: 3.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" platform: 3.0.0-nullsafety.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.1.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_proxy: 0.1.0+7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 2.1.0-nullsafety.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.10-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -113,4 +113,4 @@ dartdoc: # Exclude this package from the hosted API docs. nodoc: true -# PUBSPEC CHECKSUM: 359a +# PUBSPEC CHECKSUM: 7f38 diff --git a/packages/flutter_tools/test/integration.shard/test_data/gen_l10n_project.dart b/packages/flutter_tools/test/integration.shard/test_data/gen_l10n_project.dart index eed76cdb56..1b5f01b93a 100644 --- a/packages/flutter_tools/test/integration.shard/test_data/gen_l10n_project.dart +++ b/packages/flutter_tools/test/integration.shard/test_data/gen_l10n_project.dart @@ -42,7 +42,7 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter - intl: 0.17.0-nullsafety.2 + intl: 0.16.1 '''; @override