Some NNBD Test Conversion (#67558)
Just converting some test files to NNBD
This commit is contained in:
committed by
GitHub
parent
82ff246156
commit
b79e3462a3
@@ -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/gestures.dart';
|
||||
@@ -38,10 +36,10 @@ void main() {
|
||||
expect(material.elevation, 0.0);
|
||||
expect(material.shadowColor, null);
|
||||
expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0)));
|
||||
expect(material.textStyle.color, const Color(0xdd000000));
|
||||
expect(material.textStyle.fontFamily, 'Roboto');
|
||||
expect(material.textStyle.fontSize, 14);
|
||||
expect(material.textStyle.fontWeight, FontWeight.w500);
|
||||
expect(material.textStyle?.color, const Color(0xdd000000));
|
||||
expect(material.textStyle?.fontFamily, 'Roboto');
|
||||
expect(material.textStyle?.fontSize, 14);
|
||||
expect(material.textStyle?.fontWeight, FontWeight.w500);
|
||||
expect(material.type, MaterialType.transparency);
|
||||
|
||||
final Offset center = tester.getCenter(find.byType(FlatButton));
|
||||
@@ -58,10 +56,10 @@ void main() {
|
||||
expect(material.elevation, 0.0);
|
||||
expect(material.shadowColor, null);
|
||||
expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0)));
|
||||
expect(material.textStyle.color, const Color(0xdd000000));
|
||||
expect(material.textStyle.fontFamily, 'Roboto');
|
||||
expect(material.textStyle.fontSize, 14);
|
||||
expect(material.textStyle.fontWeight, FontWeight.w500);
|
||||
expect(material.textStyle?.color, const Color(0xdd000000));
|
||||
expect(material.textStyle?.fontFamily, 'Roboto');
|
||||
expect(material.textStyle?.fontSize, 14);
|
||||
expect(material.textStyle?.fontWeight, FontWeight.w500);
|
||||
expect(material.type, MaterialType.transparency);
|
||||
|
||||
// Disabled FlatButton
|
||||
@@ -83,10 +81,10 @@ void main() {
|
||||
expect(material.elevation, 0.0);
|
||||
expect(material.shadowColor, null);
|
||||
expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0)));
|
||||
expect(material.textStyle.color, const Color(0x61000000));
|
||||
expect(material.textStyle.fontFamily, 'Roboto');
|
||||
expect(material.textStyle.fontSize, 14);
|
||||
expect(material.textStyle.fontWeight, FontWeight.w500);
|
||||
expect(material.textStyle?.color, const Color(0x61000000));
|
||||
expect(material.textStyle?.fontFamily, 'Roboto');
|
||||
expect(material.textStyle?.fontSize, 14);
|
||||
expect(material.textStyle?.fontWeight, FontWeight.w500);
|
||||
expect(material.type, MaterialType.transparency);
|
||||
});
|
||||
|
||||
@@ -171,9 +169,9 @@ void main() {
|
||||
MaterialState.focused,
|
||||
};
|
||||
if (states.any(interactiveStates.contains)) {
|
||||
return Colors.blue[900];
|
||||
return Colors.blue[900]!;
|
||||
}
|
||||
return Colors.blue[800];
|
||||
return Colors.blue[800]!;
|
||||
}
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -260,8 +258,8 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
Color textColor() {
|
||||
return tester.renderObject<RenderParagraph>(find.text('FlatButton')).text.style.color;
|
||||
Color? textColor() {
|
||||
return tester.renderObject<RenderParagraph>(find.text('FlatButton')).text.style?.color;
|
||||
}
|
||||
|
||||
// Default, not disabled.
|
||||
@@ -329,7 +327,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
Color iconColor() => _iconStyle(tester, Icons.add).color;
|
||||
Color? iconColor() => _iconStyle(tester, Icons.add)?.color;
|
||||
// Default, not disabled.
|
||||
expect(iconColor(), equals(defaultColor));
|
||||
|
||||
@@ -386,8 +384,8 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
Color textColor() {
|
||||
return tester.renderObject<RenderParagraph>(find.text('FlatButton')).text.style.color;
|
||||
Color? textColor() {
|
||||
return tester.renderObject<RenderParagraph>(find.text('FlatButton')).text.style?.color;
|
||||
}
|
||||
|
||||
// Disabled.
|
||||
@@ -460,7 +458,7 @@ void main() {
|
||||
addTearDown(gesture.removePointer);
|
||||
|
||||
await tester.pump();
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
expect(RendererBinding.instance?.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
@@ -476,7 +474,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
expect(RendererBinding.instance?.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
|
||||
// Test default cursor
|
||||
await tester.pumpWidget(
|
||||
@@ -492,7 +490,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
||||
expect(RendererBinding.instance?.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
||||
|
||||
// Test default cursor when disabled
|
||||
await tester.pumpWidget(
|
||||
@@ -508,7 +506,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||
expect(RendererBinding.instance?.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||
});
|
||||
|
||||
testWidgets('Does FlatButton work with focus', (WidgetTester tester) async {
|
||||
@@ -527,7 +525,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
WidgetsBinding.instance.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
WidgetsBinding.instance?.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
focusNode.requestFocus();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -695,7 +693,7 @@ void main() {
|
||||
bool wasPressed;
|
||||
Finder flatButton;
|
||||
|
||||
Widget buildFrame({ VoidCallback onPressed, VoidCallback onLongPress }) {
|
||||
Widget buildFrame({ VoidCallback? onPressed, VoidCallback? onLongPress }) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: FlatButton(
|
||||
@@ -829,7 +827,7 @@ void main() {
|
||||
const double buttonHeight = 100;
|
||||
const double buttonDefaultMinHeight = 36.0;
|
||||
|
||||
Future<void> buildWidget({double buttonHeight}) {
|
||||
Future<void> buildWidget({double? buttonHeight}) {
|
||||
return tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -859,7 +857,7 @@ void main() {
|
||||
const double buttonMinWidth = 100;
|
||||
const double buttonDefaultMinWidth = 88.0;
|
||||
|
||||
Future<void> buildWidget({double buttonMinWidth}) {
|
||||
Future<void> buildWidget({double? buttonMinWidth}) {
|
||||
return tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -886,7 +884,7 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
TextStyle _iconStyle(WidgetTester tester, IconData icon) {
|
||||
TextStyle? _iconStyle(WidgetTester tester, IconData icon) {
|
||||
final RichText iconRichText = tester.widget<RichText>(
|
||||
find.descendant(of: find.byIcon(icon), matching: find.byType(RichText)),
|
||||
);
|
||||
|
||||
@@ -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_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 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.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 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
@@ -110,9 +108,8 @@ void main() {
|
||||
final Text textWidget = actionTextBox.widget as Text;
|
||||
final DefaultTextStyle defaultTextStyle = DefaultTextStyle.of(actionTextBox);
|
||||
|
||||
TextStyle effectiveStyle = textWidget.style;
|
||||
effectiveStyle = defaultTextStyle.style.merge(textWidget.style);
|
||||
expect(effectiveStyle.color.alpha, 128); // Which is alpha of .5
|
||||
final TextStyle effectiveStyle = defaultTextStyle.style.merge(textWidget.style);
|
||||
expect(effectiveStyle.color?.alpha, 128); // Which is alpha of .5
|
||||
|
||||
// We drag up to fully collapse the space bar.
|
||||
await tester.drag(find.byType(Container).first, const Offset(0, -400.0));
|
||||
@@ -391,13 +388,13 @@ void main() {
|
||||
testWidgets('FlexibleSpaceBar sets width constraints for the title', (WidgetTester tester) async {
|
||||
const double titleFontSize = 20.0;
|
||||
const double height = 300.0;
|
||||
double width;
|
||||
late double width;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (BuildContext context) {
|
||||
width = MediaQuery.of(context).size.width;
|
||||
width = MediaQuery.of(context)!.size.width;
|
||||
return CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
SliverAppBar(
|
||||
@@ -439,7 +436,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('FlexibleSpaceBar test titlePadding defaults', (WidgetTester tester) async {
|
||||
Widget buildFrame(TargetPlatform platform, bool centerTitle) {
|
||||
Widget buildFrame(TargetPlatform platform, bool? centerTitle) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(platform: platform),
|
||||
home: Scaffold(
|
||||
@@ -489,7 +486,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('FlexibleSpaceBar test titlePadding override', (WidgetTester tester) async {
|
||||
Widget buildFrame(TargetPlatform platform, bool centerTitle) {
|
||||
Widget buildFrame(TargetPlatform platform, bool? centerTitle) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(platform: platform),
|
||||
home: Scaffold(
|
||||
@@ -560,7 +557,7 @@ void main() {
|
||||
class TestDelegate extends SliverPersistentHeaderDelegate {
|
||||
|
||||
const TestDelegate({
|
||||
this.settings,
|
||||
required this.settings,
|
||||
});
|
||||
|
||||
final FlexibleSpaceBarSettings settings;
|
||||
|
||||
@@ -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:math';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -79,11 +77,11 @@ void main() {
|
||||
});
|
||||
|
||||
group('interrupts in-progress animations without jumps', () {
|
||||
_GeometryListener geometryListener;
|
||||
ScaffoldGeometry geometry;
|
||||
_GeometryListenerState listenerState;
|
||||
Size previousRect;
|
||||
Iterable<double> previousRotations;
|
||||
_GeometryListener? geometryListener;
|
||||
ScaffoldGeometry? geometry;
|
||||
_GeometryListenerState? listenerState;
|
||||
Size? previousRect;
|
||||
Iterable<double>? previousRotations;
|
||||
|
||||
// The maximum amounts we expect the fab width and height to change
|
||||
// during one step of a transition.
|
||||
@@ -100,13 +98,13 @@ void main() {
|
||||
// Measure the delta in width and height of the fab, and check that it never grows
|
||||
// by more than the expected maximum deltas.
|
||||
void check() {
|
||||
geometry = listenerState.cache.value;
|
||||
final Size currentRect = geometry.floatingActionButtonArea?.size;
|
||||
geometry = listenerState?.cache.value;
|
||||
final Size? currentRect = geometry?.floatingActionButtonArea?.size;
|
||||
// Measure the delta in width and height of the rect, and check that
|
||||
// it never grows by more than a safe amount.
|
||||
if (previousRect != null && currentRect != null) {
|
||||
final double deltaWidth = currentRect.width - previousRect.width;
|
||||
final double deltaHeight = currentRect.height - previousRect.height;
|
||||
final double deltaWidth = currentRect.width - previousRect!.width;
|
||||
final double deltaHeight = currentRect.height - previousRect!.height;
|
||||
expect(
|
||||
deltaWidth.abs(),
|
||||
lessThanOrEqualTo(maxDeltaWidth),
|
||||
@@ -135,15 +133,15 @@ void main() {
|
||||
final Iterable<double> currentRotations = rotationTransitions.map(
|
||||
(RotationTransition t) => t.turns.value);
|
||||
|
||||
if (previousRotations != null && previousRotations.isNotEmpty
|
||||
if (previousRotations != null && previousRotations!.isNotEmpty
|
||||
&& currentRotations != null && currentRotations.isNotEmpty
|
||||
&& previousRect != null && currentRect != null) {
|
||||
final List<double> deltas = <double>[];
|
||||
for (final double currentRotation in currentRotations) {
|
||||
double minDelta;
|
||||
for (final double previousRotation in previousRotations) {
|
||||
late double minDelta;
|
||||
for (final double previousRotation in previousRotations!) {
|
||||
final double delta = (previousRotation - currentRotation).abs();
|
||||
minDelta ??= delta;
|
||||
minDelta = delta;
|
||||
minDelta = min(delta, minDelta);
|
||||
}
|
||||
deltas.add(minDelta);
|
||||
@@ -161,7 +159,7 @@ void main() {
|
||||
}
|
||||
|
||||
listenerState = tester.state(find.byType(_GeometryListener));
|
||||
listenerState.geometryListenable.addListener(check);
|
||||
listenerState!.geometryListenable!.addListener(check);
|
||||
}
|
||||
|
||||
setUp(() {
|
||||
@@ -649,7 +647,7 @@ void main() {
|
||||
builder: (BuildContext context) {
|
||||
return FloatingActionButton(
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
ScaffoldMessenger.of(context)!.showSnackBar(
|
||||
const SnackBar(content: Text('Snacky!')),
|
||||
);
|
||||
},
|
||||
@@ -677,10 +675,10 @@ void main() {
|
||||
Future<void> _runFloatTests(
|
||||
WidgetTester tester,
|
||||
FloatingActionButtonLocation location, {
|
||||
Rect defaultRect,
|
||||
Rect bottomNavigationBarRect,
|
||||
Rect bottomSheetRect,
|
||||
Rect snackBarRect,
|
||||
required Rect defaultRect,
|
||||
required Rect bottomNavigationBarRect,
|
||||
required Rect bottomSheetRect,
|
||||
required Rect snackBarRect,
|
||||
bool mini = false,
|
||||
}) async {
|
||||
const double keyboardHeight = 200.0;
|
||||
@@ -1050,10 +1048,10 @@ void main() {
|
||||
Future<void> _runDockedTests(
|
||||
WidgetTester tester,
|
||||
FloatingActionButtonLocation location, {
|
||||
Rect defaultRect,
|
||||
Rect bottomNavigationBarRect,
|
||||
Rect bottomSheetRect,
|
||||
Rect snackBarRect,
|
||||
required Rect defaultRect,
|
||||
required Rect bottomNavigationBarRect,
|
||||
required Rect bottomSheetRect,
|
||||
required Rect snackBarRect,
|
||||
bool mini = false,
|
||||
}) async {
|
||||
const double keyboardHeight = 200.0;
|
||||
@@ -1385,8 +1383,8 @@ void main() {
|
||||
Future<void> _runTopTests(
|
||||
WidgetTester tester,
|
||||
FloatingActionButtonLocation location, {
|
||||
Rect defaultRect,
|
||||
Rect appBarRect,
|
||||
required Rect defaultRect,
|
||||
required Rect appBarRect,
|
||||
bool mini = false,
|
||||
}) async {
|
||||
const double viewPadding = 50.0;
|
||||
@@ -1508,8 +1506,8 @@ class _GeometryListenerState extends State<_GeometryListener> {
|
||||
}
|
||||
|
||||
int numNotifications = 0;
|
||||
ValueListenable<ScaffoldGeometry> geometryListenable;
|
||||
_GeometryCachePainter cache;
|
||||
ValueListenable<ScaffoldGeometry>? geometryListenable;
|
||||
late _GeometryCachePainter cache;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
@@ -1519,11 +1517,11 @@ class _GeometryListenerState extends State<_GeometryListener> {
|
||||
return;
|
||||
|
||||
if (geometryListenable != null)
|
||||
geometryListenable.removeListener(onGeometryChanged);
|
||||
geometryListenable!.removeListener(onGeometryChanged);
|
||||
|
||||
geometryListenable = newListenable;
|
||||
geometryListenable.addListener(onGeometryChanged);
|
||||
cache = _GeometryCachePainter(geometryListenable);
|
||||
geometryListenable!.addListener(onGeometryChanged);
|
||||
cache = _GeometryCachePainter(geometryListenable!);
|
||||
}
|
||||
|
||||
void onGeometryChanged() {
|
||||
@@ -1545,7 +1543,7 @@ const double _miniFloatOffsetY = _floatOffsetY + kMiniButtonOffsetAdjustment;
|
||||
Widget _singleFabScaffold(
|
||||
FloatingActionButtonLocation location,
|
||||
{
|
||||
FloatingActionButtonAnimator animator,
|
||||
FloatingActionButtonAnimator? animator,
|
||||
bool mini = false,
|
||||
TextDirection textDirection = TextDirection.ltr,
|
||||
}
|
||||
@@ -1589,7 +1587,7 @@ class _GeometryCachePainter extends CustomPainter {
|
||||
|
||||
final ValueListenable<ScaffoldGeometry> geometryListenable;
|
||||
|
||||
ScaffoldGeometry value;
|
||||
late ScaffoldGeometry value;
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
value = geometryListenable.value;
|
||||
@@ -1602,15 +1600,15 @@ class _GeometryCachePainter extends CustomPainter {
|
||||
}
|
||||
|
||||
Widget buildFrame({
|
||||
FloatingActionButton fab = const FloatingActionButton(
|
||||
FloatingActionButton? fab = const FloatingActionButton(
|
||||
onPressed: null,
|
||||
child: Text('1'),
|
||||
),
|
||||
FloatingActionButtonLocation location,
|
||||
_GeometryListener listener,
|
||||
FloatingActionButtonLocation? location,
|
||||
_GeometryListener? listener,
|
||||
TextDirection textDirection = TextDirection.ltr,
|
||||
EdgeInsets viewInsets = const EdgeInsets.only(bottom: 200.0),
|
||||
Widget bab,
|
||||
Widget? bab,
|
||||
}) {
|
||||
return Localizations(
|
||||
locale: const Locale('en', 'us'),
|
||||
@@ -1677,17 +1675,17 @@ class _QuarterEndTopFabLocation extends StandardFabLocation
|
||||
|
||||
class _LinearMovementFabAnimator extends FloatingActionButtonAnimator {
|
||||
@override
|
||||
Offset getOffset({@required Offset begin, @required Offset end, @required double progress}) {
|
||||
return Offset.lerp(begin, end, progress);
|
||||
Offset getOffset({required Offset begin, required Offset end, required double progress}) {
|
||||
return Offset.lerp(begin, end, progress)!;
|
||||
}
|
||||
|
||||
@override
|
||||
Animation<double> getScaleAnimation({@required Animation<double> parent}) {
|
||||
Animation<double> getScaleAnimation({required Animation<double> parent}) {
|
||||
return const AlwaysStoppedAnimation<double>(1.0);
|
||||
}
|
||||
|
||||
@override
|
||||
Animation<double> getRotationAnimation({@required Animation<double> parent}) {
|
||||
Animation<double> getRotationAnimation({required Animation<double> parent}) {
|
||||
return const AlwaysStoppedAnimation<double>(1.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
|
||||
|
||||
@TestOn('!chrome') // whole file needs triage.
|
||||
import 'dart:ui';
|
||||
|
||||
@@ -109,8 +107,8 @@ void main() {
|
||||
expect(find.text('Add'), findsNothing);
|
||||
|
||||
// Test hover for tooltip.
|
||||
TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
|
||||
await gesture.addPointer();
|
||||
TestGesture? gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
|
||||
await gesture!.addPointer();
|
||||
addTearDown(() => gesture?.removePointer());
|
||||
await gesture.moveTo(tester.getCenter(find.byType(FloatingActionButton)));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -146,8 +144,8 @@ void main() {
|
||||
expect(find.text('Add'), findsNothing);
|
||||
|
||||
// Test hover for tooltip.
|
||||
TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
|
||||
await gesture.addPointer();
|
||||
TestGesture? gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
|
||||
await gesture!.addPointer();
|
||||
addTearDown(() => gesture?.removePointer());
|
||||
await tester.pumpAndSettle();
|
||||
await gesture.moveTo(tester.getCenter(find.byType(FloatingActionButton)));
|
||||
@@ -472,7 +470,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Floating Action Button heroTag', (WidgetTester tester) async {
|
||||
BuildContext theContext;
|
||||
late BuildContext theContext;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -495,7 +493,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Floating Action Button heroTag - with duplicate', (WidgetTester tester) async {
|
||||
BuildContext theContext;
|
||||
late BuildContext theContext;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -519,7 +517,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Floating Action Button heroTag - with duplicate', (WidgetTester tester) async {
|
||||
BuildContext theContext;
|
||||
late BuildContext theContext;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -773,7 +771,7 @@ void main() {
|
||||
|
||||
await tester.pump();
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -791,7 +789,7 @@ void main() {
|
||||
);
|
||||
|
||||
await gesture.moveTo(tester.getCenter(find.byType(FloatingActionButton)));
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
|
||||
// Test default cursor
|
||||
await tester.pumpWidget(
|
||||
@@ -808,7 +806,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
||||
|
||||
// Test default cursor when disabled
|
||||
await tester.pumpWidget(
|
||||
@@ -825,7 +823,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||
});
|
||||
|
||||
testWidgets('Floating Action Button has no clip by default', (WidgetTester tester) async {
|
||||
@@ -882,7 +880,7 @@ void main() {
|
||||
final RichText iconRichText = tester.widget<RichText>(
|
||||
find.descendant(of: find.byIcon(Icons.access_alarm), matching: find.byType(RichText)),
|
||||
);
|
||||
expect(iconRichText.text.style.color, foregroundColor);
|
||||
expect(iconRichText.text.style!.color, foregroundColor);
|
||||
});
|
||||
|
||||
testWidgets('FloatingActionButton uses custom splash color', (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/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
@@ -28,7 +26,7 @@ void main() {
|
||||
// The color scheme values are guaranteed to be non null since the default
|
||||
// [ThemeData] creates it with [ColorScheme.fromSwatch].
|
||||
expect(_getRawMaterialButton(tester).fillColor, ThemeData().colorScheme.secondary);
|
||||
expect(_getRichText(tester).text.style.color, ThemeData().colorScheme.onSecondary);
|
||||
expect(_getRichText(tester).text.style!.color, ThemeData().colorScheme.onSecondary);
|
||||
|
||||
// These defaults come directly from the [FloatingActionButton].
|
||||
expect(_getRawMaterialButton(tester).elevation, 6);
|
||||
@@ -67,7 +65,7 @@ void main() {
|
||||
));
|
||||
|
||||
expect(_getRawMaterialButton(tester).fillColor, backgroundColor);
|
||||
expect(_getRichText(tester).text.style.color, foregroundColor);
|
||||
expect(_getRichText(tester).text.style!.color, foregroundColor);
|
||||
expect(_getRawMaterialButton(tester).elevation, elevation);
|
||||
expect(_getRawMaterialButton(tester).disabledElevation, disabledElevation);
|
||||
expect(_getRawMaterialButton(tester).highlightElevation, highlightElevation);
|
||||
@@ -112,7 +110,7 @@ void main() {
|
||||
));
|
||||
|
||||
expect(_getRawMaterialButton(tester).fillColor, backgroundColor);
|
||||
expect(_getRichText(tester).text.style.color, foregroundColor);
|
||||
expect(_getRichText(tester).text.style!.color, foregroundColor);
|
||||
expect(_getRawMaterialButton(tester).elevation, elevation);
|
||||
expect(_getRawMaterialButton(tester).disabledElevation, disabledElevation);
|
||||
expect(_getRawMaterialButton(tester).highlightElevation, highlightElevation);
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -23,7 +21,7 @@ class MockOnPressedFunction {
|
||||
}
|
||||
|
||||
void main() {
|
||||
MockOnPressedFunction mockOnPressedFunction;
|
||||
late MockOnPressedFunction mockOnPressedFunction;
|
||||
|
||||
setUp(() {
|
||||
mockOnPressedFunction = MockOnPressedFunction();
|
||||
@@ -537,14 +535,14 @@ void main() {
|
||||
});
|
||||
|
||||
group('feedback', () {
|
||||
FeedbackTester feedback;
|
||||
late FeedbackTester feedback;
|
||||
|
||||
setUp(() {
|
||||
feedback = FeedbackTester();
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
feedback?.dispose();
|
||||
feedback.dispose();
|
||||
});
|
||||
|
||||
testWidgets('IconButton with disabled feedback', (WidgetTester tester) async {
|
||||
@@ -664,7 +662,7 @@ void main() {
|
||||
|
||||
await tester.pump();
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.forbidden);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.forbidden);
|
||||
|
||||
// Test default is click
|
||||
await tester.pumpWidget(
|
||||
@@ -681,11 +679,11 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
||||
});
|
||||
}
|
||||
|
||||
Widget wrap({ Widget child }) {
|
||||
Widget wrap({ required Widget child }) {
|
||||
return FocusTraversalGroup(
|
||||
policy: ReadingOrderTraversalPolicy(),
|
||||
child: Directionality(
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -19,12 +17,12 @@ void main() {
|
||||
builder: (BuildContext context) {
|
||||
return Container(
|
||||
key: primaryContainerKey,
|
||||
color: Theme.of(context).primaryColor,
|
||||
color: Theme.of(context)!.primaryColor,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
BuildContext navigatorContext;
|
||||
late BuildContext navigatorContext;
|
||||
|
||||
Widget buildFrame() {
|
||||
return MaterialApp(
|
||||
@@ -33,7 +31,7 @@ void main() {
|
||||
builder: (BuildContext context) {
|
||||
navigatorContext = context;
|
||||
return Theme(
|
||||
data: Theme.of(context).copyWith(primaryColor: primaryColor),
|
||||
data: Theme.of(context)!.copyWith(primaryColor: primaryColor),
|
||||
child: Builder( // Introduce a context so the shadow Theme is visible to captureAll().
|
||||
builder: (BuildContext context) {
|
||||
return Center(
|
||||
@@ -43,7 +41,7 @@ void main() {
|
||||
ElevatedButton(
|
||||
child: const Text('push unwrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// The primaryBox will see the default Theme when built.
|
||||
builder: (BuildContext _) => primaryBox,
|
||||
@@ -54,7 +52,7 @@ void main() {
|
||||
ElevatedButton(
|
||||
child: const Text('push wrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// Capture the shadow Theme.
|
||||
builder: (BuildContext _) => InheritedTheme.captureAll(context, primaryBox),
|
||||
@@ -75,7 +73,7 @@ void main() {
|
||||
}
|
||||
|
||||
Color containerColor() {
|
||||
return tester.widget<Container>(find.byKey(primaryContainerKey)).color;
|
||||
return tester.widget<Container>(find.byKey(primaryContainerKey)).color!;
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildFrame());
|
||||
@@ -86,7 +84,7 @@ void main() {
|
||||
await tester.pumpAndSettle(); // route animation
|
||||
expect(containerColor(), primaryColor);
|
||||
|
||||
Navigator.of(navigatorContext).pop();
|
||||
Navigator.of(navigatorContext)!.pop();
|
||||
await tester.pumpAndSettle(); // route animation
|
||||
|
||||
// Show the route which contains primaryBox
|
||||
@@ -133,7 +131,7 @@ void main() {
|
||||
TextStyle itemTextStyle(String text) {
|
||||
return tester.widget<RichText>(
|
||||
find.descendant(of: find.text(text), matching: find.byType(RichText)),
|
||||
).text.style;
|
||||
).text.style!;
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildFrame());
|
||||
@@ -176,7 +174,7 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
BuildContext navigatorContext;
|
||||
late BuildContext navigatorContext;
|
||||
|
||||
Widget buildFrame() {
|
||||
return MaterialApp(
|
||||
@@ -196,7 +194,7 @@ void main() {
|
||||
ElevatedButton(
|
||||
child: const Text('push unwrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// The Banner will see the default BannerTheme when built.
|
||||
builder: (BuildContext _) => banner,
|
||||
@@ -207,7 +205,7 @@ void main() {
|
||||
ElevatedButton(
|
||||
child: const Text('push wrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// Capture the shadow BannerTheme.
|
||||
builder: (BuildContext _) => InheritedTheme.captureAll(context, banner),
|
||||
@@ -228,7 +226,7 @@ void main() {
|
||||
Color bannerColor() {
|
||||
return tester.widget<Container>(
|
||||
find.descendant(of: find.byType(MaterialBanner), matching: find.byType(Container)).first,
|
||||
).color;
|
||||
).color!;
|
||||
}
|
||||
|
||||
TextStyle getTextStyle(String text) {
|
||||
@@ -237,7 +235,7 @@ void main() {
|
||||
of: find.text(text),
|
||||
matching: find.byType(RichText),
|
||||
),
|
||||
).text.style;
|
||||
).text.style!;
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildFrame());
|
||||
@@ -249,7 +247,7 @@ void main() {
|
||||
expect(getTextStyle('hello').fontSize, bannerFontSize);
|
||||
expect(getTextStyle('hello').color, bannerTextColor);
|
||||
|
||||
Navigator.of(navigatorContext).pop();
|
||||
Navigator.of(navigatorContext)!.pop();
|
||||
await tester.pumpAndSettle(); // route animation
|
||||
|
||||
await tester.tap(find.text('push unwrapped'));
|
||||
@@ -265,7 +263,7 @@ void main() {
|
||||
const double dividerThickness = 7;
|
||||
const Widget divider = Center(child: Divider());
|
||||
|
||||
BuildContext navigatorContext;
|
||||
late BuildContext navigatorContext;
|
||||
|
||||
Widget buildFrame() {
|
||||
return MaterialApp(
|
||||
@@ -286,7 +284,7 @@ void main() {
|
||||
ElevatedButton(
|
||||
child: const Text('push unwrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// The Banner will see the default BannerTheme when built.
|
||||
builder: (BuildContext _) => divider,
|
||||
@@ -297,7 +295,7 @@ void main() {
|
||||
ElevatedButton(
|
||||
child: const Text('push wrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// Capture the shadow BannerTheme.
|
||||
builder: (BuildContext _) => InheritedTheme.captureAll(context, divider),
|
||||
@@ -319,7 +317,7 @@ void main() {
|
||||
final BoxDecoration decoration = tester.widget<Container>(
|
||||
find.descendant(of: find.byType(Divider), matching: find.byType(Container)).first,
|
||||
).decoration as BoxDecoration;
|
||||
return decoration.border.bottom;
|
||||
return decoration.border!.bottom;
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildFrame());
|
||||
@@ -331,7 +329,7 @@ void main() {
|
||||
expect(dividerBorder().color, dividerColor);
|
||||
expect(dividerBorder().width, dividerThickness);
|
||||
|
||||
Navigator.of(navigatorContext).pop();
|
||||
Navigator.of(navigatorContext)!.pop();
|
||||
await tester.pumpAndSettle(); // route animation
|
||||
|
||||
await tester.tap(find.text('push unwrapped'));
|
||||
@@ -371,7 +369,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
BuildContext navigatorContext;
|
||||
late BuildContext navigatorContext;
|
||||
|
||||
Widget buildFrame() {
|
||||
return MaterialApp(
|
||||
@@ -390,7 +388,7 @@ void main() {
|
||||
ElevatedButton(
|
||||
child: const Text('push unwrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// The Banner will see the default BannerTheme when built.
|
||||
builder: (BuildContext _) => listTiles,
|
||||
@@ -401,7 +399,7 @@ void main() {
|
||||
ElevatedButton(
|
||||
child: const Text('push wrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// Capture the shadow BannerTheme.
|
||||
builder: (BuildContext _) => InheritedTheme.captureAll(context, listTiles),
|
||||
@@ -422,7 +420,7 @@ void main() {
|
||||
TextStyle getTextStyle(String text) {
|
||||
return tester.widget<RichText>(
|
||||
find.descendant(of: find.text(text), matching: find.byType(RichText)),
|
||||
).text.style;
|
||||
).text.style!;
|
||||
}
|
||||
|
||||
TextStyle getIconStyle(Key key) {
|
||||
@@ -431,7 +429,7 @@ void main() {
|
||||
of: find.byKey(key),
|
||||
matching: find.byType(RichText),
|
||||
),
|
||||
).text.style;
|
||||
).text.style!;
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildFrame());
|
||||
@@ -444,7 +442,7 @@ void main() {
|
||||
expect(getIconStyle(selectedIconKey).color, tileSelectedColor);
|
||||
expect(getIconStyle(unselectedIconKey).color, tileIconColor);
|
||||
|
||||
Navigator.of(navigatorContext).pop();
|
||||
Navigator.of(navigatorContext)!.pop();
|
||||
await tester.pumpAndSettle(); // route animation
|
||||
|
||||
await tester.tap(find.text('push unwrapped'));
|
||||
@@ -469,7 +467,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
BuildContext navigatorContext;
|
||||
late BuildContext navigatorContext;
|
||||
|
||||
Widget buildFrame() {
|
||||
return MaterialApp(
|
||||
@@ -490,7 +488,7 @@ void main() {
|
||||
ElevatedButton(
|
||||
child: const Text('push unwrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// The slider will see the default SliderTheme when built.
|
||||
builder: (BuildContext _) => slider,
|
||||
@@ -501,7 +499,7 @@ void main() {
|
||||
ElevatedButton(
|
||||
child: const Text('push wrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// Capture the shadow SliderTheme.
|
||||
builder: (BuildContext _) => InheritedTheme.captureAll(context, slider),
|
||||
@@ -528,7 +526,7 @@ void main() {
|
||||
expect(sliderBox, paints..rrect(color: activeTrackColor)..rrect(color: inactiveTrackColor));
|
||||
expect(sliderBox, paints..circle(color: thumbColor));
|
||||
|
||||
Navigator.of(navigatorContext).pop();
|
||||
Navigator.of(navigatorContext)!.pop();
|
||||
await tester.pumpAndSettle(); // route animation
|
||||
|
||||
await tester.tap(find.text('push unwrapped'));
|
||||
@@ -555,7 +553,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
BuildContext navigatorContext;
|
||||
late BuildContext navigatorContext;
|
||||
|
||||
Widget buildFrame() {
|
||||
return MaterialApp(
|
||||
@@ -575,7 +573,7 @@ void main() {
|
||||
ElevatedButton(
|
||||
child: const Text('push unwrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// The slider will see the default ToggleButtonsTheme when built.
|
||||
builder: (BuildContext _) => toggleButtons,
|
||||
@@ -586,7 +584,7 @@ void main() {
|
||||
ElevatedButton(
|
||||
child: const Text('push wrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// Capture the shadow toggleButtons.
|
||||
builder: (BuildContext _) => InheritedTheme.captureAll(context, toggleButtons),
|
||||
@@ -607,7 +605,7 @@ void main() {
|
||||
Color getTextColor(String text) {
|
||||
return tester.widget<RichText>(
|
||||
find.descendant(of: find.text(text), matching: find.byType(RichText)),
|
||||
).text.style.color;
|
||||
).text.style!.color!;
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildFrame());
|
||||
@@ -618,7 +616,7 @@ void main() {
|
||||
expect(getTextColor('selected'), selectedButtonColor);
|
||||
expect(getTextColor('unselected'), buttonColor);
|
||||
|
||||
Navigator.of(navigatorContext).pop();
|
||||
Navigator.of(navigatorContext)!.pop();
|
||||
await tester.pumpAndSettle(); // route animation
|
||||
|
||||
await tester.tap(find.text('push unwrapped'));
|
||||
@@ -644,7 +642,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
BuildContext navigatorContext;
|
||||
late BuildContext navigatorContext;
|
||||
|
||||
Widget buildFrame() {
|
||||
return MaterialApp(
|
||||
@@ -664,7 +662,7 @@ void main() {
|
||||
RaisedButton(
|
||||
child: const Text('push unwrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// The slider will see the default ButtonTheme when built.
|
||||
builder: (BuildContext _) => buttons,
|
||||
@@ -675,7 +673,7 @@ void main() {
|
||||
RaisedButton(
|
||||
child: const Text('push wrapped'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
Navigator.of(context)!.push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
// Capture the shadow toggleButtons.
|
||||
builder: (BuildContext _) => InheritedTheme.captureAll(context, buttons),
|
||||
@@ -699,7 +697,7 @@ void main() {
|
||||
of: find.widgetWithText(RawMaterialButton, text),
|
||||
matching: find.byType(Material),
|
||||
),
|
||||
).color;
|
||||
).color!;
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildFrame());
|
||||
@@ -710,7 +708,7 @@ void main() {
|
||||
expect(getButtonColor('disabled'), disabledButtonColor);
|
||||
expect(getButtonColor('enabled'), buttonColor);
|
||||
|
||||
Navigator.of(navigatorContext).pop();
|
||||
Navigator.of(navigatorContext)!.pop();
|
||||
await tester.pumpAndSettle(); // route animation
|
||||
|
||||
await tester.tap(find.text('push unwrapped'));
|
||||
|
||||
@@ -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/rendering.dart';
|
||||
import 'package:flutter/services.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/material.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 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -400,7 +398,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
||||
|
||||
// Test default of InkWell()
|
||||
await tester.pumpWidget(
|
||||
@@ -417,7 +415,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
||||
|
||||
// Test disabled
|
||||
await tester.pumpWidget(
|
||||
@@ -432,7 +430,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||
|
||||
// Test default of InkResponse()
|
||||
await tester.pumpWidget(
|
||||
@@ -449,7 +447,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
|
||||
|
||||
// Test disabled
|
||||
await tester.pumpWidget(
|
||||
@@ -464,18 +462,18 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||
});
|
||||
|
||||
group('feedback', () {
|
||||
FeedbackTester feedback;
|
||||
late FeedbackTester feedback;
|
||||
|
||||
setUp(() {
|
||||
feedback = FeedbackTester();
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
feedback?.dispose();
|
||||
feedback.dispose();
|
||||
});
|
||||
|
||||
testWidgets('enabled (default)', (WidgetTester tester) async {
|
||||
@@ -740,7 +738,7 @@ void main() {
|
||||
testWidgets('When ink wells are nested, only the inner one is triggered by tap splash', (WidgetTester tester) async {
|
||||
final GlobalKey middleKey = GlobalKey();
|
||||
final GlobalKey innerKey = GlobalKey();
|
||||
Widget paddedInkWell({Key key, Widget child}) {
|
||||
Widget paddedInkWell({Key? key, Widget? child}) {
|
||||
return InkWell(
|
||||
key: key,
|
||||
onTap: () {},
|
||||
@@ -769,7 +767,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
final MaterialInkController material = Material.of(tester.element(find.byKey(innerKey)));
|
||||
final MaterialInkController material = Material.of(tester.element(find.byKey(innerKey)))!;
|
||||
|
||||
// Press
|
||||
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byKey(innerKey)), pointer: 1);
|
||||
@@ -806,7 +804,7 @@ void main() {
|
||||
testWidgets('Reparenting parent should allow both inkwells to show splash afterwards', (WidgetTester tester) async {
|
||||
final GlobalKey middleKey = GlobalKey();
|
||||
final GlobalKey innerKey = GlobalKey();
|
||||
Widget paddedInkWell({Key key, Widget child}) {
|
||||
Widget paddedInkWell({Key? key, Widget? child}) {
|
||||
return InkWell(
|
||||
key: key,
|
||||
onTap: () {},
|
||||
@@ -842,7 +840,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
final MaterialInkController material = Material.of(tester.element(find.byKey(innerKey)));
|
||||
final MaterialInkController material = Material.of(tester.element(find.byKey(innerKey)))!;
|
||||
|
||||
// Press
|
||||
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byKey(innerKey)), pointer: 1);
|
||||
@@ -894,7 +892,7 @@ void main() {
|
||||
testWidgets('Parent inkwell does not block child inkwells from splashes', (WidgetTester tester) async {
|
||||
final GlobalKey middleKey = GlobalKey();
|
||||
final GlobalKey innerKey = GlobalKey();
|
||||
Widget paddedInkWell({Key key, Widget child}) {
|
||||
Widget paddedInkWell({Key? key, Widget? child}) {
|
||||
return InkWell(
|
||||
key: key,
|
||||
onTap: () {},
|
||||
@@ -923,7 +921,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
final MaterialInkController material = Material.of(tester.element(find.byKey(innerKey)));
|
||||
final MaterialInkController material = Material.of(tester.element(find.byKey(innerKey)))!;
|
||||
|
||||
// Press middle
|
||||
await tester.startGesture(tester.getTopLeft(find.byKey(middleKey)) + const Offset(1, 1), pointer: 1);
|
||||
@@ -983,7 +981,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
final MaterialInkController material = Material.of(tester.element(find.byKey(leftKey)));
|
||||
final MaterialInkController material = Material.of(tester.element(find.byKey(leftKey)))!;
|
||||
|
||||
final Offset parentPosition = tester.getTopLeft(find.byKey(parentKey)) + const Offset(1, 1);
|
||||
|
||||
@@ -1032,10 +1030,10 @@ void main() {
|
||||
final GlobalKey rightKey = GlobalKey();
|
||||
|
||||
Widget doubleInkWellRow({
|
||||
double leftWidth,
|
||||
double rightWidth,
|
||||
Widget leftChild,
|
||||
Widget rightChild,
|
||||
required double leftWidth,
|
||||
required double rightWidth,
|
||||
Widget? leftChild,
|
||||
Widget? rightChild,
|
||||
}) {
|
||||
return Material(
|
||||
child: Directionality(
|
||||
@@ -1095,7 +1093,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
final MaterialInkController material = Material.of(tester.element(find.byKey(innerKey)));
|
||||
final MaterialInkController material = Material.of(tester.element(find.byKey(innerKey)))!;
|
||||
|
||||
// Press inner
|
||||
final TestGesture gesture = await tester.startGesture(const Offset(100, 50), pointer: 1);
|
||||
@@ -1169,7 +1167,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
final MaterialInkController material = Material.of(tester.element(find.byKey(innerKey)));
|
||||
final MaterialInkController material = Material.of(tester.element(find.byKey(innerKey)))!;
|
||||
|
||||
// Press
|
||||
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byKey(innerKey)), pointer: 1);
|
||||
@@ -1194,9 +1192,9 @@ void main() {
|
||||
|
||||
testWidgets('disabled and hovered inkwell responds to mouse-exit', (WidgetTester tester) async {
|
||||
int onHoverCount = 0;
|
||||
bool hover;
|
||||
late bool hover;
|
||||
|
||||
Widget buildFrame({ bool enabled }) {
|
||||
Widget buildFrame({ required bool enabled }) {
|
||||
return Material(
|
||||
child: Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -1257,7 +1255,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Changing InkWell.enabled should not trigger TextButton setState()', (WidgetTester tester) async {
|
||||
Widget buildFrame({ bool enabled }) {
|
||||
Widget buildFrame({ required bool enabled }) {
|
||||
return Material(
|
||||
child: Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
|
||||
Reference in New Issue
Block a user