Unverified Commit 46238de8 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

[NNBD] Migrate some Material tests to NNBD (#67887)

Migrates the following files to NNBD: 
* input_decorator_test.dart
* list_tile_test.dart
* localizations_test.dart
* material_button_test.dart
* material_state_property_test.dart
* material_test.dart
* mergeable_material_test.dart
parent 244f5ab5
......@@ -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 'package:flutter/material.dart';
......@@ -14,15 +12,15 @@ import '../rendering/mock_canvas.dart';
Widget buildInputDecorator({
InputDecoration decoration = const InputDecoration(),
InputDecorationTheme inputDecorationTheme,
InputDecorationTheme? inputDecorationTheme,
TextDirection textDirection = TextDirection.ltr,
bool expands = false,
bool isEmpty = false,
bool isFocused = false,
bool isHovering = false,
TextStyle baseStyle,
TextAlignVertical textAlignVertical,
VisualDensity visualDensity,
TextStyle? baseStyle,
TextAlignVertical? textAlignVertical,
VisualDensity? visualDensity,
bool fixTextFieldOutlineLabel = false,
Widget child = const Text(
'text',
......@@ -34,7 +32,7 @@ Widget buildInputDecorator({
child: Builder(
builder: (BuildContext context) {
return Theme(
data: Theme.of(context).copyWith(
data: Theme.of(context)!.copyWith(
inputDecorationTheme: inputDecorationTheme,
visualDensity: visualDensity,
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel,
......@@ -70,7 +68,7 @@ Finder findBorderPainter() {
}
double getBorderBottom(WidgetTester tester) {
final RenderBox box = InputDecorator.containerOf(tester.element(findBorderPainter()));
final RenderBox box = InputDecorator.containerOf(tester.element(findBorderPainter()))!;
return box.size.height;
}
......@@ -85,7 +83,7 @@ Rect getLabelRect(WidgetTester tester) {
return tester.getRect(findLabel());
}
InputBorder getBorder(WidgetTester tester) {
InputBorder? getBorder(WidgetTester tester) {
if (!tester.any(findBorderPainter()))
return null;
final CustomPaint customPaint = tester.widget(findBorderPainter());
......@@ -96,21 +94,21 @@ InputBorder getBorder(WidgetTester tester) {
return border;
}
BorderSide getBorderSide(WidgetTester tester) {
return getBorder(tester)?.borderSide;
BorderSide? getBorderSide(WidgetTester tester) {
return getBorder(tester)!.borderSide;
}
BorderRadius getBorderRadius(WidgetTester tester) {
final InputBorder border = getBorder(tester);
BorderRadius? getBorderRadius(WidgetTester tester) {
final InputBorder border = getBorder(tester)!;
if (border is UnderlineInputBorder) {
return border.borderRadius;
}
return null;
}
double getBorderWeight(WidgetTester tester) => getBorderSide(tester)?.width;
double getBorderWeight(WidgetTester tester) => getBorderSide(tester)!.width;
Color getBorderColor(WidgetTester tester) => getBorderSide(tester)?.color;
Color getBorderColor(WidgetTester tester) => getBorderSide(tester)!.color;
Color getContainerColor(WidgetTester tester) {
final CustomPaint customPaint = tester.widget(findBorderPainter());
......@@ -925,10 +923,10 @@ void main() {
testWidgets('InputDecorator counter text, widget, and null', (WidgetTester tester) async {
Widget buildFrame({
InputCounterWidgetBuilder buildCounter,
String counterText,
Widget counter,
int maxLength,
InputCounterWidgetBuilder? buildCounter,
String? counterText,
Widget? counter,
int? maxLength,
}) {
return MaterialApp(
home: Scaffold(
......@@ -953,7 +951,7 @@ void main() {
// When counter, counterText, and buildCounter are null, defaults to showing
// the built-in counter.
int maxLength = 10;
int? maxLength = 10;
await tester.pumpWidget(buildFrame(maxLength: maxLength));
Finder counterFinder = find.byType(Text);
expect(counterFinder, findsOneWidget);
......@@ -966,13 +964,18 @@ void main() {
final Key buildCounterKey = UniqueKey();
const String counterText = 'I show instead of count';
final Widget counter = Text('hello', key: counterKey);
final InputCounterWidgetBuilder buildCounter =
(BuildContext context, { int currentLength, int maxLength, bool isFocused }) {
return Text(
'${currentLength.toString()} of ${maxLength.toString()}',
key: buildCounterKey,
);
};
final InputCounterWidgetBuilder buildCounter = (
BuildContext context, {
required int currentLength,
required int? maxLength,
required bool isFocused,
}) {
return Text(
'${currentLength.toString()} of ${maxLength.toString()}',
key: buildCounterKey,
);
};
await tester.pumpWidget(buildFrame(
counterText: counterText,
counter: counter,
......@@ -3021,10 +3024,10 @@ void main() {
expect(tester.getTopRight(find.text('counter')), const Offset(800.0, 64.0));
// Verify that the styles were passed along
expect(tester.widget<Text>(find.text('prefix')).style.color, prefixStyle.color);
expect(tester.widget<Text>(find.text('suffix')).style.color, suffixStyle.color);
expect(tester.widget<Text>(find.text('helper')).style.color, helperStyle.color);
expect(tester.widget<Text>(find.text('counter')).style.color, counterStyle.color);
expect(tester.widget<Text>(find.text('prefix')).style!.color, prefixStyle.color);
expect(tester.widget<Text>(find.text('suffix')).style!.color, suffixStyle.color);
expect(tester.widget<Text>(find.text('helper')).style!.color, helperStyle.color);
expect(tester.widget<Text>(find.text('counter')).style!.color, counterStyle.color);
TextStyle getLabelStyle() {
return tester.firstWidget<AnimatedDefaultTextStyle>(
......@@ -3073,7 +3076,7 @@ void main() {
final RenderObject renderer = tester.renderObject(find.byType(InputDecorator));
final Iterable<String> nodeNames = renderer.debugDescribeChildren()
.map((DiagnosticsNode node) => node.name);
.map((DiagnosticsNode node) => node.name!);
expect(nodeNames, unorderedEquals(<String>[
'container',
'counter',
......@@ -3089,7 +3092,7 @@ void main() {
]));
final Set<Object> nodeValues = Set<Object>.from(
renderer.debugDescribeChildren().map<Object>((DiagnosticsNode node) => node.value)
renderer.debugDescribeChildren().map<Object>((DiagnosticsNode node) => node.value!)
);
expect(nodeValues.length, 11);
});
......@@ -3347,7 +3350,11 @@ void main() {
const Color disabledColor = Color(0x05000000);
const Color enabledBorderColor = Color(0x61000000);
Future<void> pumpDecorator({bool hovering, bool enabled = true, bool filled = true}) async {
Future<void> pumpDecorator({
required bool hovering,
bool enabled = true,
bool filled = true,
}) async {
return await tester.pumpWidget(
buildInputDecorator(
isHovering: hovering,
......@@ -3422,7 +3429,11 @@ void main() {
const Color disabledColor = Color(0x05000000);
const Color enabledBorderColor = Color(0x61000000);
Future<void> pumpDecorator({bool focused, bool enabled = true, bool filled = true}) async {
Future<void> pumpDecorator({
required bool focused,
bool enabled = true,
bool filled = true,
}) async {
return await tester.pumpWidget(
buildInputDecorator(
isFocused: focused,
......@@ -3467,7 +3478,13 @@ void main() {
});
testWidgets('InputDecorator withdraws label when not empty or focused', (WidgetTester tester) async {
Future<void> pumpDecorator({bool focused, bool enabled = true, bool filled = false, bool empty = true, bool directional = false}) async {
Future<void> pumpDecorator({
required bool focused,
bool enabled = true,
bool filled = false,
bool empty = true,
bool directional = false,
}) async {
return await tester.pumpWidget(
buildInputDecorator(
isEmpty: empty,
......@@ -4140,8 +4157,8 @@ void main() {
testWidgets('textAlignVertical can be updated', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/56933
const String hintText = 'hint';
TextAlignVertical alignment = TextAlignVertical.top;
StateSetter setState;
TextAlignVertical? alignment = TextAlignVertical.top;
late StateSetter setState;
await tester.pumpWidget(
MaterialApp(
home: StatefulBuilder(
......@@ -4187,7 +4204,7 @@ void main() {
child: Builder(
builder: (BuildContext context) {
return Theme(
data: Theme.of(context),
data: Theme.of(context)!,
child: Align(
alignment: Alignment.topLeft,
child: TextField(
......@@ -4247,7 +4264,7 @@ void main() {
child: Builder(
builder: (BuildContext context) {
return Theme(
data: Theme.of(context).copyWith(visualDensity: visualDensity),
data: Theme.of(context)!.copyWith(visualDensity: visualDensity),
child: Center(
child: Row(
children: <Widget>[
......@@ -4320,7 +4337,7 @@ void main() {
child: Builder(
builder: (BuildContext context) {
return Theme(
data: Theme.of(context).copyWith(visualDensity: VisualDensity.compact),
data: Theme.of(context)!.copyWith(visualDensity: VisualDensity.compact),
child: Center(
child: Row(
children: <Widget>[
......
......@@ -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' as math;
import 'dart:ui';
......@@ -17,14 +15,14 @@ import '../rendering/mock_canvas.dart';
import '../widgets/semantics_tester.dart';
class TestIcon extends StatefulWidget {
const TestIcon({ Key key }) : super(key: key);
const TestIcon({ Key? key }) : super(key: key);
@override
TestIconState createState() => TestIconState();
}
class TestIconState extends State<TestIcon> {
IconThemeData iconTheme;
late IconThemeData iconTheme;
@override
Widget build(BuildContext context) {
......@@ -34,7 +32,7 @@ class TestIconState extends State<TestIcon> {
}
class TestText extends StatefulWidget {
const TestText(this.text, { Key key }) : super(key: key);
const TestText(this.text, { Key? key }) : super(key: key);
final String text;
......@@ -43,7 +41,7 @@ class TestText extends StatefulWidget {
}
class TestTextState extends State<TestText> {
TextStyle textStyle;
late TextStyle textStyle;
@override
Widget build(BuildContext context) {
......@@ -58,11 +56,11 @@ void main() {
final Key leadingKey = GlobalKey();
final Key trailingKey = GlobalKey();
bool hasSubtitle;
late bool hasSubtitle;
const double leftPadding = 10.0;
const double rightPadding = 20.0;
Widget buildFrame({ bool dense = false, bool isTwoLine = false, bool isThreeLine = false, double textScaleFactor = 1.0, double subtitleScaleFactor }) {
Widget buildFrame({ bool dense = false, bool isTwoLine = false, bool isThreeLine = false, double textScaleFactor = 1.0, double? subtitleScaleFactor }) {
hasSubtitle = isTwoLine || isThreeLine;
subtitleScaleFactor ??= textScaleFactor;
return MaterialApp(
......@@ -259,16 +257,16 @@ void main() {
final Key subtitleKey = UniqueKey();
final Key leadingKey = UniqueKey();
final Key trailingKey = UniqueKey();
ThemeData theme;
late ThemeData theme;
Widget buildFrame({
bool enabled = true,
bool dense = false,
bool selected = false,
ShapeBorder shape,
Color selectedColor,
Color iconColor,
Color textColor,
ShapeBorder? shape,
Color? selectedColor,
Color? iconColor,
Color? textColor,
}) {
return MaterialApp(
home: Material(
......@@ -281,7 +279,7 @@ void main() {
textColor: textColor,
child: Builder(
builder: (BuildContext context) {
theme = Theme.of(context);
theme = Theme.of(context)!;
return ListTile(
enabled: enabled,
selected: selected,
......@@ -304,9 +302,9 @@ void main() {
borderRadius: BorderRadius.all(Radius.circular(4.0)),
);
Color iconColor(Key key) => tester.state<TestIconState>(find.byKey(key)).iconTheme.color;
Color textColor(Key key) => tester.state<TestTextState>(find.byKey(key)).textStyle.color;
ShapeBorder inkWellBorder() => tester.widget<InkWell>(find.descendant(of: find.byType(ListTile), matching: find.byType(InkWell))).customBorder;
Color iconColor(Key key) => tester.state<TestIconState>(find.byKey(key)).iconTheme.color!;
Color textColor(Key key) => tester.state<TestTextState>(find.byKey(key)).textStyle.color!;
ShapeBorder inkWellBorder() => tester.widget<InkWell>(find.descendant(of: find.byType(ListTile), matching: find.byType(InkWell))).customBorder!;
// A selected ListTile's leading, trailing, and text get the primary color by default
await tester.pumpWidget(buildFrame(selected: true));
......@@ -1175,10 +1173,10 @@ void main() {
);
await tester.pump(); // Let the focus take effect.
final FocusNode tileNode = Focus.of(childKey.currentContext);
tileNode.requestFocus();
final FocusNode? tileNode = Focus.of(childKey.currentContext!);
tileNode!.requestFocus();
await tester.pump(); // Let the focus take effect.
expect(Focus.of(childKey.currentContext, nullOk: true).hasPrimaryFocus, isTrue);
expect(Focus.of(childKey.currentContext!, nullOk: true)!.hasPrimaryFocus, isTrue);
expect(tileNode.hasPrimaryFocus, isTrue);
await tester.pumpWidget(
......@@ -1199,7 +1197,7 @@ void main() {
);
expect(tester.binding.focusManager.primaryFocus, isNot(equals(tileNode)));
expect(Focus.of(childKey.currentContext, nullOk: true).hasPrimaryFocus, isFalse);
expect(Focus.of(childKey.currentContext!, nullOk: true)!.hasPrimaryFocus, isFalse);
});
testWidgets('ListTile can autofocus unless disabled.', (WidgetTester tester) async {
......@@ -1224,7 +1222,7 @@ void main() {
);
await tester.pump();
expect(Focus.of(childKey.currentContext, nullOk: true).hasPrimaryFocus, isTrue);
expect(Focus.of(childKey.currentContext!, nullOk: true)!.hasPrimaryFocus, isTrue);
await tester.pumpWidget(
MaterialApp(
......@@ -1245,7 +1243,7 @@ void main() {
);
await tester.pump();
expect(Focus.of(childKey.currentContext, nullOk: true).hasPrimaryFocus, isFalse);
expect(Focus.of(childKey.currentContext!, nullOk: true)!.hasPrimaryFocus, isFalse);
});
testWidgets('ListTile is focusable and has correct focus color', (WidgetTester tester) async {
......@@ -1480,7 +1478,7 @@ void main() {
await tester.pump();
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
// Test default cursor
await tester.pumpWidget(
......@@ -1498,7 +1496,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(
......@@ -1516,7 +1514,7 @@ void main() {
),
);
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
// Test default cursor when onTap or onLongPress is null
await tester.pumpWidget(
......@@ -1532,7 +1530,7 @@ void main() {
),
);
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
});
testWidgets('ListTile respects tileColor & selectedTileColor', (WidgetTester tester) async {
......@@ -1612,7 +1610,7 @@ void main() {
});
testWidgets('ListTile respects ListTileTheme\'s tileColor & selectedTileColor', (WidgetTester tester) async {
ListTileTheme theme;
late ListTileTheme theme;
bool isSelected = false;
await tester.pumpWidget(
......
......@@ -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/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
......@@ -42,10 +40,10 @@ void main() {
expect(material.elevation, 2.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(MaterialButton));
......@@ -62,10 +60,10 @@ void main() {
expect(material.elevation, 8.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 MaterialButton
......@@ -87,10 +85,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);
});
......@@ -192,7 +190,7 @@ void main() {
expect(material.elevation, equals(focusElevation));
// Hover elevation overrides focus
TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
TestGesture? gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer();
addTearDown(() => gesture?.removePointer());
await gesture.moveTo(tester.getCenter(find.byType(MaterialButton)));
......@@ -305,7 +303,7 @@ void main() {
bool wasPressed;
Finder materialButton;
Widget buildFrame({ VoidCallback onPressed, VoidCallback onLongPress }) {
Widget buildFrame({ VoidCallback? onPressed, VoidCallback? onLongPress }) {
return Directionality(
textDirection: TextDirection.ltr,
child: MaterialButton(
......@@ -395,7 +393,7 @@ void main() {
await tester.pump();
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
// Test default cursor
await tester.pumpWidget(
......@@ -410,7 +408,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(
......@@ -425,7 +423,7 @@ void main() {
),
);
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
});
// This test is very similar to the '...explicit splashColor and highlightColor' test
......@@ -654,7 +652,7 @@ void main() {
});
testWidgets('MaterialButton minWidth and height parameters', (WidgetTester tester) async {
Widget buildFrame({ double minWidth, double height, EdgeInsets padding = EdgeInsets.zero, Widget child }) {
Widget buildFrame({ double? minWidth, double? height, EdgeInsets padding = EdgeInsets.zero, Widget? child }) {
return Directionality(
textDirection: TextDirection.ltr,
child: Center(
......
......@@ -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 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:flutter/rendering.dart';
......@@ -13,7 +11,7 @@ import '../rendering/mock_canvas.dart';
import '../widgets/test_border.dart' show TestBorder;
class NotifyMaterial extends StatelessWidget {
const NotifyMaterial({ Key key }) : super(key: key);
const NotifyMaterial({ Key? key }) : super(key: key);
@override
Widget build(BuildContext context) {
LayoutChangedNotification().dispatch(context);
......@@ -380,22 +378,6 @@ void main() {
expect(find.byKey(materialKey), hasNoImmediateClip);
});
testWidgets('Null clipBehavior asserts', (WidgetTester tester) async {
final GlobalKey materialKey = GlobalKey();
Future<void> doPump() async {
await tester.pumpWidget(
Material(
key: materialKey,
type: MaterialType.transparency,
child: const SizedBox(width: 100.0, height: 100.0),
clipBehavior: null,
),
);
}
expect(() async => doPump(), throwsAssertionError);
});
testWidgets('clips to bounding rect by default given Clip.antiAlias', (WidgetTester tester) async {
final GlobalKey materialKey = GlobalKey();
await tester.pumpWidget(
......
......@@ -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';
......@@ -15,55 +13,55 @@ enum RadiusType {
Round
}
void matches(BorderRadius borderRadius, RadiusType top, RadiusType bottom) {
final Radius cardRadius = kMaterialEdges[MaterialType.card].topLeft;
void matches(BorderRadius? borderRadius, RadiusType top, RadiusType bottom) {
final Radius cardRadius = kMaterialEdges[MaterialType.card]!.topLeft;
if (top == RadiusType.Sharp) {
expect(borderRadius.topLeft, equals(Radius.zero));
expect(borderRadius.topRight, equals(Radius.zero));
expect(borderRadius?.topLeft, equals(Radius.zero));
expect(borderRadius?.topRight, equals(Radius.zero));
} else if (top == RadiusType.Shifting) {
expect(borderRadius.topLeft.x, greaterThan(0.0));
expect(borderRadius.topLeft.x, lessThan(cardRadius.x));
expect(borderRadius.topLeft.y, greaterThan(0.0));
expect(borderRadius.topLeft.y, lessThan(cardRadius.y));
expect(borderRadius.topRight.x, greaterThan(0.0));
expect(borderRadius.topRight.x, lessThan(cardRadius.x));
expect(borderRadius.topRight.y, greaterThan(0.0));
expect(borderRadius.topRight.y, lessThan(cardRadius.y));
expect(borderRadius?.topLeft.x, greaterThan(0.0));
expect(borderRadius?.topLeft.x, lessThan(cardRadius.x));
expect(borderRadius?.topLeft.y, greaterThan(0.0));
expect(borderRadius?.topLeft.y, lessThan(cardRadius.y));
expect(borderRadius?.topRight.x, greaterThan(0.0));
expect(borderRadius?.topRight.x, lessThan(cardRadius.x));
expect(borderRadius?.topRight.y, greaterThan(0.0));
expect(borderRadius?.topRight.y, lessThan(cardRadius.y));
} else {
expect(borderRadius.topLeft, equals(cardRadius));
expect(borderRadius.topRight, equals(cardRadius));
expect(borderRadius?.topLeft, equals(cardRadius));
expect(borderRadius?.topRight, equals(cardRadius));
}
if (bottom == RadiusType.Sharp) {
expect(borderRadius.bottomLeft, equals(Radius.zero));
expect(borderRadius.bottomRight, equals(Radius.zero));
expect(borderRadius?.bottomLeft, equals(Radius.zero));
expect(borderRadius?.bottomRight, equals(Radius.zero));
} else if (bottom == RadiusType.Shifting) {
expect(borderRadius.bottomLeft.x, greaterThan(0.0));
expect(borderRadius.bottomLeft.x, lessThan(cardRadius.x));
expect(borderRadius.bottomLeft.y, greaterThan(0.0));
expect(borderRadius.bottomLeft.y, lessThan(cardRadius.y));
expect(borderRadius.bottomRight.x, greaterThan(0.0));
expect(borderRadius.bottomRight.x, lessThan(cardRadius.x));
expect(borderRadius.bottomRight.y, greaterThan(0.0));
expect(borderRadius.bottomRight.y, lessThan(cardRadius.y));
expect(borderRadius?.bottomLeft.x, greaterThan(0.0));
expect(borderRadius?.bottomLeft.x, lessThan(cardRadius.x));
expect(borderRadius?.bottomLeft.y, greaterThan(0.0));
expect(borderRadius?.bottomLeft.y, lessThan(cardRadius.y));
expect(borderRadius?.bottomRight.x, greaterThan(0.0));
expect(borderRadius?.bottomRight.x, lessThan(cardRadius.x));
expect(borderRadius?.bottomRight.y, greaterThan(0.0));
expect(borderRadius?.bottomRight.y, lessThan(cardRadius.y));
} else {
expect(borderRadius.bottomLeft, equals(cardRadius));
expect(borderRadius.bottomRight, equals(cardRadius));
expect(borderRadius?.bottomLeft, equals(cardRadius));
expect(borderRadius?.bottomRight, equals(cardRadius));
}
}
// Returns the border radius decoration of an item within a MergeableMaterial.
// This depends on the exact structure of objects built by the Material and
// MergeableMaterial widgets.
BorderRadius getBorderRadius(WidgetTester tester, int index) {
BorderRadius? getBorderRadius(WidgetTester tester, int index) {
final List<Element> containers = tester.elementList(find.byType(Container))
.toList();
final Container container = containers[index].widget as Container;
final BoxDecoration boxDecoration = container.decoration as BoxDecoration;
final BoxDecoration? boxDecoration = container.decoration as BoxDecoration?;
return boxDecoration.borderRadius as BorderRadius;
return boxDecoration!.borderRadius as BorderRadius?;
}
void main() {
......@@ -221,8 +219,8 @@ void main() {
),
);
final BoxShadow boxShadow = kElevationToShadow[2][0];
final RRect rrect = kMaterialEdges[MaterialType.card].toRRect(
final BoxShadow boxShadow = kElevationToShadow[2]![0];
final RRect rrect = kMaterialEdges[MaterialType.card]!.toRRect(
const Rect.fromLTRB(0.0, 0.0, 800.0, 100.0)
);
expect(
......@@ -1201,6 +1199,6 @@ void main() {
final DecoratedBox decoratedBox = tester.widget(find.byType(DecoratedBox).last);
final BoxDecoration decoration = decoratedBox.decoration as BoxDecoration;
// Since we are getting the last DecoratedBox, it will have a Border.top.
expect(decoration.border.top.color, dividerColor);
expect(decoration.border!.top.color, dividerColor);
});
}
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