Unverified Commit f7ee4402 authored by Darren Austin's avatar Darren Austin Committed by GitHub

Migrate yet even more widget framework tests to null safety. (#67941)

Migrate yet even more widget framework tests to null safety.
parent f5608f2b
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/widgets.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
@TestOn('chrome')
import 'dart:async';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/widgets.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
......@@ -12,11 +10,11 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test('IconDataDiagnosticsProperty includes valueProperties in JSON', () {
IconDataProperty property = IconDataProperty('foo', const IconData(101010));
final Map<String, Object> valueProperties = property.toJsonMap(const DiagnosticsSerializationDelegate())['valueProperties'] as Map<String, Object>;
final Map<String, Object> valueProperties = property.toJsonMap(const DiagnosticsSerializationDelegate())['valueProperties']! as Map<String, Object>;
expect(valueProperties['codePoint'], 101010);
property = IconDataProperty('foo', null);
final Map<String, Object> json = property.toJsonMap(const DiagnosticsSerializationDelegate());
final Map<String, Object?> json = property.toJsonMap(const DiagnosticsSerializationDelegate());
expect(json.containsKey('valueProperties'), isFalse);
});
}
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
......@@ -25,7 +23,7 @@ void main() {
),
);
final RichText text = tester.widget(find.byType(RichText));
expect(text.text.style.color, const Color(0xFF666666).withOpacity(0.5));
expect(text.text.style!.color, const Color(0xFF666666).withOpacity(0.5));
});
testWidgets('Icon sizing - no theme, default size', (WidgetTester tester) async {
......@@ -125,7 +123,7 @@ void main() {
);
final RichText richText = tester.firstWidget(find.byType(RichText));
expect(richText.text.style.fontFamily, equals('Roboto'));
expect(richText.text.style!.fontFamily, equals('Roboto'));
});
testWidgets('Icon with semantic label', (WidgetTester tester) async {
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:typed_data';
import 'dart:ui';
......@@ -78,8 +76,7 @@ void main() {
await pumpWithSigma(5.0);
final RenderObject renderObject = tester.firstRenderObject(find.byType(ImageFiltered));
final ImageFilterLayer originalLayer = renderObject.debugLayer as ImageFilterLayer;
expect(originalLayer, isNotNull);
final ImageFilterLayer originalLayer = renderObject.debugLayer! as ImageFilterLayer;
// Change blur sigma to force a repaint.
await pumpWithSigma(10.0);
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:async';
import 'dart:io';
......@@ -25,7 +23,7 @@ void main() {
expect(MockHttpHeaders.headers['flutter'], <String>['flutter']);
}, createHttpClient: (SecurityContext _) {
}, createHttpClient: (SecurityContext? _) {
return client;
});
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/57187
......@@ -62,7 +60,7 @@ class MockHttpClientResponse extends Fake implements HttpClientResponse {
HttpClientResponseCompressionState get compressionState => HttpClientResponseCompressionState.decompressed;
@override
StreamSubscription<List<int>> listen(void Function(List<int> event) onData, {Function onError, void Function() onDone, bool cancelOnError}) {
StreamSubscription<List<int>> listen(void Function(List<int> event)? onData, {Function? onError, void Function()? onDone, bool? cancelOnError}) {
return Stream<List<int>>.fromIterable(<List<int>>[kTransparentImage]).listen(
onData,
onDone: onDone,
......@@ -78,6 +76,6 @@ class MockHttpHeaders extends Fake implements HttpHeaders {
@override
void add(String key, Object value, { bool preserveHeaderCase = false }) {
headers[key] ??= <String>[];
headers[key].add(value.toString());
headers[key]!.add(value.toString());
}
}
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -12,7 +10,7 @@ import '../painting/mocks_for_image_cache.dart';
void main() {
ImageProvider _image;
late ImageProvider _image;
setUpAll(() async {
_image = TestImageProvider(
......@@ -45,8 +43,7 @@ void main() {
);
final Image image = tester.widget(find.byType(Image));
expect(image, isNotNull);
expect(image.color.alpha, equals(128));
expect(image.color!.alpha, equals(128));
});
testWidgets('ImageIcon sizing - no theme, explicit size', (WidgetTester tester) async {
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
@TestOn('!chrome') // asset bundle behaves differently.
import 'dart:typed_data';
import 'dart:ui' as ui show Image;
......@@ -43,7 +41,7 @@ class TestAssetBundle extends CachingAssetBundle {
@override
Future<ByteData> load(String key) {
ByteData data;
late ByteData data;
switch (key) {
case 'assets/image.png':
data = TestByteData(1.0);
......@@ -71,7 +69,7 @@ class TestAssetBundle extends CachingAssetBundle {
Future<String> loadString(String key, { bool cache = true }) {
if (key == 'AssetManifest.json')
return SynchronousFuture<String>(manifest);
return SynchronousFuture<String>(null);
return SynchronousFuture<String>('');
}
@override
......@@ -91,21 +89,20 @@ class TestAssetImage extends AssetImage {
@override
ImageStreamCompleter load(AssetBundleImageKey key, DecoderCallback decode) {
ImageInfo imageInfo;
late ImageInfo imageInfo;
key.bundle.load(key.name).then<void>((ByteData data) {
final TestByteData testData = data as TestByteData;
final ui.Image image = images[testData.scale];
final ui.Image image = images[testData.scale]!;
assert(image != null, 'Expected ${testData.scale} to have a key in $images');
imageInfo = ImageInfo(image: image, scale: key.scale);
});
assert(imageInfo != null);
return FakeImageStreamCompleter(
SynchronousFuture<ImageInfo>(imageInfo)
);
}
}
Widget buildImageAtRatio(String imageName, Key key, double ratio, bool inferSize, Map<double, ui.Image> images, [ AssetBundle bundle ]) {
Widget buildImageAtRatio(String imageName, Key key, double ratio, bool inferSize, Map<double, ui.Image> images, [ AssetBundle? bundle ]) {
const double windowSize = 500.0; // 500 logical pixels
const double imageSize = 200.0; // 200 logical pixels
......@@ -313,12 +310,12 @@ void main() {
await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false, images, bundle));
expect(getRenderImage(tester, key).size, const Size(200.0, 200.0));
// Verify we got the 10x scaled image, since the TestByteData said it should be 10x.
expect(getRenderImage(tester, key).image.height, 480);
expect(getRenderImage(tester, key).image!.height, 480);
key = GlobalKey();
await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, true, images, bundle));
expect(getRenderImage(tester, key).size, const Size(480.0, 480.0));
// Verify we got the 10x scaled image, since the TestByteData said it should be 10x.
expect(getRenderImage(tester, key).image.height, 480);
expect(getRenderImage(tester, key).image!.height, 480);
});
testWidgets('Image cache resize upscale display 5', (WidgetTester tester) async {
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui show Image;
import 'package:flutter/foundation.dart';
......@@ -31,7 +29,7 @@ class TestImageProvider extends ImageProvider<TestImageProvider> {
}
void main() {
ui.Image testImage;
late ui.Image testImage;
setUpAll(() async {
testImage = await createTestImage(width: 16, height: 9);
});
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
......@@ -20,7 +18,7 @@ const Duration animationDuration = Duration(milliseconds:1000);
const Duration additionalDelay = Duration(milliseconds:1);
void main() {
MockOnEndFunction mockOnEndFunction;
late MockOnEndFunction mockOnEndFunction;
const Key switchKey = Key('switchKey');
setUp(() {
......@@ -355,7 +353,7 @@ void main() {
});
}
Widget wrap({Widget child}) {
Widget wrap({required Widget child}) {
return Directionality(
textDirection: TextDirection.ltr,
child: Material(
......@@ -366,16 +364,13 @@ Widget wrap({Widget child}) {
class TestAnimatedWidget extends StatefulWidget {
const TestAnimatedWidget({
Key key,
Key? key,
this.callback,
this.switchKey,
this.state,
required this.switchKey,
required this.state,
}) : super(key: key);
@required
final VoidCallback callback;
@required
final VoidCallback? callback;
final Key switchKey;
@required
final State<StatefulWidget> state;
@override
......@@ -408,7 +403,6 @@ abstract class _TestAnimatedWidgetState extends State<TestAnimatedWidget> {
}
}
class _TestAnimatedContainerWidgetState extends _TestAnimatedWidgetState {
@override
Widget getAnimatedWidget() {
......@@ -553,7 +547,7 @@ class _TestTweenAnimationBuilderWidgetState extends _TestAnimatedWidgetState {
tween: Tween<double>(begin: 1, end: 2),
duration: duration,
onEnd: widget.callback,
builder: (BuildContext context, double size, Widget child) {
builder: (BuildContext context, double? size, Widget? child) {
return Container(
child: child,
width: size,
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/rendering.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
......@@ -13,7 +11,7 @@ const Size _kTestViewSize = Size(800.0, 600.0);
class OffscreenRenderView extends RenderView {
OffscreenRenderView() : super(
configuration: const ViewConfiguration(size: _kTestViewSize),
window: WidgetsBinding.instance.window,
window: WidgetsBinding.instance!.window,
);
@override
......@@ -32,7 +30,7 @@ class OffscreenWidgetTree {
final RenderView renderView = OffscreenRenderView();
final BuildOwner buildOwner = BuildOwner();
final PipelineOwner pipelineOwner = PipelineOwner();
RenderObjectToWidgetElement<RenderBox> root;
RenderObjectToWidgetElement<RenderBox>? root;
void pumpWidget(Widget app) {
root = RenderObjectToWidgetAdapter<RenderBox>(
......@@ -44,7 +42,7 @@ class OffscreenWidgetTree {
}
void pumpFrame() {
buildOwner.buildScope(root);
buildOwner.buildScope(root!);
pipelineOwner.flushLayout();
pipelineOwner.flushCompositingBits();
pipelineOwner.flushPaint();
......@@ -60,18 +58,18 @@ class Counter {
}
class Trigger {
VoidCallback callback;
VoidCallback? callback;
void fire() {
if (callback != null)
callback();
callback!();
}
}
class TriggerableWidget extends StatefulWidget {
const TriggerableWidget({
Key key,
this.trigger,
this.counter,
Key? key,
required this.trigger,
required this.counter,
}) : super(key: key);
final Trigger trigger;
......@@ -110,8 +108,8 @@ class TriggerableState extends State<TriggerableWidget> {
class TestFocusable extends StatefulWidget {
const TestFocusable({
Key key,
this.focusNode,
Key? key,
required this.focusNode,
this.autofocus = true,
}) : super(key: key);
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/src/widgets/basic.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -19,7 +17,7 @@ void main() {
return const SizedBox();
}),
));
final InheritedElement element = key.currentContext as InheritedElement;
final InheritedElement element = key.currentContext! as InheritedElement;
expect(
element.toStringDeep(minLevel: DiagnosticLevel.info),
equalsIgnoringHashCodes(
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/foundation.dart';
......@@ -13,28 +11,28 @@ import 'package:flutter/material.dart';
// valued fields: a, b, c.
class ABCModel extends InheritedModel<String> {
const ABCModel({
Key key,
Key? key,
this.a,
this.b,
this.c,
this.aspects,
Widget child,
required Widget child,
}) : super(key: key, child: child);
final int a;
final int b;
final int c;
final int? a;
final int? b;
final int? c;
// The aspects (fields) of this model that widgets can depend on with
// inheritFrom.
//
// This property is null by default, which means that the model supports
// all 3 fields.
final Set<String> aspects;
final Set<String>? aspects;
@override
bool isSupportedAspect(Object aspect) {
return aspect == null || aspects == null || aspects.contains(aspect);
return aspect == null || aspects == null || aspects!.contains(aspect);
}
@override
......@@ -50,13 +48,13 @@ class ABCModel extends InheritedModel<String> {
|| (c != old.c && dependencies.contains('c'));
}
static ABCModel of(BuildContext context, { String fieldName }) {
static ABCModel? of(BuildContext context, { String? fieldName }) {
return InheritedModel.inheritFrom<ABCModel>(context, aspect: fieldName);
}
}
class ShowABCField extends StatefulWidget {
const ShowABCField({ Key key, this.fieldName }) : super(key: key);
const ShowABCField({ Key? key, required this.fieldName }) : super(key: key);
final String fieldName;
......@@ -69,8 +67,8 @@ class _ShowABCFieldState extends State<ShowABCField> {
@override
Widget build(BuildContext context) {
final ABCModel abc = ABCModel.of(context, fieldName: widget.fieldName);
final int value = widget.fieldName == 'a' ? abc.a : (widget.fieldName == 'b' ? abc.b : abc.c);
final ABCModel abc = ABCModel.of(context, fieldName: widget.fieldName)!;
final int? value = widget.fieldName == 'a' ? abc.a : (widget.fieldName == 'b' ? abc.b : abc.c);
return Text('${widget.fieldName}: $value [${_buildCount++}]');
}
}
......@@ -91,7 +89,7 @@ void main() {
// aspect of the model changes.
final Widget showABC = Builder(
builder: (BuildContext context) {
final ABCModel abc = ABCModel.of(context);
final ABCModel abc = ABCModel.of(context)!;
return Text('a: ${abc.a} b: ${abc.b} c: ${abc.c}');
}
);
......@@ -193,7 +191,7 @@ void main() {
});
testWidgets('Looking up an non existent InheritedModel ancestor returns null', (WidgetTester tester) async {
ABCModel inheritedModel;
ABCModel? inheritedModel;
await tester.pumpWidget(
Builder(
......@@ -228,8 +226,8 @@ void main() {
// Which is the inner model, for which b,c are null.
final Widget showABC = Builder(
builder: (BuildContext context) {
final ABCModel abc = ABCModel.of(context);
return Text('a: ${abc.a} b: ${abc.b} c: ${abc.c}', style: Theme.of(context).textTheme.headline6);
final ABCModel abc = ABCModel.of(context)!;
return Text('a: ${abc.a} b: ${abc.b} c: ${abc.c}', style: Theme.of(context)!.textTheme.headline6);
}
);
......@@ -330,7 +328,7 @@ void main() {
int _a = 0;
int _b = 1;
int _c = 2;
Set<String> _innerModelAspects = <String>{'a'};
Set<String>? _innerModelAspects = <String>{'a'};
// Same as in abcPage in the "Inner InheritedModel shadows the outer one"
// test except: the "Add b aspect" changes adds 'b' to the set of
......@@ -345,8 +343,8 @@ void main() {
// Which is the inner model, for which b,c are null.
final Widget showABC = Builder(
builder: (BuildContext context) {
final ABCModel abc = ABCModel.of(context);
return Text('a: ${abc.a} b: ${abc.b} c: ${abc.c}', style: Theme.of(context).textTheme.headline6);
final ABCModel abc = ABCModel.of(context)!;
return Text('a: ${abc.a} b: ${abc.b} c: ${abc.c}', style: Theme.of(context)!.textTheme.headline6);
}
);
......
......@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
import 'test_widgets.dart';
class TestInherited extends InheritedWidget {
const TestInherited({ Key key, Widget child, this.shouldNotify = true })
const TestInherited({ Key? key, required Widget child, this.shouldNotify = true })
: super(key: key, child: child);
final bool shouldNotify;
......@@ -22,7 +20,7 @@ class TestInherited extends InheritedWidget {
}
class ValueInherited extends InheritedWidget {
const ValueInherited({ Key key, Widget child, this.value })
const ValueInherited({ Key? key, required Widget child, required this.value })
: super(key: key, child: child);
final int value;
......@@ -32,7 +30,7 @@ class ValueInherited extends InheritedWidget {
}
class ExpectFail extends StatefulWidget {
const ExpectFail(this.onError, { Key key }) : super(key: key);
const ExpectFail(this.onError, { Key? key }) : super(key: key);
final VoidCallback onError;
@override
......@@ -55,7 +53,7 @@ class ExpectFailState extends State<ExpectFail> {
}
class ChangeNotifierInherited extends InheritedNotifier<ChangeNotifier> {
const ChangeNotifierInherited({ Key key, Widget child, ChangeNotifier notifier })
const ChangeNotifierInherited({ Key? key, required Widget child, ChangeNotifier? notifier })
: super(key: key, child: child, notifier: notifier);
}
......@@ -65,7 +63,7 @@ void main() {
final Builder builder = Builder(
builder: (BuildContext context) {
log.add(context.dependOnInheritedWidgetOfExactType<TestInherited>());
log.add(context.dependOnInheritedWidgetOfExactType<TestInherited>()!);
return Container();
}
);
......@@ -97,7 +95,7 @@ void main() {
key: globalKey,
child: Builder(
builder: (BuildContext context) {
log.add(context.dependOnInheritedWidgetOfExactType<TestInherited>());
log.add(context.dependOnInheritedWidgetOfExactType<TestInherited>()!);
return Container();
}
),
......@@ -134,7 +132,7 @@ void main() {
child: Container(
child: Builder(
builder: (BuildContext context) {
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>();
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
log.add('a: ${v.value}');
return const Text('', textDirection: TextDirection.ltr);
}
......@@ -151,7 +149,7 @@ void main() {
child: Container(
child: Builder(
builder: (BuildContext context) {
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>();
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
log.add('b: ${v.value}');
return const Text('', textDirection: TextDirection.ltr);
}
......@@ -209,7 +207,7 @@ void main() {
key: key,
child: Builder(
builder: (BuildContext context) {
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>();
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
log.add('a: ${v.value}');
return const Text('', textDirection: TextDirection.ltr);
}
......@@ -227,7 +225,7 @@ void main() {
key: key,
child: Builder(
builder: (BuildContext context) {
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>();
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
log.add('b: ${v.value}');
return const Text('', textDirection: TextDirection.ltr);
}
......@@ -270,7 +268,7 @@ void main() {
final Widget child = Builder(
builder: (BuildContext context) {
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>();
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
log.add(v.value);
return const Text('', textDirection: TextDirection.ltr);
}
......@@ -341,7 +339,7 @@ void main() {
final Widget child = Builder(
key: GlobalKey(),
builder: (BuildContext context) {
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>();
final ValueInherited v = context.dependOnInheritedWidgetOfExactType<ValueInherited>()!;
log.add(v.value);
return const Text('', textDirection: TextDirection.ltr);
},
......@@ -382,13 +380,13 @@ void main() {
});
testWidgets('Inherited widget notifies descendants when descendant previously failed to find a match', (WidgetTester tester) async {
int inheritedValue = -1;
int? inheritedValue = -1;
final Widget inner = Container(
key: GlobalKey(),
child: Builder(
builder: (BuildContext context) {
final ValueInherited widget = context.dependOnInheritedWidgetOfExactType<ValueInherited>();
final ValueInherited? widget = context.dependOnInheritedWidgetOfExactType<ValueInherited>();
inheritedValue = widget?.value;
return Container();
}
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -14,7 +12,7 @@ class TestRoute extends PageRouteBuilder<void> {
}
class IconTextBox extends StatelessWidget {
const IconTextBox(this.text, { Key key }) : super(key: key);
const IconTextBox(this.text, { Key? key }) : super(key: key);
final String text;
@override
Widget build(BuildContext context) {
......@@ -34,7 +32,7 @@ void main() {
const Color textColor = Color(0xFF00FF00);
const Color iconColor = Color(0xFF0000FF);
bool useCaptureAll = false;
BuildContext navigatorContext;
late BuildContext navigatorContext;
Widget buildFrame() {
return WidgetsApp(
......@@ -61,7 +59,7 @@ void main() {
behavior: HitTestBehavior.opaque,
onTap: () {
navigatorContext = context;
Navigator.of(context).push(
Navigator.of(context)!.push(
TestRoute(
useCaptureAll
? InheritedTheme.captureAll(context, const IconTextBox('Hello'))
......@@ -88,7 +86,7 @@ void main() {
of: find.byType(Icon),
matching: find.byType(RichText),
),
).text.style;
).text.style!;
}
TextStyle getTextStyle(String text) {
......@@ -97,7 +95,7 @@ void main() {
of: find.text(text),
matching: find.byType(RichText),
),
).text.style;
).text.style!;
}
useCaptureAll = false;
......@@ -123,7 +121,7 @@ void main() {
// Return to the home route
useCaptureAll = true;
Navigator.of(navigatorContext).pop();
Navigator.of(navigatorContext)!.pop();
await tester.pumpAndSettle(); // route transition
// Verify that all is the same as it was when the test started
......@@ -199,7 +197,7 @@ void main() {
of: find.byKey(key),
matching: find.byType(RichText),
),
).text.style;
).text.style!;
}
expect(getIconStyle(icon1).color, innerColor);
......@@ -245,7 +243,7 @@ void main() {
of: find.text(text),
matching: find.byType(RichText),
),
).text.style;
).text.style!;
}
expect(getTextStyle('Hello').fontSize, null);
......
......@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
List<String> ancestors = <String>[];
class TestWidget extends StatefulWidget {
const TestWidget({ Key key }) : super(key: key);
const TestWidget({ Key? key }) : super(key: key);
@override
TestWidgetState createState() => TestWidgetState();
}
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
......@@ -625,11 +623,11 @@ void main() {
testWidgets('Scale with mouse returns onInteraction properties', (WidgetTester tester) async{
final TransformationController transformationController = TransformationController();
Offset focalPoint;
Offset localFocalPoint;
double scaleChange;
Velocity currentVelocity;
bool calledStart;
late Offset focalPoint;
late Offset localFocalPoint;
late double scaleChange;
late Velocity currentVelocity;
late bool calledStart;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
......@@ -677,11 +675,11 @@ void main() {
testWidgets('onInteraction can be used to get scene point', (WidgetTester tester) async{
final TransformationController transformationController = TransformationController();
Offset focalPoint;
Offset localFocalPoint;
double scaleChange;
Velocity currentVelocity;
bool calledStart;
late Offset focalPoint;
late Offset localFocalPoint;
late double scaleChange;
late Velocity currentVelocity;
late bool calledStart;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
......
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