Unverified Commit 4f2e7987 authored by Abhishek Ghaskata's avatar Abhishek Ghaskata Committed by GitHub

Migrate external_ui to null safety (#80640)

parent 4825c639
......@@ -15,7 +15,7 @@ void main() {
}
class MyApp extends StatefulWidget {
const MyApp({Key key}) : super(key: key);
const MyApp({Key? key}) : super(key: key);
@override
State createState() => MyAppState();
......@@ -27,17 +27,17 @@ enum FrameState { initial, slow, afterSlow, fast, afterFast }
class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
int _widgetBuilds = 0;
FrameState _state;
FrameState _state = FrameState.initial;
String _summary = '';
IconData _icon;
double _flutterFrameRate;
IconData? _icon;
double _flutterFrameRate = 0;
Future<void> _summarizeStats() async {
final double framesProduced = await channel.invokeMethod('getProducedFrameRate');
final double framesConsumed = await channel.invokeMethod('getConsumedFrameRate');
final double? framesProduced = await channel.invokeMethod('getProducedFrameRate');
final double? framesConsumed = await channel.invokeMethod('getConsumedFrameRate');
_summary = '''
Produced: ${framesProduced.toStringAsFixed(1)}fps
Consumed: ${framesConsumed.toStringAsFixed(1)}fps
Produced: ${framesProduced?.toStringAsFixed(1)}fps
Consumed: ${framesConsumed?.toStringAsFixed(1)}fps
Widget builds: $_widgetBuilds''';
}
......@@ -96,15 +96,15 @@ Widget builds: $_widgetBuilds''';
debugPrint('Awaiting calm (3 second pause)...');
await Future<void>.delayed(const Duration(milliseconds: 3000));
debugPrint('Calibrating...');
DateTime startTime;
late DateTime startTime;
int tickCount = 0;
Ticker ticker;
Ticker? ticker;
ticker = createTicker((Duration time) {
tickCount += 1;
if (tickCount == calibrationTickCount) { // about 10 seconds
final Duration elapsed = DateTime.now().difference(startTime);
ticker.stop();
ticker.dispose();
ticker?.stop();
ticker?.dispose();
setState(() {
_flutterFrameRate = tickCount * 1000 / elapsed.inMilliseconds;
debugPrint('Calibrated: frame rate ${_flutterFrameRate.toStringAsFixed(1)}fps.');
......
......@@ -2,7 +2,7 @@ name: external_ui
description: A test of Flutter integrating external UIs.
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
......
......@@ -13,7 +13,7 @@ const Duration samplingTime = Duration(seconds: 8);
Future<void> main() async {
group('texture suite', () {
FlutterDriver driver;
late FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect();
......@@ -32,9 +32,9 @@ Future<void> main() async {
await driver.waitFor(fab);
final String calibrationResult = await driver.getText(summary);
final Match matchCalibration = calibrationRegExp.matchAsPrefix(calibrationResult);
final Match? matchCalibration = calibrationRegExp.matchAsPrefix(calibrationResult);
expect(matchCalibration, isNotNull);
final double flutterFrameRate = double.parse(matchCalibration.group(1));
final double flutterFrameRate = double.parse(matchCalibration?.group(1) ?? '0');
// Texture frame stats at 0.5x Flutter frame rate
await driver.tap(fab);
......@@ -42,11 +42,11 @@ Future<void> main() async {
await driver.tap(fab);
final String statsSlow = await driver.getText(summary);
final Match matchSlow = statsRegExp.matchAsPrefix(statsSlow);
final Match matchSlow = statsRegExp.matchAsPrefix(statsSlow)!;
expect(matchSlow, isNotNull);
expect(double.parse(matchSlow.group(1)), closeTo(flutterFrameRate / 2.0, 5.0));
expect(double.parse(matchSlow.group(2)), closeTo(flutterFrameRate / 2.0, 5.0));
expect(int.parse(matchSlow.group(3)), 1);
expect(double.parse(matchSlow.group(1)!), closeTo(flutterFrameRate / 2.0, 5.0));
expect(double.parse(matchSlow.group(2)!), closeTo(flutterFrameRate / 2.0, 5.0));
expect(int.parse(matchSlow.group(3)!), 1);
// Texture frame stats at 2.0x Flutter frame rate
await driver.tap(fab);
......@@ -54,15 +54,15 @@ Future<void> main() async {
await driver.tap(fab);
final String statsFast = await driver.getText(summary);
final Match matchFast = statsRegExp.matchAsPrefix(statsFast);
final Match matchFast = statsRegExp.matchAsPrefix(statsFast)!;
expect(matchFast, isNotNull);
expect(double.parse(matchFast.group(1)), closeTo(flutterFrameRate * 2.0, 5.0));
expect(double.parse(matchFast.group(2)), closeTo(flutterFrameRate, 10.0));
expect(int.parse(matchFast.group(3)), 1);
expect(double.parse(matchFast.group(1)!), closeTo(flutterFrameRate * 2.0, 5.0));
expect(double.parse(matchFast.group(2)!), closeTo(flutterFrameRate, 10.0));
expect(int.parse(matchFast.group(3)!), 1);
});
tearDownAll(() async {
driver?.close();
driver.close();
});
});
}
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