Unverified Commit 06f051b2 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Migrate remaining examples to null-safety (#74857)

parent c505ee79
......@@ -666,7 +666,7 @@ Future<void> _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: <String>[path.join('test', 'src', 'real_tests')]);
......
......@@ -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<MyHomePage> {
static const String _channel = 'increment';
static const String _pong = 'pong';
static const String _emptyMessage = '';
static const BasicMessageChannel<String> platform =
BasicMessageChannel<String>(_channel, StringCodec());
static const BasicMessageChannel<String?> platform =
BasicMessageChannel<String?>(_channel, StringCodec());
int _counter = 0;
......@@ -44,7 +43,7 @@ class _MyHomePageState extends State<MyHomePage> {
platform.setMessageHandler(_handlePlatformIncrement);
}
Future<String> _handlePlatformIncrement(String message) async {
Future<String> _handlePlatformIncrement(String? message) async {
setState(() {
_counter++;
});
......
......@@ -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:
......
......@@ -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<MyHomePage> 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<MyHomePage> with TickerProviderStateMixin {
@override
Widget build(BuildContext context) {
final List<AnimationController> controllers = List<AnimationController>.filled(IMAGES, null);
for (int i = 0; i < IMAGES; i++) {
controllers[i] = AnimationController(
duration: const Duration(milliseconds: 3600),
vsync: this,
)..repeat();
}
final List<Completer<bool>> completers = List<Completer<bool>>.filled(IMAGES, null);
for (int i = 0; i < IMAGES; i++) {
completers[i] = Completer<bool>();
}
final List<AnimationController> controllers = <AnimationController>[
for (int i = 0; i < IMAGES; i++)
AnimationController(
duration: const Duration(milliseconds: 3600),
vsync: this,
)..repeat(),
];
final List<Completer<bool>> completers = <Completer<bool>>[
for (int i = 0; i < IMAGES; i++)
Completer<bool>(),
];
final List<Future<bool>> futures = completers.map(
(Completer<bool> completer) => completer.future).toList();
final DateTime started = DateTime.now();
......
......@@ -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:
......
......@@ -24,7 +24,7 @@ class _PlatformChannelState extends State<PlatformChannel> {
Future<void> _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<PlatformChannel> {
eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError);
}
void _onEvent(Object event) {
void _onEvent(Object? event) {
setState(() {
_chargingStatus =
"Battery status: ${event == 'charging' ? '' : 'dis'}charging.";
......
name: platform_channel
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: ">=2.12.0-0 <3.0.0"
dependencies:
flutter:
......
......@@ -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;
......
......@@ -24,7 +24,7 @@ class _PlatformChannelState extends State<PlatformChannel> {
Future<void> _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<PlatformChannel> {
eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError);
}
void _onEvent(Object event) {
void _onEvent(Object? event) {
setState(() {
_chargingStatus =
"Battery status: ${event == 'charging' ? '' : 'dis'}charging.";
......
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:
......
......@@ -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;
......
......@@ -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<MyHomePage> {
}
Future<void> _launchPlatformCount() async {
final int platformCounter =
final int? platformCounter =
await _methodChannel.invokeMethod('switchView', _counter);
setState(() {
_counter = platformCounter;
_counter = platformCounter!;
});
}
......
name: platform_view
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: ">=2.12.0-0 <3.0.0"
dependencies:
flutter:
......
name: splash
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: ">=2.12.0-0 <3.0.0"
dependencies:
flutter:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment