diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 19ddeb3d45..7436c11000 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -666,7 +666,7 @@ Future _runFrameworkTests() async { await _runFlutterTest(path.join(flutterRoot, 'dev', 'integration_tests', 'android_semantics_testing')); await _runFlutterTest(path.join(flutterRoot, 'dev', 'manual_tests')); await _runFlutterTest(path.join(flutterRoot, 'dev', 'tools', 'vitool')); - await _runFlutterTest(path.join(flutterRoot, 'examples', 'hello_world')); + await _runFlutterTest(path.join(flutterRoot, 'examples', 'hello_world'), options: soundNullSafetyOptions); await _runFlutterTest(path.join(flutterRoot, 'examples', 'layers'), options: soundNullSafetyOptions); await _runFlutterTest(path.join(flutterRoot, 'dev', 'benchmarks', 'test_apps', 'stocks')); await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_driver'), tests: [path.join('test', 'src', 'real_tests')]); diff --git a/examples/flutter_view/lib/main.dart b/examples/flutter_view/lib/main.dart index a743cc7c4f..e6ece4d677 100644 --- a/examples/flutter_view/lib/main.dart +++ b/examples/flutter_view/lib/main.dart @@ -11,7 +11,6 @@ void main() { } class FlutterView extends StatelessWidget { - @override Widget build(BuildContext context) { return MaterialApp( @@ -33,8 +32,8 @@ class _MyHomePageState extends State { static const String _channel = 'increment'; static const String _pong = 'pong'; static const String _emptyMessage = ''; - static const BasicMessageChannel platform = - BasicMessageChannel(_channel, StringCodec()); + static const BasicMessageChannel platform = + BasicMessageChannel(_channel, StringCodec()); int _counter = 0; @@ -44,7 +43,7 @@ class _MyHomePageState extends State { platform.setMessageHandler(_handlePlatformIncrement); } - Future _handlePlatformIncrement(String message) async { + Future _handlePlatformIncrement(String? message) async { setState(() { _counter++; }); diff --git a/examples/flutter_view/pubspec.yaml b/examples/flutter_view/pubspec.yaml index e1d845fa51..4e9024851f 100644 --- a/examples/flutter_view/pubspec.yaml +++ b/examples/flutter_view/pubspec.yaml @@ -2,7 +2,7 @@ name: flutter_view description: A new flutter project. environment: - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" dependencies: flutter: diff --git a/examples/image_list/lib/main.dart b/examples/image_list/lib/main.dart index 8be4ee3544..e63f82c3e5 100644 --- a/examples/image_list/lib/main.dart +++ b/examples/image_list/lib/main.dart @@ -81,7 +81,7 @@ mhBKvYQc85gja0s1c+1VXA== class MyHttpOverrides extends HttpOverrides { @override - HttpClient createHttpClient(SecurityContext context) { + HttpClient createHttpClient(SecurityContext? context) { return super.createHttpClient( (context ?? SecurityContext())..setTrustedCertificatesBytes(certificate.codeUnits) ); @@ -141,7 +141,7 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatefulWidget { - const MyHomePage({Key key, this.title, this.port}) : super(key: key); + const MyHomePage({Key? key, required this.title, required this.port}) : super(key: key); final String title; final int port; @@ -164,7 +164,7 @@ class _MyHomePageState extends State with TickerProviderStateMixin { frameBuilder: ( BuildContext context, Widget child, - int frame, + int? frame, bool wasSynchronouslyLoaded, ) { if (frame == 0 && !completer.isCompleted) { @@ -177,17 +177,17 @@ class _MyHomePageState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { - final List controllers = List.filled(IMAGES, null); - for (int i = 0; i < IMAGES; i++) { - controllers[i] = AnimationController( - duration: const Duration(milliseconds: 3600), - vsync: this, - )..repeat(); - } - final List> completers = List>.filled(IMAGES, null); - for (int i = 0; i < IMAGES; i++) { - completers[i] = Completer(); - } + final List controllers = [ + for (int i = 0; i < IMAGES; i++) + AnimationController( + duration: const Duration(milliseconds: 3600), + vsync: this, + )..repeat(), + ]; + final List> completers = >[ + for (int i = 0; i < IMAGES; i++) + Completer(), + ]; final List> futures = completers.map( (Completer completer) => completer.future).toList(); final DateTime started = DateTime.now(); diff --git a/examples/image_list/pubspec.yaml b/examples/image_list/pubspec.yaml index 81acc95843..ca2ccae429 100644 --- a/examples/image_list/pubspec.yaml +++ b/examples/image_list/pubspec.yaml @@ -4,7 +4,7 @@ description: Simple Flutter project used for benchmarking image loading over net version: 1.0.0+1 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" dependencies: flutter: diff --git a/examples/platform_channel/lib/main.dart b/examples/platform_channel/lib/main.dart index 6ea0581409..58a5eacb8d 100644 --- a/examples/platform_channel/lib/main.dart +++ b/examples/platform_channel/lib/main.dart @@ -24,7 +24,7 @@ class _PlatformChannelState extends State { Future _getBatteryLevel() async { String batteryLevel; try { - final int result = await methodChannel.invokeMethod('getBatteryLevel'); + final int? result = await methodChannel.invokeMethod('getBatteryLevel'); batteryLevel = 'Battery level: $result%.'; } on PlatformException { batteryLevel = 'Failed to get battery level.'; @@ -40,7 +40,7 @@ class _PlatformChannelState extends State { eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError); } - void _onEvent(Object event) { + void _onEvent(Object? event) { setState(() { _chargingStatus = "Battery status: ${event == 'charging' ? '' : 'dis'}charging."; diff --git a/examples/platform_channel/pubspec.yaml b/examples/platform_channel/pubspec.yaml index 4fa7711c8f..dd2a22b11a 100644 --- a/examples/platform_channel/pubspec.yaml +++ b/examples/platform_channel/pubspec.yaml @@ -1,7 +1,7 @@ name: platform_channel environment: - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" dependencies: flutter: diff --git a/examples/platform_channel/test_driver/button_tap_test.dart b/examples/platform_channel/test_driver/button_tap_test.dart index 79bb73c584..e8c200e0f1 100644 --- a/examples/platform_channel/test_driver/button_tap_test.dart +++ b/examples/platform_channel/test_driver/button_tap_test.dart @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(goderbauer): migrate this file to null-safety when flutter_driver is null-safe. +// @dart = 2.9 + import 'package:flutter_driver/flutter_driver.dart'; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; diff --git a/examples/platform_channel_swift/lib/main.dart b/examples/platform_channel_swift/lib/main.dart index 6ea0581409..58a5eacb8d 100644 --- a/examples/platform_channel_swift/lib/main.dart +++ b/examples/platform_channel_swift/lib/main.dart @@ -24,7 +24,7 @@ class _PlatformChannelState extends State { Future _getBatteryLevel() async { String batteryLevel; try { - final int result = await methodChannel.invokeMethod('getBatteryLevel'); + final int? result = await methodChannel.invokeMethod('getBatteryLevel'); batteryLevel = 'Battery level: $result%.'; } on PlatformException { batteryLevel = 'Failed to get battery level.'; @@ -40,7 +40,7 @@ class _PlatformChannelState extends State { eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError); } - void _onEvent(Object event) { + void _onEvent(Object? event) { setState(() { _chargingStatus = "Battery status: ${event == 'charging' ? '' : 'dis'}charging."; diff --git a/examples/platform_channel_swift/pubspec.yaml b/examples/platform_channel_swift/pubspec.yaml index 77bbcebab9..182d4392b4 100644 --- a/examples/platform_channel_swift/pubspec.yaml +++ b/examples/platform_channel_swift/pubspec.yaml @@ -1,7 +1,7 @@ name: platform_channel_swift environment: - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" dependencies: flutter: diff --git a/examples/platform_channel_swift/test_driver/button_tap_test.dart b/examples/platform_channel_swift/test_driver/button_tap_test.dart index 79bb73c584..e8c200e0f1 100644 --- a/examples/platform_channel_swift/test_driver/button_tap_test.dart +++ b/examples/platform_channel_swift/test_driver/button_tap_test.dart @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(goderbauer): migrate this file to null-safety when flutter_driver is null-safe. +// @dart = 2.9 + import 'package:flutter_driver/flutter_driver.dart'; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; diff --git a/examples/platform_view/lib/main.dart b/examples/platform_view/lib/main.dart index 7d4ff73dc4..e2818b5c51 100644 --- a/examples/platform_view/lib/main.dart +++ b/examples/platform_view/lib/main.dart @@ -25,7 +25,7 @@ class PlatformView extends StatelessWidget { } class MyHomePage extends StatefulWidget { - const MyHomePage({Key key, this.title}) : super(key: key); + const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @@ -46,10 +46,10 @@ class _MyHomePageState extends State { } Future _launchPlatformCount() async { - final int platformCounter = + final int? platformCounter = await _methodChannel.invokeMethod('switchView', _counter); setState(() { - _counter = platformCounter; + _counter = platformCounter!; }); } diff --git a/examples/platform_view/pubspec.yaml b/examples/platform_view/pubspec.yaml index ba40c07038..b16ff30d69 100644 --- a/examples/platform_view/pubspec.yaml +++ b/examples/platform_view/pubspec.yaml @@ -1,7 +1,7 @@ name: platform_view environment: - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" dependencies: flutter: diff --git a/examples/splash/pubspec.yaml b/examples/splash/pubspec.yaml index 2617f4f201..060326c964 100644 --- a/examples/splash/pubspec.yaml +++ b/examples/splash/pubspec.yaml @@ -1,7 +1,7 @@ name: splash environment: - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" dependencies: flutter: