Update color assertions (#154752)

issue: https://github.com/flutter/flutter/issues/127855
This is a forward fix to help
https://github.com/flutter/engine/pull/54981 land.

It makes the following changes:
1) Removes hardcoded `Color.toString()` assumptions in asserts
1) Switches some lerp tests to use numbers that are more friendly to
uint8_t and floating point numbers
1) implements custom matchers for color
1) removes word wrapping for some asserts since it makes them fragile to
changes in `Color.toString()` invocations

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
gaaclarke 2024-09-10 15:32:40 -07:00 committed by GitHub
parent 30835d7dac
commit 203f11647f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
81 changed files with 1034 additions and 865 deletions

View File

@ -1753,6 +1753,9 @@ abstract class DiagnosticsNode {
/// `minLevel` specifies the minimum [DiagnosticLevel] for properties included
/// in the output.
///
/// `wrapWidth` specifies the column number where word wrapping will be
/// applied.
///
/// The [toStringDeep] method takes other arguments, but those are intended
/// for internal use when recursing to the descendants, and so can be ignored.
///
@ -1768,12 +1771,13 @@ abstract class DiagnosticsNode {
String? prefixOtherLines,
TextTreeConfiguration? parentConfiguration,
DiagnosticLevel minLevel = DiagnosticLevel.debug,
int wrapWidth = 65,
}) {
String result = '';
assert(() {
result = TextTreeRenderer(
minLevel: minLevel,
wrapWidth: 65,
wrapWidth: wrapWidth,
).render(
this,
prefixLineOne: prefixLineOne,
@ -3315,6 +3319,9 @@ abstract class DiagnosticableTree with Diagnosticable {
/// `minLevel` specifies the minimum [DiagnosticLevel] for properties included
/// in the output.
///
/// `wrapWidth` specifies the column number where word wrapping will be
/// applied.
///
/// The [toStringDeep] method takes other arguments, but those are intended
/// for internal use when recursing to the descendants, and so can be ignored.
///
@ -3327,8 +3334,9 @@ abstract class DiagnosticableTree with Diagnosticable {
String prefixLineOne = '',
String? prefixOtherLines,
DiagnosticLevel minLevel = DiagnosticLevel.debug,
int wrapWidth = 65,
}) {
return toDiagnosticsNode().toStringDeep(prefixLineOne: prefixLineOne, prefixOtherLines: prefixOtherLines, minLevel: minLevel);
return toDiagnosticsNode().toStringDeep(prefixLineOne: prefixLineOne, prefixOtherLines: prefixOtherLines, minLevel: minLevel, wrapWidth: wrapWidth);
}
@override
@ -3400,8 +3408,9 @@ mixin DiagnosticableTreeMixin implements DiagnosticableTree {
String prefixLineOne = '',
String? prefixOtherLines,
DiagnosticLevel minLevel = DiagnosticLevel.debug,
int wrapWidth = 65,
}) {
return toDiagnosticsNode().toStringDeep(prefixLineOne: prefixLineOne, prefixOtherLines: prefixOtherLines, minLevel: minLevel);
return toDiagnosticsNode().toStringDeep(prefixLineOne: prefixLineOne, prefixOtherLines: prefixOtherLines, minLevel: minLevel, wrapWidth: wrapWidth);
}
@override

View File

@ -4002,11 +4002,13 @@ abstract class RenderObject with DiagnosticableTreeMixin implements HitTestTarge
String prefixLineOne = '',
String? prefixOtherLines = '',
DiagnosticLevel minLevel = DiagnosticLevel.debug,
int wrapWidth = 65,
}) {
return _withDebugActiveLayoutCleared(() => super.toStringDeep(
prefixLineOne: prefixLineOne,
prefixOtherLines: prefixOtherLines,
minLevel: minLevel,
wrapWidth: wrapWidth,
));
}

View File

@ -3085,8 +3085,9 @@ class SemanticsNode with DiagnosticableTreeMixin {
String? prefixOtherLines,
DiagnosticLevel minLevel = DiagnosticLevel.debug,
DebugSemanticsDumpOrder childOrder = DebugSemanticsDumpOrder.traversalOrder,
int wrapWidth = 65,
}) {
return toDiagnosticsNode(childOrder: childOrder).toStringDeep(prefixLineOne: prefixLineOne, prefixOtherLines: prefixOtherLines, minLevel: minLevel);
return toDiagnosticsNode(childOrder: childOrder).toStringDeep(prefixLineOne: prefixLineOne, prefixOtherLines: prefixOtherLines, minLevel: minLevel, wrapWidth: wrapWidth);
}
@override

View File

@ -40,7 +40,7 @@ void main() {
(FlutterError error) => error.diagnostics.map((DiagnosticsNode node) => node.toString()),
'diagnostics',
<String>[
'Cannot lerp between "Color(0xff000000)" and "Color(0xffffffff)".',
'Cannot lerp between "${const Color(0xff000000)}" and "${const Color(0xffffffff)}".',
'The type Color might not fully implement `+`, `-`, and/or `*`. $kApiDocsLink',
'To lerp colors, consider ColorTween instead.',
],
@ -194,10 +194,10 @@ void main() {
begin: const Color(0xff000000),
end: const Color(0xffffffff),
);
expect(tween.lerp(0.0), const Color(0xff000000));
expect(tween.lerp(0.5), const Color(0xff7f7f7f));
expect(tween.lerp(0.7), const Color(0xffb2b2b2));
expect(tween.lerp(1.0), const Color(0xffffffff));
expect(tween.lerp(0.0), isSameColorAs(const Color(0xff000000)));
expect(tween.lerp(0.5), isSameColorAs(const Color(0xff7f7f7f)));
expect(tween.lerp(0.7), isSameColorAs(const Color(0xffb2b2b2)));
expect(tween.lerp(1.0), isSameColorAs(const Color(0xffffffff)));
});
test('StepTween', () {

View File

@ -130,20 +130,20 @@ void main() {
expect(
dynamicColor.toString(),
contains(
'CupertinoDynamicColor(*color = Color(0xff000000)*, '
'darkColor = Color(0xff000001), '
'highContrastColor = Color(0xff000003), '
'darkHighContrastColor = Color(0xff000005), '
'elevatedColor = Color(0xff000002), '
'darkElevatedColor = Color(0xff000004), '
'highContrastElevatedColor = Color(0xff000006), '
'darkHighContrastElevatedColor = Color(0xff000007)',
'CupertinoDynamicColor(*color = ${const Color(0xff000000)}*, '
'darkColor = ${const Color(0xff000001)}, '
'highContrastColor = ${const Color(0xff000003)}, '
'darkHighContrastColor = ${const Color(0xff000005)}, '
'elevatedColor = ${const Color(0xff000002)}, '
'darkElevatedColor = ${const Color(0xff000004)}, '
'highContrastElevatedColor = ${const Color(0xff000006)}, '
'darkHighContrastElevatedColor = ${const Color(0xff000007)}',
),
);
expect(notSoDynamicColor1.toString(), contains('CupertinoDynamicColor(*color = Color(0xff000000)*'));
expect(vibrancyDependentColor1.toString(), contains('CupertinoDynamicColor(*color = Color(0xff000001)*, darkColor = Color(0xff000000)'));
expect(contrastDependentColor1.toString(), contains('CupertinoDynamicColor(*color = Color(0xff000001)*, highContrastColor = Color(0xff000000)'));
expect(elevationDependentColor1.toString(), contains('CupertinoDynamicColor(*color = Color(0xff000001)*, elevatedColor = Color(0xff000000)'));
expect(notSoDynamicColor1.toString(), contains('CupertinoDynamicColor(*color = ${const Color(0xff000000)}*'));
expect(vibrancyDependentColor1.toString(), contains('CupertinoDynamicColor(*color = ${const Color(0xff000001)}*, darkColor = ${const Color(0xff000000)}'));
expect(contrastDependentColor1.toString(), contains('CupertinoDynamicColor(*color = ${const Color(0xff000001)}*, highContrastColor = ${const Color(0xff000000)}'));
expect(elevationDependentColor1.toString(), contains('CupertinoDynamicColor(*color = ${const Color(0xff000001)}*, elevatedColor = ${const Color(0xff000000)}'));
expect(
const CupertinoDynamicColor.withBrightnessAndContrast(
@ -153,10 +153,10 @@ void main() {
darkHighContrastColor: color3,
).toString(),
contains(
'CupertinoDynamicColor(*color = Color(0xff000000)*, '
'darkColor = Color(0xff000001), '
'highContrastColor = Color(0xff000002), '
'darkHighContrastColor = Color(0xff000003)',
'CupertinoDynamicColor(*color = ${const Color(0xff000000)}*, '
'darkColor = ${const Color(0xff000001)}, '
'highContrastColor = ${const Color(0xff000002)}, '
'darkHighContrastColor = ${const Color(0xff000003)}',
),
);
});

View File

@ -214,7 +214,7 @@ void main() {
// The transition's stack is ordered. The bottom middle is inserted first.
final RenderParagraph bottomMiddle =
tester.renderObject(flying(tester, find.text('Page 1')).first);
expect(bottomMiddle.text.style!.color, const Color(0xff000306));
expect(bottomMiddle.text.style!.color, isSameColorAs(const Color(0xff000306)));
expect(bottomMiddle.text.style!.fontWeight, FontWeight.w600);
expect(bottomMiddle.text.style!.fontFamily, 'CupertinoSystemText');
expect(bottomMiddle.text.style!.letterSpacing, -0.41);
@ -225,7 +225,7 @@ void main() {
// are flipped.
final RenderParagraph topBackLabel =
tester.renderObject(flying(tester, find.text('Page 1')).last);
expect(topBackLabel.text.style!.color, const Color(0xff000306));
expect(topBackLabel.text.style!.color, isSameColorAs(const Color(0xff000306)));
expect(topBackLabel.text.style!.fontWeight, FontWeight.w600);
expect(topBackLabel.text.style!.fontFamily, 'CupertinoSystemText');
expect(topBackLabel.text.style!.letterSpacing, -0.41);
@ -234,14 +234,14 @@ void main() {
// Move animation further a bit.
await tester.pump(const Duration(milliseconds: 200));
expect(bottomMiddle.text.style!.color, const Color(0xff005ec5));
expect(bottomMiddle.text.style!.color, isSameColorAs(const Color(0xff005ec5)));
expect(bottomMiddle.text.style!.fontWeight, FontWeight.w400);
expect(bottomMiddle.text.style!.fontFamily, 'CupertinoSystemText');
expect(bottomMiddle.text.style!.letterSpacing, -0.41);
checkOpacity(tester, flying(tester, find.text('Page 1')).first, 0.0);
expect(topBackLabel.text.style!.color, const Color(0xff005ec5));
expect(topBackLabel.text.style!.color, isSameColorAs(const Color(0xff005ec5)));
expect(topBackLabel.text.style!.fontWeight, FontWeight.w400);
expect(topBackLabel.text.style!.fontFamily, 'CupertinoSystemText');
expect(topBackLabel.text.style!.letterSpacing, -0.41);
@ -262,7 +262,7 @@ void main() {
// The transition's stack is ordered. The bottom middle is inserted first.
final RenderParagraph bottomMiddle =
tester.renderObject(flying(tester, find.text('Page 1')).first);
expect(bottomMiddle.text.style!.color, const Color(0xfff8fbff));
expect(bottomMiddle.text.style!.color, isSameColorAs(const Color(0xfff8fbff)));
expect(bottomMiddle.text.style!.fontWeight, FontWeight.w600);
expect(bottomMiddle.text.style!.fontFamily, 'CupertinoSystemText');
expect(bottomMiddle.text.style!.letterSpacing, -0.41);
@ -273,7 +273,7 @@ void main() {
// are flipped.
final RenderParagraph topBackLabel =
tester.renderObject(flying(tester, find.text('Page 1')).last);
expect(topBackLabel.text.style!.color, const Color(0xfff8fbff));
expect(topBackLabel.text.style!.color, isSameColorAs(const Color(0xfff8fbff)));
expect(topBackLabel.text.style!.fontWeight, FontWeight.w600);
expect(topBackLabel.text.style!.fontFamily, 'CupertinoSystemText');
expect(topBackLabel.text.style!.letterSpacing, -0.41);
@ -282,14 +282,14 @@ void main() {
// Move animation further a bit.
await tester.pump(const Duration(milliseconds: 200));
expect(bottomMiddle.text.style!.color, const Color(0xff409fff));
expect(bottomMiddle.text.style!.color, isSameColorAs(const Color(0xff409fff)));
expect(bottomMiddle.text.style!.fontWeight, FontWeight.w400);
expect(bottomMiddle.text.style!.fontFamily, 'CupertinoSystemText');
expect(bottomMiddle.text.style!.letterSpacing, -0.41);
checkOpacity(tester, flying(tester, find.text('Page 1')).first, 0.0);
expect(topBackLabel.text.style!.color, const Color(0xff409fff));
expect(topBackLabel.text.style!.color, isSameColorAs(const Color(0xff409fff)));
expect(topBackLabel.text.style!.fontWeight, FontWeight.w400);
expect(topBackLabel.text.style!.fontFamily, 'CupertinoSystemText');
expect(topBackLabel.text.style!.letterSpacing, -0.41);
@ -365,7 +365,7 @@ void main() {
// The transition's stack is ordered. The bottom middle is inserted first.
final RenderParagraph bottomMiddle =
tester.renderObject(flying(tester, find.text('Page 1')).first);
expect(bottomMiddle.text.style!.color, const Color(0xff000306));
expect(bottomMiddle.text.style!.color, isSameColorAs(const Color(0xff000306)));
expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).first),
@ -379,7 +379,7 @@ void main() {
// are flipped.
final RenderParagraph topBackLabel =
tester.renderObject(flying(tester, find.text('Page 1')).last);
expect(topBackLabel.text.style!.color, const Color(0xff000306));
expect(topBackLabel.text.style!.color, isSameColorAs(const Color(0xff000306)));
expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).last),
const Offset(
@ -417,7 +417,7 @@ void main() {
// The transition's stack is ordered. The bottom middle is inserted first.
final RenderParagraph bottomMiddle =
tester.renderObject(flying(tester, find.text('Page 1')).first);
expect(bottomMiddle.text.style!.color, const Color(0xff000306));
expect(bottomMiddle.text.style!.color, isSameColorAs(const Color(0xff000306)));
expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).first),
const Offset(
@ -430,7 +430,7 @@ void main() {
// are flipped.
final RenderParagraph topBackLabel =
tester.renderObject(flying(tester, find.text('Page 1')).last);
expect(topBackLabel.text.style!.color, const Color(0xff000306));
expect(topBackLabel.text.style!.color, isSameColorAs(const Color(0xff000306)));
expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).last),
const Offset(
@ -1116,7 +1116,7 @@ void main() {
// The transition's stack is ordered. The bottom large title is inserted first.
final RenderParagraph bottomLargeTitle =
tester.renderObject(flying(tester, find.text('Page 1')).first);
expect(bottomLargeTitle.text.style!.color, const Color(0xff000306));
expect(bottomLargeTitle.text.style!.color, isSameColorAs(const Color(0xff000306)));
expect(bottomLargeTitle.text.style!.fontWeight, FontWeight.w700);
expect(bottomLargeTitle.text.style!.fontFamily, 'CupertinoSystemDisplay');
expect(bottomLargeTitle.text.style!.letterSpacing, moreOrLessEquals(0.35967791542410854));
@ -1124,19 +1124,19 @@ void main() {
// The top back label is styled exactly the same way.
final RenderParagraph topBackLabel =
tester.renderObject(flying(tester, find.text('Page 1')).last);
expect(topBackLabel.text.style!.color, const Color(0xff000306));
expect(topBackLabel.text.style!.color, isSameColorAs(const Color(0xff000306)));
expect(topBackLabel.text.style!.fontWeight, FontWeight.w700);
expect(topBackLabel.text.style!.fontFamily, 'CupertinoSystemDisplay');
expect(topBackLabel.text.style!.letterSpacing, moreOrLessEquals(0.35967791542410854));
// Move animation further a bit.
await tester.pump(const Duration(milliseconds: 200));
expect(bottomLargeTitle.text.style!.color, const Color(0xff005ec5));
expect(bottomLargeTitle.text.style!.color, isSameColorAs(const Color(0xff005ec5)));
expect(bottomLargeTitle.text.style!.fontWeight, FontWeight.w500);
expect(bottomLargeTitle.text.style!.fontFamily, 'CupertinoSystemText');
expect(bottomLargeTitle.text.style!.letterSpacing, moreOrLessEquals(-0.23270857974886894));
expect(topBackLabel.text.style!.color, const Color(0xff005ec5));
expect(topBackLabel.text.style!.color, isSameColorAs(const Color(0xff005ec5)));
expect(topBackLabel.text.style!.fontWeight, FontWeight.w500);
expect(topBackLabel.text.style!.fontFamily, 'CupertinoSystemText');
expect(topBackLabel.text.style!.letterSpacing, moreOrLessEquals(-0.23270857974886894));

View File

@ -1020,28 +1020,28 @@ void main() {
await tester.tap(find.text('Child 2'));
await tester.pump();
expect(getBackgroundColor(tester, 0), CupertinoColors.activeBlue);
expect(getBackgroundColor(tester, 1), const Color(0x33007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(CupertinoColors.activeBlue));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0x33007aff)));
await tester.pump(const Duration(milliseconds: 40));
expect(getBackgroundColor(tester, 0), const Color(0xff3d9aff));
expect(getBackgroundColor(tester, 1), const Color(0x64007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xff3d9aff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0x64007aff)));
await tester.pump(const Duration(milliseconds: 40));
expect(getBackgroundColor(tester, 0), const Color(0xff7bbaff));
expect(getBackgroundColor(tester, 1), const Color(0x95007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xff7bbaff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0x95007aff)));
await tester.pump(const Duration(milliseconds: 40));
expect(getBackgroundColor(tester, 0), const Color(0xffb9daff));
expect(getBackgroundColor(tester, 1), const Color(0xc7007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xffb9daff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0xc7007aff)));
await tester.pump(const Duration(milliseconds: 40));
expect(getBackgroundColor(tester, 0), const Color(0xfff7faff));
expect(getBackgroundColor(tester, 1), const Color(0xf8007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xfff7faff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0xf8007aff)));
await tester.pump(const Duration(milliseconds: 40));
expect(getBackgroundColor(tester, 0), isSameColorAs(CupertinoColors.white));
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.activeBlue));
});
testWidgets('Animation is correct when widget is rebuilt', (WidgetTester tester) async {
@ -1087,8 +1087,8 @@ void main() {
},
),
);
expect(getBackgroundColor(tester, 0), CupertinoColors.activeBlue);
expect(getBackgroundColor(tester, 1), const Color(0x33007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(CupertinoColors.activeBlue));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0x33007aff)));
await tester.pumpWidget(
StatefulBuilder(
@ -1108,8 +1108,8 @@ void main() {
),
duration: const Duration(milliseconds: 40),
);
expect(getBackgroundColor(tester, 0), const Color(0xff3d9aff));
expect(getBackgroundColor(tester, 1), const Color(0x64007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xff3d9aff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0x64007aff)));
await tester.pumpWidget(
StatefulBuilder(
@ -1129,8 +1129,8 @@ void main() {
),
duration: const Duration(milliseconds: 40),
);
expect(getBackgroundColor(tester, 0), const Color(0xff7bbaff));
expect(getBackgroundColor(tester, 1), const Color(0x95007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xff7bbaff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0x95007aff)));
await tester.pumpWidget(
StatefulBuilder(
@ -1150,8 +1150,8 @@ void main() {
),
duration: const Duration(milliseconds: 40),
);
expect(getBackgroundColor(tester, 0), const Color(0xffb9daff));
expect(getBackgroundColor(tester, 1), const Color(0xc7007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xffb9daff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0xc7007aff)));
await tester.pumpWidget(
StatefulBuilder(
@ -1171,8 +1171,8 @@ void main() {
),
duration: const Duration(milliseconds: 40),
);
expect(getBackgroundColor(tester, 0), const Color(0xfff7faff));
expect(getBackgroundColor(tester, 1), const Color(0xf8007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xfff7faff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0xf8007aff)));
await tester.pumpWidget(
StatefulBuilder(
@ -1193,7 +1193,7 @@ void main() {
duration: const Duration(milliseconds: 40),
);
expect(getBackgroundColor(tester, 0), isSameColorAs(CupertinoColors.white));
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.activeBlue));
});
testWidgets('Multiple segments are pressed', (WidgetTester tester) async {
@ -1272,12 +1272,12 @@ void main() {
await tester.tap(find.text('B'));
await tester.pump();
expect(getBackgroundColor(tester, 0), CupertinoColors.activeBlue);
expect(getBackgroundColor(tester, 1), const Color(0x33007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(CupertinoColors.activeBlue));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0x33007aff)));
await tester.pump(const Duration(milliseconds: 40));
expect(getBackgroundColor(tester, 0), const Color(0xff3d9aff));
expect(getBackgroundColor(tester, 1), const Color(0x64007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xff3d9aff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0x64007aff)));
// While A to B transition is occurring, press on C.
await tester.tap(find.text('C'));
@ -1285,24 +1285,24 @@ void main() {
await tester.pump();
// A and B are now both transitioning to white.
expect(getBackgroundColor(tester, 0), const Color(0xff3d9aff));
expect(getBackgroundColor(tester, 1), const Color(0xffc1deff));
expect(getBackgroundColor(tester, 2), const Color(0x33007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xff3d9aff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0xffc1deff)));
expect(getBackgroundColor(tester, 2), isSameColorAs(const Color(0x33007aff)));
await tester.pump(const Duration(milliseconds: 40));
// B background color has reached unselected state.
expect(getBackgroundColor(tester, 0), const Color(0xff7bbaff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xff7bbaff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white));
expect(getBackgroundColor(tester, 2), const Color(0x64007aff));
expect(getBackgroundColor(tester, 2), isSameColorAs(const Color(0x64007aff)));
await tester.pump(const Duration(milliseconds: 100));
// A background color has reached unselected state.
expect(getBackgroundColor(tester, 0), isSameColorAs(CupertinoColors.white));
expect(getBackgroundColor(tester, 2), const Color(0xe0007aff));
expect(getBackgroundColor(tester, 2), isSameColorAs(const Color(0xe0007aff)));
await tester.pump(const Duration(milliseconds: 40));
// C background color has reached selected state.
expect(getBackgroundColor(tester, 2), CupertinoColors.activeBlue);
expect(getBackgroundColor(tester, 2), isSameColorAs(CupertinoColors.activeBlue));
});
testWidgets('Segment is selected while it is transitioning to unselected state', (WidgetTester tester) async {
@ -1311,12 +1311,12 @@ void main() {
await tester.tap(find.text('Child 2'));
await tester.pump();
expect(getBackgroundColor(tester, 0), CupertinoColors.activeBlue);
expect(getBackgroundColor(tester, 1), const Color(0x33007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(CupertinoColors.activeBlue));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0x33007aff)));
await tester.pump(const Duration(milliseconds: 40));
expect(getBackgroundColor(tester, 0), const Color(0xff3d9aff));
expect(getBackgroundColor(tester, 1), const Color(0x64007aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xff3d9aff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0x64007aff)));
// While A to B transition is occurring, press on A again.
await tester.tap(find.text('Child 1'));
@ -1324,12 +1324,12 @@ void main() {
await tester.pump();
// Both transitions start to reverse.
expect(getBackgroundColor(tester, 0), const Color(0xcd007aff));
expect(getBackgroundColor(tester, 1), const Color(0xffc1deff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xcd007aff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0xffc1deff)));
await tester.pump(const Duration(milliseconds: 40));
// A and B finish transitioning.
expect(getBackgroundColor(tester, 0), CupertinoColors.activeBlue);
expect(getBackgroundColor(tester, 0), isSameColorAs(CupertinoColors.activeBlue));
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white));
});
@ -1416,14 +1416,14 @@ void main() {
await tester.tap(find.text('B'));
await tester.pump();
expect(getBackgroundColor(tester, 1), const Color(0x33007aff));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0x33007aff)));
expect(getChildCount(tester), 2);
await tester.pump(const Duration(milliseconds: 40));
expect(getBackgroundColor(tester, 1), const Color(0x64007aff));
expect(getBackgroundColor(tester, 1), isSameColorAs(const Color(0x64007aff)));
await tester.pump(const Duration(milliseconds: 150));
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.activeBlue));
});
testWidgets('Remove currently animating segment', (WidgetTester tester) async {
@ -1465,11 +1465,11 @@ void main() {
expect(getChildCount(tester), 2);
await tester.pump(const Duration(milliseconds: 40));
expect(getBackgroundColor(tester, 0), const Color(0xff3d9aff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xff3d9aff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white));
await tester.pump(const Duration(milliseconds: 40));
expect(getBackgroundColor(tester, 0), const Color(0xff7bbaff));
expect(getBackgroundColor(tester, 0), isSameColorAs(const Color(0xff7bbaff)));
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white));
await tester.pump(const Duration(milliseconds: 100));

View File

@ -1591,7 +1591,7 @@ void main() {
expect(simple.isFiltered(DiagnosticLevel.info), isFalse);
expect(simple.value, equals(color));
expect(simple.propertyType, equals(Color));
expect(simple.toString(), equals('name: Color(0xffffffff)'));
expect(simple.toString(), equals('name: ${const Color(0xffffffff)}'));
validatePropertyJsonSerialization(simple);
});
@ -1795,7 +1795,7 @@ void main() {
expect(objectsProperty.isFiltered(DiagnosticLevel.info), isFalse);
expect(
objectsProperty.toString(),
equals('objects: Rect.fromLTRB(0.0, 0.0, 20.0, 20.0), Color(0xffffffff)'),
equals('objects: Rect.fromLTRB(0.0, 0.0, 20.0, 20.0), ${const Color(0xffffffff)}'),
);
validateIterablePropertyJsonSerialization(objectsProperty);
@ -1811,15 +1811,15 @@ void main() {
equals(
'objects:\n'
'Rect.fromLTRB(0.0, 0.0, 20.0, 20.0)\n'
'Color(0xffffffff)',
'${const Color(0xffffffff)}',
),
);
expect(
multiLineProperty.toStringDeep(),
multiLineProperty.toStringDeep(wrapWidth: 100),
equals(
'objects:\n'
' Rect.fromLTRB(0.0, 0.0, 20.0, 20.0)\n'
' Color(0xffffffff)\n',
' ${const Color(0xffffffff)}\n',
),
);
validateIterablePropertyJsonSerialization(multiLineProperty);
@ -1827,12 +1827,12 @@ void main() {
expect(
TestTree(
properties: <DiagnosticsNode>[multiLineProperty],
).toStringDeep(),
).toStringDeep(wrapWidth: 100),
equalsIgnoringHashCodes(
'TestTree#00000\n'
' objects:\n'
' Rect.fromLTRB(0.0, 0.0, 20.0, 20.0)\n'
' Color(0xffffffff)\n',
' ${const Color(0xffffffff)}\n',
),
);
@ -1842,7 +1842,7 @@ void main() {
style: DiagnosticsTreeStyle.singleLine,
).toStringDeep(),
equalsIgnoringHashCodes(
'TestTree#00000(objects: [Rect.fromLTRB(0.0, 0.0, 20.0, 20.0), Color(0xffffffff)], foo: 42)',
'TestTree#00000(objects: [Rect.fromLTRB(0.0, 0.0, 20.0, 20.0), ${const Color(0xffffffff)}], foo: 42)',
),
);
@ -1859,21 +1859,21 @@ void main() {
expect(objectProperty.isFiltered(DiagnosticLevel.info), isFalse);
expect(
objectProperty.toString(),
equals('object: Color(0xffffffff)'),
equals('object: ${const Color(0xffffffff)}'),
);
expect(
objectProperty.toStringDeep(),
equals('object: Color(0xffffffff)\n'),
objectProperty.toStringDeep(wrapWidth: 100),
equals('object: ${const Color(0xffffffff)}\n'),
);
validateIterablePropertyJsonSerialization(objectProperty);
expect(
TestTree(
name: 'root',
properties: <DiagnosticsNode>[objectProperty],
).toStringDeep(),
).toStringDeep(wrapWidth: 120),
equalsIgnoringHashCodes(
'TestTree#00000\n'
' object: Color(0xffffffff)\n',
' object: ${const Color(0xffffffff)}\n',
),
);
});

View File

@ -327,14 +327,15 @@ void main() {
});
}
PaintColorMatcher hasColor(int color) {
return PaintColorMatcher(color);
PaintColorMatcher hasColor(int color, {double threshold = 1/255}) {
return PaintColorMatcher(color, threshold);
}
class PaintColorMatcher extends Matcher {
const PaintColorMatcher(this.expectedColor);
const PaintColorMatcher(this.expectedColor, this.threshold);
final int expectedColor;
final double threshold;
@override
Description describe(Description description) =>
@ -343,6 +344,11 @@ class PaintColorMatcher extends Matcher {
@override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
final Paint actualPaint = item as Paint;
return actualPaint.color == Color(expectedColor);
final Color expected = Color(expectedColor);
return actualPaint.color.colorSpace == expected.colorSpace &&
(actualPaint.color.a - expected.a).abs() < threshold &&
(actualPaint.color.r - expected.r).abs() < threshold &&
(actualPaint.color.g - expected.g).abs() < threshold &&
(actualPaint.color.b - expected.b).abs() < threshold;
}
}

View File

@ -1087,19 +1087,19 @@ void main() {
description,
equalsIgnoringHashCodes(
<String>[
'backgroundColor: Color(0xff000000)',
'foregroundColor: Color(0xff000001)',
'backgroundColor: ${const Color(0xff000000)}',
'foregroundColor: ${const Color(0xff000001)}',
'elevation: 8.0',
'scrolledUnderElevation: 3.0',
'shadowColor: Color(0xff000002)',
'surfaceTintColor: Color(0xff000003)',
'shadowColor: ${const Color(0xff000002)}',
'surfaceTintColor: ${const Color(0xff000003)}',
'shape: StadiumBorder(BorderSide(width: 0.0, style: none))',
'iconTheme: IconThemeData#00000(color: Color(0xff000004))',
'iconTheme: IconThemeData#00000(color: ${const Color(0xff000004)})',
'centerTitle: true',
'titleSpacing: 40.0',
'toolbarHeight: 96.0',
'toolbarTextStyle: TextStyle(inherit: true, color: Color(0xff000005))',
'titleTextStyle: TextStyle(inherit: true, color: Color(0xff000006))'
'toolbarTextStyle: TextStyle(inherit: true, color: ${const Color(0xff000005)})',
'titleTextStyle: TextStyle(inherit: true, color: ${const Color(0xff000006)})'
],
),
);

View File

@ -1590,7 +1590,7 @@ void main() {
// Test the initial Scaffold background color.
await tester.pumpWidget(buildWidget());
expect(tester.widget<Material>(find.byType(Material)).color, lightTheme.colorScheme.surface);
expect(tester.widget<Material>(find.byType(Material)).color, isSameColorAs(lightTheme.colorScheme.surface));
// Test the Scaffold background color animation from light to dark theme.
await tester.pumpWidget(buildWidget(themeMode: ThemeMode.dark));
@ -1598,13 +1598,13 @@ void main() {
await tester.pump(const Duration(milliseconds: 50)); // Advance animation by 50 milliseconds.
// Scaffold background color is slightly updated.
expect(tester.widget<Material>(find.byType(Material)).color, const Color(0xffc3bdc5));
expect(tester.widget<Material>(find.byType(Material)).color, isSameColorAs(const Color(0xffc3bdc5)));
// Let the animation finish.
await tester.pumpAndSettle();
// Scaffold background color is fully updated to dark theme.
expect(tester.widget<Material>(find.byType(Material)).color, darkTheme.colorScheme.surface);
expect(tester.widget<Material>(find.byType(Material)).color, isSameColorAs(darkTheme.colorScheme.surface));
// Reset to light theme to compare the Scaffold background color animation
// with the default animation curve.
@ -1621,13 +1621,13 @@ void main() {
// Scaffold background color is slightly updated but with a different
// color than the default animation curve.
expect(tester.widget<Material>(find.byType(Material)).color, const Color(0xffe7e1e9));
expect(tester.widget<Material>(find.byType(Material)).color, isSameColorAs(const Color(0xffe7e1e9)));
// Let the animation finish.
await tester.pumpAndSettle();
// Scaffold background color is fully updated to dark theme.
expect(tester.widget<Material>(find.byType(Material)).color, darkTheme.colorScheme.surface);
expect(tester.widget<Material>(find.byType(Material)).color, isSameColorAs(darkTheme.colorScheme.surface));
// Switch from dark to light theme with overridden animation duration.
await tester.pumpWidget(buildWidget(animationStyle: AnimationStyle.noAnimation));
@ -1635,7 +1635,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 1));
expect(tester.widget<Material>(find.byType(Material)).color, isNot(darkTheme.colorScheme.surface));
expect(tester.widget<Material>(find.byType(Material)).color, lightTheme.colorScheme.surface);
expect(tester.widget<Material>(find.byType(Material)).color, isSameColorAs(lightTheme.colorScheme.surface));
});
testWidgets('AnimationStyle.noAnimation removes AnimatedTheme from the tree', (WidgetTester tester) async {

View File

@ -61,8 +61,8 @@ void main() {
.toList();
expect(description, <String>[
'backgroundColor: Color(0xfffffff0)',
'textColor: Color(0xfffffff1)',
'backgroundColor: ${const Color(0xfffffff0)}',
'textColor: ${const Color(0xfffffff1)}',
'smallSize: 1.0',
'largeSize: 2.0',
'textStyle: TextStyle(inherit: true, size: 4.0)',

View File

@ -55,11 +55,11 @@ void main() {
.toList();
expect(description, <String>[
'backgroundColor: Color(0xfffffff0)',
'surfaceTintColor: Color(0xfffffff1)',
'shadowColor: Color(0xfffffff2)',
'dividerColor: Color(0xfffffff3)',
'contentTextStyle: TextStyle(inherit: true, color: Color(0xfffffff4))',
'backgroundColor: ${const Color(0xfffffff0)}',
'surfaceTintColor: ${const Color(0xfffffff1)}',
'shadowColor: ${const Color(0xfffffff2)}',
'dividerColor: ${const Color(0xfffffff3)}',
'contentTextStyle: TextStyle(inherit: true, color: ${const Color(0xfffffff4)})',
'elevation: 4.0',
'padding: EdgeInsets.all(20.0)',
'leadingPadding: EdgeInsets(8.0, 0.0, 0.0, 0.0)',

View File

@ -345,7 +345,7 @@ void main() {
final PhysicalShape physicalShape = tester.widget(find.byType(PhysicalShape).at(0));
// For the default dark theme the overlay color for elevation 8 is 0xFF2D2D2D
expect(physicalShape.color, const Color(0xFF2D2D2D));
expect(physicalShape.color, isSameColorAs(const Color(0xFF2D2D2D)));
});
testWidgets('Material3 - Dark theme applies an elevation overlay color', (WidgetTester tester) async {

View File

@ -86,7 +86,7 @@ void main() {
.map((DiagnosticsNode node) => node.toString())
.toList();
expect(description[0], 'backgroundColor: Color(0xfffffff0)');
expect(description[0], 'backgroundColor: ${const Color(0xfffffff0)}');
expect(description[1], 'elevation: 10.0');
// Ignore instance address for IconThemeData.
@ -95,8 +95,8 @@ void main() {
expect(description[3].contains('unselectedIconTheme: IconThemeData'), isTrue);
expect(description[3].contains('(size: 2.0)'), isTrue);
expect(description[4], 'selectedItemColor: Color(0xfffffff1)');
expect(description[5], 'unselectedItemColor: Color(0xfffffff2)');
expect(description[4], 'selectedItemColor: ${const Color(0xfffffff1)}');
expect(description[5], 'unselectedItemColor: ${const Color(0xfffffff2)}');
expect(description[6], 'selectedLabelStyle: TextStyle(inherit: true, size: 3.0)');
expect(description[7], 'unselectedLabelStyle: TextStyle(inherit: true, size: 4.0)');
expect(description[8], 'showSelectedLabels: true');

View File

@ -67,11 +67,11 @@ void main() {
.toList();
expect(description, <String>[
'backgroundColor: Color(0xffffffff)',
'backgroundColor: ${const Color(0xffffffff)}',
'elevation: 2.0',
'shadowColor: Color(0xff00ffff)',
'shadowColor: ${const Color(0xff00ffff)}',
'shape: RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.circular(2.0))',
'dragHandleColor: Color(0xffffffff)',
'dragHandleColor: ${const Color(0xffffffff)}',
'dragHandleSize: Size(20.0, 20.0)',
'clipBehavior: Clip.antiAlias',
'constraints: BoxConstraints(200.0<=w<=640.0, 0.0<=h<=Infinity)',

View File

@ -90,18 +90,18 @@ void main() {
expect(description, <String>[
'textStyle: WidgetStatePropertyAll(TextStyle(inherit: true, size: 10.0))',
'backgroundColor: WidgetStatePropertyAll(Color(0xfffffff1))',
'foregroundColor: WidgetStatePropertyAll(Color(0xfffffff2))',
'overlayColor: WidgetStatePropertyAll(Color(0xfffffff3))',
'shadowColor: WidgetStatePropertyAll(Color(0xfffffff4))',
'surfaceTintColor: WidgetStatePropertyAll(Color(0xfffffff5))',
'backgroundColor: WidgetStatePropertyAll(${const Color(0xfffffff1)})',
'foregroundColor: WidgetStatePropertyAll(${const Color(0xfffffff2)})',
'overlayColor: WidgetStatePropertyAll(${const Color(0xfffffff3)})',
'shadowColor: WidgetStatePropertyAll(${const Color(0xfffffff4)})',
'surfaceTintColor: WidgetStatePropertyAll(${const Color(0xfffffff5)})',
'elevation: WidgetStatePropertyAll(1.5)',
'padding: WidgetStatePropertyAll(EdgeInsets.all(1.0))',
'minimumSize: WidgetStatePropertyAll(Size(1.0, 2.0))',
'maximumSize: WidgetStatePropertyAll(Size(100.0, 200.0))',
'iconColor: WidgetStatePropertyAll(Color(0xfffffff6))',
'iconColor: WidgetStatePropertyAll(${const Color(0xfffffff6)})',
'iconSize: WidgetStatePropertyAll(48.1)',
'side: WidgetStatePropertyAll(BorderSide(color: Color(0xfffffff6), width: 4.0))',
'side: WidgetStatePropertyAll(BorderSide(color: ${const Color(0xfffffff6)}, width: 4.0))',
'shape: WidgetStatePropertyAll(StadiumBorder(BorderSide(width: 0.0, style: none)))',
'mouseCursor: WidgetStatePropertyAll(SystemMouseCursor(forbidden))',
'tapTargetSize: shrinkWrap',

View File

@ -74,9 +74,9 @@ void main() {
.toList();
expect(description[0], 'clipBehavior: Clip.antiAlias');
expect(description[1], 'color: MaterialColor(primary value: Color(0xffffc107))');
expect(description[2], 'shadowColor: MaterialColor(primary value: Color(0xff4caf50))');
expect(description[3], 'surfaceTintColor: MaterialColor(primary value: Color(0xff9c27b0))');
expect(description[1], 'color: MaterialColor(primary value: ${const Color(0xffffc107)})');
expect(description[2], 'shadowColor: MaterialColor(primary value: ${const Color(0xff4caf50)})');
expect(description[3], 'surfaceTintColor: MaterialColor(primary value: ${const Color(0xff9c27b0)})');
expect(description[4], 'elevation: 10.5');
expect(description[5], 'margin: EdgeInsets.all(20.5)');
expect(description[6], 'shape: BeveledRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.circular(20.5))');

View File

@ -72,9 +72,9 @@ void main() {
description,
equalsIgnoringHashCodes(<String>[
'mouseCursor: WidgetStatePropertyAll(SystemMouseCursor(click))',
'fillColor: WidgetStatePropertyAll(Color(0xfffffff0))',
'checkColor: WidgetStatePropertyAll(Color(0xfffffff1))',
'overlayColor: WidgetStatePropertyAll(Color(0xfffffff2))',
'fillColor: WidgetStatePropertyAll(${const Color(0xfffffff0)})',
'checkColor: WidgetStatePropertyAll(${const Color(0xfffffff1)})',
'overlayColor: WidgetStatePropertyAll(${const Color(0xfffffff2)})',
'splashRadius: 1.0',
'materialTapTargetSize: MaterialTapTargetSize.shrinkWrap',
'visualDensity: VisualDensity#00000(h: 0.0, v: 0.0)',
@ -428,9 +428,9 @@ void main() {
);
final CheckboxThemeData lerped = CheckboxThemeData.lerp(theme, null, 0.5);
expect(lerped.fillColor!.resolve(<MaterialState>{}), const Color(0x80fffff0));
expect(lerped.checkColor!.resolve(<MaterialState>{}), const Color(0x80fffff1));
expect(lerped.overlayColor!.resolve(<MaterialState>{}), const Color(0x80fffff2));
expect(lerped.fillColor!.resolve(<MaterialState>{}), isSameColorAs(const Color(0x80fffff0)));
expect(lerped.checkColor!.resolve(<MaterialState>{}), isSameColorAs(const Color(0x80fffff1)));
expect(lerped.overlayColor!.resolve(<MaterialState>{}), isSameColorAs(const Color(0x80fffff2)));
expect(lerped.splashRadius, 1.5);
expect(lerped.materialTapTargetSize, null);
expect(lerped.visualDensity, null);
@ -462,9 +462,9 @@ void main() {
);
final CheckboxThemeData lerped = CheckboxThemeData.lerp(themeA, themeB, 0.5);
expect(lerped.fillColor!.resolve(<MaterialState>{}), const Color(0xfffffff1));
expect(lerped.checkColor!.resolve(<MaterialState>{}), const Color(0xfffffff2));
expect(lerped.overlayColor!.resolve(<MaterialState>{}), const Color(0xfffffff3));
expect(lerped.fillColor!.resolve(<MaterialState>{}), isSameColorAs(const Color(0xfffffff1)));
expect(lerped.checkColor!.resolve(<MaterialState>{}), isSameColorAs(const Color(0xfffffff2)));
expect(lerped.overlayColor!.resolve(<MaterialState>{}), isSameColorAs(const Color(0xfffffff3)));
expect(lerped.splashRadius, 6);
expect(lerped.materialTapTargetSize, MaterialTapTargetSize.shrinkWrap);
expect(lerped.visualDensity, const VisualDensity(vertical: 2.0, horizontal: 2.0));

View File

@ -136,17 +136,17 @@ void main() {
.toList();
expect(description, equalsIgnoringHashCodes(<String>[
'color: WidgetStatePropertyAll(Color(0xfffffff0))',
'backgroundColor: Color(0xfffffff1)',
'deleteIconColor: Color(0xfffffff2)',
'disabledColor: Color(0xfffffff3)',
'selectedColor: Color(0xfffffff4)',
'secondarySelectedColor: Color(0xfffffff5)',
'shadowColor: Color(0xfffffff6)',
'surfaceTintColor: Color(0xfffffff7)',
'selectedShadowColor: Color(0xfffffff8)',
'color: WidgetStatePropertyAll(${const Color(0xfffffff0)})',
'backgroundColor: ${const Color(0xfffffff1)}',
'deleteIconColor: ${const Color(0xfffffff2)}',
'disabledColor: ${const Color(0xfffffff3)}',
'selectedColor: ${const Color(0xfffffff4)}',
'secondarySelectedColor: ${const Color(0xfffffff5)}',
'shadowColor: ${const Color(0xfffffff6)}',
'surfaceTintColor: ${const Color(0xfffffff7)}',
'selectedShadowColor: ${const Color(0xfffffff8)}',
'showCheckmark: true',
'checkMarkColor: Color(0xfffffff9)',
'checkMarkColor: ${const Color(0xfffffff9)}',
'labelPadding: EdgeInsets.all(1.0)',
'padding: EdgeInsets.all(2.0)',
'side: BorderSide(width: 10.0)',
@ -156,7 +156,7 @@ void main() {
'brightness: dark',
'elevation: 5.0',
'pressElevation: 6.0',
'iconTheme: IconThemeData#00000(color: Color(0xffffff10))',
'iconTheme: IconThemeData#00000(color: ${const Color(0xffffff10)})',
'avatarBoxConstraints: BoxConstraints(unconstrained)',
'deleteIconBoxConstraints: BoxConstraints(unconstrained)',
]));
@ -636,115 +636,115 @@ void main() {
final ChipThemeData lerp = ChipThemeData.lerp(chipThemeBlack, chipThemeWhite, 0.5)!;
const Color middleGrey = Color(0xff7f7f7f);
expect(lerp.backgroundColor, equals(middleGrey.withAlpha(0x1f)));
expect(lerp.deleteIconColor, equals(middleGrey.withAlpha(0xde)));
expect(lerp.disabledColor, equals(middleGrey.withAlpha(0x0c)));
expect(lerp.selectedColor, equals(middleGrey.withAlpha(0x3d)));
expect(lerp.secondarySelectedColor, equals(middleGrey.withAlpha(0x3d)));
expect(lerp.shadowColor, equals(middleGrey));
expect(lerp.surfaceTintColor, equals(middleGrey));
expect(lerp.selectedShadowColor, equals(middleGrey));
expect(lerp.backgroundColor, isSameColorAs(middleGrey.withAlpha(0x1f)));
expect(lerp.deleteIconColor, isSameColorAs(middleGrey.withAlpha(0xde)));
expect(lerp.disabledColor, isSameColorAs(middleGrey.withAlpha(0x0c)));
expect(lerp.selectedColor, isSameColorAs(middleGrey.withAlpha(0x3d)));
expect(lerp.secondarySelectedColor, isSameColorAs(middleGrey.withAlpha(0x3d)));
expect(lerp.shadowColor, isSameColorAs(middleGrey));
expect(lerp.surfaceTintColor, isSameColorAs(middleGrey));
expect(lerp.selectedShadowColor, isSameColorAs(middleGrey));
expect(lerp.showCheckmark, equals(true));
expect(lerp.labelPadding, equals(const EdgeInsets.all(4.0)));
expect(lerp.padding, equals(const EdgeInsets.all(3.0)));
expect(lerp.side!.color, equals(middleGrey));
expect(lerp.side!.color, isSameColorAs(middleGrey));
expect(lerp.shape, isA<BeveledRectangleBorder>());
expect(lerp.labelStyle?.color, equals(middleGrey.withAlpha(0xde)));
expect(lerp.secondaryLabelStyle?.color, equals(middleGrey.withAlpha(0xde)));
expect(lerp.labelStyle?.color, isSameColorAs(middleGrey.withAlpha(0xde)));
expect(lerp.secondaryLabelStyle?.color, isSameColorAs(middleGrey.withAlpha(0xde)));
expect(lerp.brightness, equals(Brightness.light));
expect(lerp.elevation, 3.0);
expect(lerp.pressElevation, 7.0);
expect(lerp.checkmarkColor, equals(middleGrey));
expect(lerp.checkmarkColor, isSameColorAs(middleGrey));
expect(lerp.iconTheme, const IconThemeData(size: 24.0));
expect(ChipThemeData.lerp(null, null, 0.25), isNull);
final ChipThemeData lerpANull25 = ChipThemeData.lerp(null, chipThemeWhite, 0.25)!;
expect(lerpANull25.backgroundColor, equals(Colors.black.withAlpha(0x08)));
expect(lerpANull25.deleteIconColor, equals(Colors.black.withAlpha(0x38)));
expect(lerpANull25.disabledColor, equals(Colors.black.withAlpha(0x03)));
expect(lerpANull25.selectedColor, equals(Colors.black.withAlpha(0x0f)));
expect(lerpANull25.secondarySelectedColor, equals(Colors.white.withAlpha(0x0f)));
expect(lerpANull25.shadowColor, equals(Colors.white.withAlpha(0x40)));
expect(lerpANull25.surfaceTintColor, equals(Colors.white.withAlpha(0x40)));
expect(lerpANull25.selectedShadowColor, equals(Colors.white.withAlpha(0x40)));
expect(lerpANull25.backgroundColor, isSameColorAs(Colors.black.withAlpha(0x08)));
expect(lerpANull25.deleteIconColor, isSameColorAs(Colors.black.withAlpha(0x38)));
expect(lerpANull25.disabledColor, isSameColorAs(Colors.black.withAlpha(0x03)));
expect(lerpANull25.selectedColor, isSameColorAs(Colors.black.withAlpha(0x0f)));
expect(lerpANull25.secondarySelectedColor, isSameColorAs(Colors.white.withAlpha(0x0f)));
expect(lerpANull25.shadowColor, isSameColorAs(Colors.white.withAlpha(0x40)));
expect(lerpANull25.surfaceTintColor, isSameColorAs(Colors.white.withAlpha(0x40)));
expect(lerpANull25.selectedShadowColor, isSameColorAs(Colors.white.withAlpha(0x40)));
expect(lerpANull25.showCheckmark, equals(true));
expect(lerpANull25.labelPadding, equals(const EdgeInsets.only(top: 2.0, bottom: 2.0)));
expect(lerpANull25.padding, equals(const EdgeInsets.all(0.5)));
expect(lerpANull25.side!.color, equals(Colors.white.withAlpha(0x3f)));
expect(lerpANull25.side!.color, isSameColorAs(Colors.white.withAlpha(0x3f)));
expect(lerpANull25.shape, isA<BeveledRectangleBorder>());
expect(lerpANull25.labelStyle?.color, equals(Colors.black.withAlpha(0x38)));
expect(lerpANull25.secondaryLabelStyle?.color, equals(Colors.white.withAlpha(0x38)));
expect(lerpANull25.labelStyle?.color, isSameColorAs(Colors.black.withAlpha(0x38)));
expect(lerpANull25.secondaryLabelStyle?.color, isSameColorAs(Colors.white.withAlpha(0x38)));
expect(lerpANull25.brightness, equals(Brightness.light));
expect(lerpANull25.elevation, 1.25);
expect(lerpANull25.pressElevation, 2.5);
expect(lerpANull25.checkmarkColor, equals(Colors.white.withAlpha(0x40)));
expect(lerpANull25.checkmarkColor, isSameColorAs(Colors.white.withAlpha(0x40)));
expect(lerpANull25.iconTheme, const IconThemeData(size: 5.5));
final ChipThemeData lerpANull75 = ChipThemeData.lerp(null, chipThemeWhite, 0.75)!;
expect(lerpANull75.backgroundColor, equals(Colors.black.withAlpha(0x17)));
expect(lerpANull75.deleteIconColor, equals(Colors.black.withAlpha(0xa7)));
expect(lerpANull75.disabledColor, equals(Colors.black.withAlpha(0x09)));
expect(lerpANull75.selectedColor, equals(Colors.black.withAlpha(0x2e)));
expect(lerpANull75.secondarySelectedColor, equals(Colors.white.withAlpha(0x2e)));
expect(lerpANull75.shadowColor, equals(Colors.white.withAlpha(0xbf)));
expect(lerpANull75.surfaceTintColor, equals(Colors.white.withAlpha(0xbf)));
expect(lerpANull75.selectedShadowColor, equals(Colors.white.withAlpha(0xbf)));
expect(lerpANull75.backgroundColor, isSameColorAs(Colors.black.withAlpha(0x17)));
expect(lerpANull75.deleteIconColor, isSameColorAs(Colors.black.withAlpha(0xa7)));
expect(lerpANull75.disabledColor, isSameColorAs(Colors.black.withAlpha(0x09)));
expect(lerpANull75.selectedColor, isSameColorAs(Colors.black.withAlpha(0x2e)));
expect(lerpANull75.secondarySelectedColor, isSameColorAs(Colors.white.withAlpha(0x2e)));
expect(lerpANull75.shadowColor, isSameColorAs(Colors.white.withAlpha(0xbf)));
expect(lerpANull75.surfaceTintColor, isSameColorAs(Colors.white.withAlpha(0xbf)));
expect(lerpANull75.selectedShadowColor, isSameColorAs(Colors.white.withAlpha(0xbf)));
expect(lerpANull75.showCheckmark, equals(true));
expect(lerpANull75.labelPadding, equals(const EdgeInsets.only(top: 6.0, bottom: 6.0)));
expect(lerpANull75.padding, equals(const EdgeInsets.all(1.5)));
expect(lerpANull75.side!.color, equals(Colors.white.withAlpha(0xbf)));
expect(lerpANull75.side!.color, isSameColorAs(Colors.white.withAlpha(0xbf)));
expect(lerpANull75.shape, isA<BeveledRectangleBorder>());
expect(lerpANull75.labelStyle?.color, equals(Colors.black.withAlpha(0xa7)));
expect(lerpANull75.secondaryLabelStyle?.color, equals(Colors.white.withAlpha(0xa7)));
expect(lerpANull75.labelStyle?.color, isSameColorAs(Colors.black.withAlpha(0xa7)));
expect(lerpANull75.secondaryLabelStyle?.color, isSameColorAs(Colors.white.withAlpha(0xa7)));
expect(lerpANull75.brightness, equals(Brightness.light));
expect(lerpANull75.elevation, 3.75);
expect(lerpANull75.pressElevation, 7.5);
expect(lerpANull75.checkmarkColor, equals(Colors.white.withAlpha(0xbf)));
expect(lerpANull75.checkmarkColor, isSameColorAs(Colors.white.withAlpha(0xbf)));
expect(lerpANull75.iconTheme, const IconThemeData(size: 16.5));
final ChipThemeData lerpBNull25 = ChipThemeData.lerp(chipThemeBlack, null, 0.25)!;
expect(lerpBNull25.backgroundColor, equals(Colors.white.withAlpha(0x17)));
expect(lerpBNull25.deleteIconColor, equals(Colors.white.withAlpha(0xa7)));
expect(lerpBNull25.disabledColor, equals(Colors.white.withAlpha(0x09)));
expect(lerpBNull25.selectedColor, equals(Colors.white.withAlpha(0x2e)));
expect(lerpBNull25.secondarySelectedColor, equals(Colors.black.withAlpha(0x2e)));
expect(lerpBNull25.shadowColor, equals(Colors.black.withAlpha(0xbf)));
expect(lerpBNull25.surfaceTintColor, equals(Colors.black.withAlpha(0xbf)));
expect(lerpBNull25.selectedShadowColor, equals(Colors.black.withAlpha(0xbf)));
expect(lerpBNull25.backgroundColor, isSameColorAs(Colors.white.withAlpha(0x17)));
expect(lerpBNull25.deleteIconColor, isSameColorAs(Colors.white.withAlpha(0xa7)));
expect(lerpBNull25.disabledColor, isSameColorAs(Colors.white.withAlpha(0x09)));
expect(lerpBNull25.selectedColor, isSameColorAs(Colors.white.withAlpha(0x2e)));
expect(lerpBNull25.secondarySelectedColor, isSameColorAs(Colors.black.withAlpha(0x2e)));
expect(lerpBNull25.shadowColor, isSameColorAs(Colors.black.withAlpha(0xbf)));
expect(lerpBNull25.surfaceTintColor, isSameColorAs(Colors.black.withAlpha(0xbf)));
expect(lerpBNull25.selectedShadowColor, isSameColorAs(Colors.black.withAlpha(0xbf)));
expect(lerpBNull25.showCheckmark, equals(false));
expect(lerpBNull25.labelPadding, equals(const EdgeInsets.only(left: 6.0, right: 6.0)));
expect(lerpBNull25.padding, equals(const EdgeInsets.all(3.0)));
expect(lerpBNull25.side!.color, equals(Colors.black.withAlpha(0x3f)));
expect(lerpBNull25.side!.color, isSameColorAs(Colors.black.withAlpha(0x3f)));
expect(lerpBNull25.shape, isA<StadiumBorder>());
expect(lerpBNull25.labelStyle?.color, equals(Colors.white.withAlpha(0xa7)));
expect(lerpBNull25.secondaryLabelStyle?.color, equals(Colors.black.withAlpha(0xa7)));
expect(lerpBNull25.labelStyle?.color, isSameColorAs(Colors.white.withAlpha(0xa7)));
expect(lerpBNull25.secondaryLabelStyle?.color, isSameColorAs(Colors.black.withAlpha(0xa7)));
expect(lerpBNull25.brightness, equals(Brightness.dark));
expect(lerpBNull25.elevation, 0.75);
expect(lerpBNull25.pressElevation, 3.0);
expect(lerpBNull25.checkmarkColor, equals(Colors.black.withAlpha(0xbf)));
expect(lerpBNull25.checkmarkColor, isSameColorAs(Colors.black.withAlpha(0xbf)));
expect(lerpBNull25.iconTheme, const IconThemeData(size: 19.5));
final ChipThemeData lerpBNull75 = ChipThemeData.lerp(chipThemeBlack, null, 0.75)!;
expect(lerpBNull75.backgroundColor, equals(Colors.white.withAlpha(0x08)));
expect(lerpBNull75.deleteIconColor, equals(Colors.white.withAlpha(0x38)));
expect(lerpBNull75.disabledColor, equals(Colors.white.withAlpha(0x03)));
expect(lerpBNull75.selectedColor, equals(Colors.white.withAlpha(0x0f)));
expect(lerpBNull75.secondarySelectedColor, equals(Colors.black.withAlpha(0x0f)));
expect(lerpBNull75.shadowColor, equals(Colors.black.withAlpha(0x40)));
expect(lerpBNull75.surfaceTintColor, equals(Colors.black.withAlpha(0x40)));
expect(lerpBNull75.selectedShadowColor, equals(Colors.black.withAlpha(0x40)));
expect(lerpBNull75.backgroundColor, isSameColorAs(Colors.white.withAlpha(0x08)));
expect(lerpBNull75.deleteIconColor, isSameColorAs(Colors.white.withAlpha(0x38)));
expect(lerpBNull75.disabledColor, isSameColorAs(Colors.white.withAlpha(0x03)));
expect(lerpBNull75.selectedColor, isSameColorAs(Colors.white.withAlpha(0x0f)));
expect(lerpBNull75.secondarySelectedColor, isSameColorAs(Colors.black.withAlpha(0x0f)));
expect(lerpBNull75.shadowColor, isSameColorAs(Colors.black.withAlpha(0x40)));
expect(lerpBNull75.surfaceTintColor, isSameColorAs(Colors.black.withAlpha(0x40)));
expect(lerpBNull75.selectedShadowColor, isSameColorAs(Colors.black.withAlpha(0x40)));
expect(lerpBNull75.showCheckmark, equals(true));
expect(lerpBNull75.labelPadding, equals(const EdgeInsets.only(left: 2.0, right: 2.0)));
expect(lerpBNull75.padding, equals(const EdgeInsets.all(1.0)));
expect(lerpBNull75.side!.color, equals(Colors.black.withAlpha(0xbf)));
expect(lerpBNull75.side!.color, isSameColorAs(Colors.black.withAlpha(0xbf)));
expect(lerpBNull75.shape, isA<StadiumBorder>());
expect(lerpBNull75.labelStyle?.color, equals(Colors.white.withAlpha(0x38)));
expect(lerpBNull75.secondaryLabelStyle?.color, equals(Colors.black.withAlpha(0x38)));
expect(lerpBNull75.labelStyle?.color, isSameColorAs(Colors.white.withAlpha(0x38)));
expect(lerpBNull75.secondaryLabelStyle?.color, isSameColorAs(Colors.black.withAlpha(0x38)));
expect(lerpBNull75.brightness, equals(Brightness.light));
expect(lerpBNull75.elevation, 0.25);
expect(lerpBNull75.pressElevation, 1.0);
expect(lerpBNull75.checkmarkColor, equals(Colors.black.withAlpha(0x40)));
expect(lerpBNull75.checkmarkColor, isSameColorAs(Colors.black.withAlpha(0x40)));
expect(lerpBNull75.iconTheme, const IconThemeData(size: 6.5));
});

View File

@ -107,7 +107,7 @@ void main() {
.map((DiagnosticsNode node) => node.toString())
.toList();
expect(description[0], 'decoration: BoxDecoration(color: Color(0xfffffff0))');
expect(description[0], 'decoration: BoxDecoration(color: ${const Color(0xfffffff0)})');
expect(description[1], "dataRowColor: Instance of '_WidgetStatePropertyWith<Color>'");
expect(description[2], 'dataRowMinHeight: 41.0');
expect(description[3], 'dataRowMaxHeight: 42.0');

View File

@ -322,43 +322,43 @@ void main() {
.toList();
expect(description, equalsIgnoringHashCodes(<String>[
'backgroundColor: Color(0xfffffff0)',
'backgroundColor: ${const Color(0xfffffff0)}',
'elevation: 6.0',
'shadowColor: Color(0xfffffff1)',
'surfaceTintColor: Color(0xfffffff2)',
'shadowColor: ${const Color(0xfffffff1)}',
'surfaceTintColor: ${const Color(0xfffffff2)}',
'shape: RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.zero)',
'headerBackgroundColor: Color(0xfffffff3)',
'headerForegroundColor: Color(0xfffffff4)',
'headerBackgroundColor: ${const Color(0xfffffff3)}',
'headerForegroundColor: ${const Color(0xfffffff4)}',
'headerHeadlineStyle: TextStyle(inherit: true, size: 10.0)',
'headerHelpStyle: TextStyle(inherit: true, size: 11.0)',
'weekDayStyle: TextStyle(inherit: true, size: 12.0)',
'dayStyle: TextStyle(inherit: true, size: 13.0)',
'dayForegroundColor: WidgetStatePropertyAll(Color(0xfffffff5))',
'dayBackgroundColor: WidgetStatePropertyAll(Color(0xfffffff6))',
'dayOverlayColor: WidgetStatePropertyAll(Color(0xfffffff7))',
'dayForegroundColor: WidgetStatePropertyAll(${const Color(0xfffffff5)})',
'dayBackgroundColor: WidgetStatePropertyAll(${const Color(0xfffffff6)})',
'dayOverlayColor: WidgetStatePropertyAll(${const Color(0xfffffff7)})',
'dayShape: WidgetStatePropertyAll(RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.zero))',
'todayForegroundColor: WidgetStatePropertyAll(Color(0xfffffff8))',
'todayBackgroundColor: WidgetStatePropertyAll(Color(0xfffffff9))',
'todayForegroundColor: WidgetStatePropertyAll(${const Color(0xfffffff8)})',
'todayBackgroundColor: WidgetStatePropertyAll(${const Color(0xfffffff9)})',
'todayBorder: BorderSide(width: 3.0)',
'yearStyle: TextStyle(inherit: true, size: 13.0)',
'yearForegroundColor: WidgetStatePropertyAll(Color(0xfffffffa))',
'yearBackgroundColor: WidgetStatePropertyAll(Color(0xfffffffb))',
'yearOverlayColor: WidgetStatePropertyAll(Color(0xfffffffc))',
'rangePickerBackgroundColor: Color(0xfffffffd)',
'yearForegroundColor: WidgetStatePropertyAll(${const Color(0xfffffffa)})',
'yearBackgroundColor: WidgetStatePropertyAll(${const Color(0xfffffffb)})',
'yearOverlayColor: WidgetStatePropertyAll(${const Color(0xfffffffc)})',
'rangePickerBackgroundColor: ${const Color(0xfffffffd)}',
'rangePickerElevation: 7.0',
'rangePickerShadowColor: Color(0xfffffffe)',
'rangePickerSurfaceTintColor: Color(0xffffffff)',
'rangePickerShadowColor: ${const Color(0xfffffffe)}',
'rangePickerSurfaceTintColor: ${const Color(0xffffffff)}',
'rangePickerShape: RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.zero)',
'rangePickerHeaderBackgroundColor: Color(0xffffff0f)',
'rangePickerHeaderForegroundColor: Color(0xffffff1f)',
'rangePickerHeaderBackgroundColor: ${const Color(0xffffff0f)}',
'rangePickerHeaderForegroundColor: ${const Color(0xffffff1f)}',
'rangePickerHeaderHeadlineStyle: TextStyle(inherit: true, size: 14.0)',
'rangePickerHeaderHelpStyle: TextStyle(inherit: true, size: 15.0)',
'rangeSelectionBackgroundColor: Color(0xffffff2f)',
'rangeSelectionOverlayColor: WidgetStatePropertyAll(Color(0xffffff3f))',
'dividerColor: Color(0xffffff4f)',
'inputDecorationTheme: InputDecorationTheme#00000(fillColor: Color(0xffffff5f), border: UnderlineInputBorder())',
'cancelButtonStyle: ButtonStyle#00000(foregroundColor: WidgetStatePropertyAll(Color(0xffffff6f)))',
'confirmButtonStyle: ButtonStyle#00000(foregroundColor: WidgetStatePropertyAll(Color(0xffffff7f)))',
'rangeSelectionBackgroundColor: ${const Color(0xffffff2f)}',
'rangeSelectionOverlayColor: WidgetStatePropertyAll(${const Color(0xffffff3f)})',
'dividerColor: ${const Color(0xffffff4f)}',
'inputDecorationTheme: InputDecorationTheme#00000(fillColor: ${const Color(0xffffff5f)}, border: UnderlineInputBorder())',
'cancelButtonStyle: ButtonStyle#00000(foregroundColor: WidgetStatePropertyAll(${const Color(0xffffff6f)}))',
'confirmButtonStyle: ButtonStyle#00000(foregroundColor: WidgetStatePropertyAll(${const Color(0xffffff7f)}))',
'locale: en',
]));
});

View File

@ -154,17 +154,17 @@ void main() {
.where((DiagnosticsNode n) => !n.isFiltered(DiagnosticLevel.info))
.map((DiagnosticsNode n) => n.toString()).toList();
expect(description, <String>[
'backgroundColor: Color(0xff123456)',
'backgroundColor: ${const Color(0xff123456)}',
'elevation: 8.0',
'shadowColor: Color(0xff000001)',
'surfaceTintColor: Color(0xff000002)',
'shadowColor: ${const Color(0xff000001)}',
'surfaceTintColor: ${const Color(0xff000002)}',
'shape: BeveledRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.circular(20.5))',
'alignment: Alignment.bottomLeft',
'iconColor: Color(0xff654321)',
'titleTextStyle: TextStyle(inherit: true, color: Color(0xffffffff))',
'contentTextStyle: TextStyle(inherit: true, color: Color(0xff000000))',
'iconColor: ${const Color(0xff654321)}',
'titleTextStyle: TextStyle(inherit: true, color: ${const Color(0xffffffff)})',
'contentTextStyle: TextStyle(inherit: true, color: ${const Color(0xff000000)})',
'actionsPadding: EdgeInsets.all(8.0)',
'barrierColor: Color(0xff000005)',
'barrierColor: ${const Color(0xff000005)}',
'insetPadding: EdgeInsets.all(20.0)',
'clipBehavior: Clip.antiAlias'
]);

View File

@ -49,7 +49,7 @@ void main() {
.toList();
expect(description, <String>[
'color: Color(0xffffffff)',
'color: ${const Color(0xffffffff)}',
'space: 5.0',
'thickness: 4.0',
'indent: 3.0',

View File

@ -49,11 +49,11 @@ void main() {
.toList();
expect(description, <String>[
'backgroundColor: Color(0x00000099)',
'scrimColor: Color(0x00000098)',
'backgroundColor: ${const Color(0x00000099)}',
'scrimColor: ${const Color(0x00000098)}',
'elevation: 5.0',
'shadowColor: Color(0x00000097)',
'surfaceTintColor: Color(0x00000096)',
'shadowColor: ${const Color(0x00000097)}',
'surfaceTintColor: ${const Color(0x00000096)}',
'shape: RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.circular(2.0))',
'width: 200.0',
'clipBehavior: Clip.hardEdge',

View File

@ -140,8 +140,8 @@ void main() {
await tester.pump(const Duration(milliseconds: 100));
final ShapeDecoration collapsingContainerDecoration = getDecoratedBox(collapsedKey).decoration as ShapeDecoration;
expect(collapsingContainerDecoration.color, Colors.transparent);
expect((collapsingContainerDecoration.shape as Border).top.color, const Color(0x15222222));
expect((collapsingContainerDecoration.shape as Border).bottom.color, const Color(0x15222222));
expect((collapsingContainerDecoration.shape as Border).top.color, isSameColorAs(const Color(0x15222222)));
expect((collapsingContainerDecoration.shape as Border).bottom.color, isSameColorAs(const Color(0x15222222)));
// Pump all the way to the end now.
await tester.pump(const Duration(seconds: 1));

View File

@ -118,15 +118,15 @@ void main() {
.toList();
expect(description, equalsIgnoringHashCodes(<String>[
'backgroundColor: Color(0xff000000)',
'collapsedBackgroundColor: Color(0xff6f83fc)',
'backgroundColor: ${const Color(0xff000000)}',
'collapsedBackgroundColor: ${const Color(0xff6f83fc)}',
'tilePadding: EdgeInsets.all(20.0)',
'expandedAlignment: Alignment.bottomCenter',
'childrenPadding: EdgeInsets.all(10.0)',
'iconColor: Color(0xffa7c61c)',
'collapsedIconColor: Color(0xffdd0b1f)',
'textColor: Color(0xffffffff)',
'collapsedTextColor: Color(0xff522bab)',
'iconColor: ${const Color(0xffa7c61c)}',
'collapsedIconColor: ${const Color(0xffdd0b1f)}',
'textColor: ${const Color(0xffffffff)}',
'collapsedTextColor: ${const Color(0xff522bab)}',
'shape: Border.all(BorderSide(width: 0.0, style: none))',
'collapsedShape: Border.all(BorderSide(width: 0.0, style: none))',
'clipBehavior: Clip.antiAlias',

View File

@ -402,11 +402,11 @@ void main() {
.toList();
expect(description, <String>[
'foregroundColor: Color(0xfeedfeed)',
'backgroundColor: Color(0xcafecafe)',
'focusColor: Color(0xfeedfee1)',
'hoverColor: Color(0xfeedfee2)',
'splashColor: Color(0xfeedfee3)',
'foregroundColor: ${const Color(0xfeedfeed)}',
'backgroundColor: ${const Color(0xcafecafe)}',
'focusColor: ${const Color(0xfeedfee1)}',
'hoverColor: ${const Color(0xfeedfee2)}',
'splashColor: ${const Color(0xfeedfee3)}',
'elevation: 23.0',
'focusElevation: 9.0',
'hoverElevation: 10.0',

View File

@ -7140,8 +7140,8 @@ void main() {
// Spot check
expect(debugString, contains('labelStyle: TextStyle(inherit: true, height: 1.0x)'));
expect(debugString, contains('isDense: true'));
expect(debugString, contains('fillColor: Color(0x00000010)'));
expect(debugString, contains('focusColor: Color(0x00000020)'));
expect(debugString, contains('fillColor: ${const Color(0x00000010)}'));
expect(debugString, contains('focusColor: ${const Color(0x00000020)}'));
expect(debugString, contains('errorBorder: UnderlineInputBorder()'));
expect(debugString, contains('focusedBorder: OutlineInputBorder()'));
});
@ -7201,20 +7201,20 @@ void main() {
'isDense: true',
'contentPadding: EdgeInsetsDirectional(40.0, 12.0, 0.0, 12.0)',
'isCollapsed: true',
'iconColor: MaterialColor(primary value: Color(0xfff44336))',
'prefixIconColor: MaterialColor(primary value: Color(0xff2196f3))',
'iconColor: MaterialColor(primary value: ${const Color(0xfff44336)})',
'prefixIconColor: MaterialColor(primary value: ${const Color(0xff2196f3)})',
'prefixIconConstraints: BoxConstraints(w=10.0, h=30.0)',
'prefixStyle: TextStyle(<all styles inherited>)',
'suffixIconColor: MaterialColor(primary value: Color(0xff2196f3))',
'suffixIconColor: MaterialColor(primary value: ${const Color(0xff2196f3)})',
'suffixIconConstraints: BoxConstraints(w=10.0, h=30.0)',
'suffixStyle: TextStyle(<all styles inherited>)',
'counterStyle: TextStyle(<all styles inherited>)',
'filled: true',
'fillColor: MaterialColor(primary value: Color(0xfff44336))',
'fillColor: MaterialColor(primary value: ${const Color(0xfff44336)})',
'activeIndicatorBorder: BorderSide',
'outlineBorder: BorderSide',
'focusColor: MaterialColor(primary value: Color(0xff2196f3))',
'hoverColor: MaterialColor(primary value: Color(0xff4caf50))',
'focusColor: MaterialColor(primary value: ${const Color(0xff2196f3)})',
'hoverColor: MaterialColor(primary value: ${const Color(0xff4caf50)})',
'errorBorder: UnderlineInputBorder()',
'focusedBorder: UnderlineInputBorder()',
'focusedErrorBorder: UnderlineInputBorder()',
@ -12443,57 +12443,57 @@ void main() {
// Test filled text field.
await pumpDecorator(hovering: false);
expect(getContainerColor(tester), equals(fillColor));
expect(getContainerColor(tester), isSameColorAs(fillColor));
await tester.pump(const Duration(seconds: 10));
expect(getContainerColor(tester), equals(fillColor));
expect(getContainerColor(tester), isSameColorAs(fillColor));
await pumpDecorator(hovering: true);
expect(getContainerColor(tester), equals(fillColor));
expect(getContainerColor(tester), isSameColorAs(fillColor));
await tester.pump(const Duration(milliseconds: 15));
expect(getContainerColor(tester), equals(hoverColor));
expect(getContainerColor(tester), isSameColorAs(hoverColor));
await pumpDecorator(hovering: false);
expect(getContainerColor(tester), equals(hoverColor));
expect(getContainerColor(tester), isSameColorAs(hoverColor));
await tester.pump(const Duration(milliseconds: 15));
expect(getContainerColor(tester), equals(fillColor));
expect(getContainerColor(tester), isSameColorAs(fillColor));
await pumpDecorator(hovering: false, enabled: false);
expect(getContainerColor(tester), equals(disabledColor));
expect(getContainerColor(tester), isSameColorAs(disabledColor));
await tester.pump(const Duration(seconds: 10));
expect(getContainerColor(tester), equals(disabledColor));
expect(getContainerColor(tester), isSameColorAs(disabledColor));
await pumpDecorator(hovering: true, enabled: false);
expect(getContainerColor(tester), equals(disabledColor));
expect(getContainerColor(tester), isSameColorAs(disabledColor));
await tester.pump(const Duration(seconds: 10));
expect(getContainerColor(tester), equals(disabledColor));
expect(getContainerColor(tester), isSameColorAs(disabledColor));
// Test outline text field.
const Color blendedHoverColor = Color(0x74004400);
await pumpDecorator(hovering: false, filled: false);
await tester.pumpAndSettle();
expect(getBorderColor(tester), equals(enabledBorderColor));
expect(getBorderColor(tester), isSameColorAs(enabledBorderColor));
await tester.pump(const Duration(seconds: 10));
expect(getBorderColor(tester), equals(enabledBorderColor));
expect(getBorderColor(tester), isSameColorAs(enabledBorderColor));
await pumpDecorator(hovering: true, filled: false);
expect(getBorderColor(tester), equals(enabledBorderColor));
expect(getBorderColor(tester), isSameColorAs(enabledBorderColor));
await tester.pump(const Duration(milliseconds: 167));
expect(getBorderColor(tester), equals(blendedHoverColor));
expect(getBorderColor(tester), isSameColorAs(blendedHoverColor));
await pumpDecorator(hovering: false, filled: false);
expect(getBorderColor(tester), equals(blendedHoverColor));
expect(getBorderColor(tester), isSameColorAs(blendedHoverColor));
await tester.pump(const Duration(milliseconds: 167));
expect(getBorderColor(tester), equals(enabledBorderColor));
expect(getBorderColor(tester), isSameColorAs(enabledBorderColor));
await pumpDecorator(hovering: false, filled: false, enabled: false);
expect(getBorderColor(tester), equals(enabledBorderColor));
expect(getBorderColor(tester), isSameColorAs(enabledBorderColor));
await tester.pump(const Duration(milliseconds: 167));
expect(getBorderColor(tester), equals(disabledColor));
expect(getBorderColor(tester), isSameColorAs(disabledColor));
await pumpDecorator(hovering: true, filled: false, enabled: false);
expect(getBorderColor(tester), equals(disabledColor));
expect(getBorderColor(tester), isSameColorAs(disabledColor));
await tester.pump(const Duration(seconds: 10));
expect(getBorderColor(tester), equals(disabledColor));
expect(getBorderColor(tester), isSameColorAs(disabledColor));
});
testWidgets('InputDecorator draws and animates focusColor', (WidgetTester tester) async {

View File

@ -2052,20 +2052,20 @@ void main() {
'visualDensity: VisualDensity#00000(h: 0.0, v: 0.0)',
'shape: RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.zero)',
'style: ListTileStyle.list',
'selectedColor: Color(0xff0000ff)',
'iconColor: Color(0xff00ff00)',
'textColor: Color(0xffff0000)',
'selectedColor: ${const Color(0xff0000ff)}',
'iconColor: ${const Color(0xff00ff00)}',
'textColor: ${const Color(0xffff0000)}',
'titleTextStyle: TextStyle(inherit: true, size: 22.0)',
'subtitleTextStyle: TextStyle(inherit: true, size: 18.0)',
'leadingAndTrailingTextStyle: TextStyle(inherit: true, size: 16.0)',
'contentPadding: EdgeInsets.zero',
'enabled: false',
'selected: true',
'focusColor: Color(0xff00ffff)',
'hoverColor: Color(0xff0000ff)',
'focusColor: ${const Color(0xff00ffff)}',
'hoverColor: ${const Color(0xff0000ff)}',
'autofocus: true',
'tileColor: Color(0xffffff00)',
'selectedTileColor: Color(0xff123456)',
'tileColor: ${const Color(0xffffff00)}',
'selectedTileColor: ${const Color(0xff123456)}',
'enableFeedback: false',
'horizontalTitleGap: 4.0',
'minVerticalPadding: 2.0',

View File

@ -127,15 +127,15 @@ void main() {
'dense: true',
'shape: StadiumBorder(BorderSide(width: 0.0, style: none))',
'style: drawer',
'selectedColor: Color(0x00000001)',
'iconColor: Color(0x00000002)',
'textColor: Color(0x00000003)',
'titleTextStyle: TextStyle(inherit: true, color: Color(0x00000004))',
'subtitleTextStyle: TextStyle(inherit: true, color: Color(0x00000005))',
'leadingAndTrailingTextStyle: TextStyle(inherit: true, color: Color(0x00000006))',
'selectedColor: ${const Color(0x00000001)}',
'iconColor: ${const Color(0x00000002)}',
'textColor: ${const Color(0x00000003)}',
'titleTextStyle: TextStyle(inherit: true, color: ${const Color(0x00000004)})',
'subtitleTextStyle: TextStyle(inherit: true, color: ${const Color(0x00000005)})',
'leadingAndTrailingTextStyle: TextStyle(inherit: true, color: ${const Color(0x00000006)})',
'contentPadding: EdgeInsets.all(100.0)',
'tileColor: Color(0x00000007)',
'selectedTileColor: Color(0x00000008)',
'tileColor: ${const Color(0x00000007)}',
'selectedTileColor: ${const Color(0x00000008)}',
'horizontalTitleGap: 200.0',
'minVerticalPadding: 300.0',
'minLeadingWidth: 400.0',

View File

@ -45,7 +45,7 @@ void main() {
test('toString formats correctly', () {
const MaterialStateProperty<Color?> colorProperty = MaterialStatePropertyAll<Color?>(Color(0xFFFFFFFF));
expect(colorProperty.toString(), equals('WidgetStatePropertyAll(Color(0xffffffff))'));
expect(colorProperty.toString(), equals('WidgetStatePropertyAll(${const Color(0xffffffff)})'));
const MaterialStateProperty<double?> doubleProperty = MaterialStatePropertyAll<double?>(33 + 1/3);
expect(doubleProperty.toString(), equals('WidgetStatePropertyAll(33.3)'));

View File

@ -114,11 +114,11 @@ void main() {
expect(description, <String>[
'type: canvas',
'color: Color(0xffffffff)',
'shadowColor: Color(0xffff0000)',
'surfaceTintColor: Color(0xff0000ff)',
'color: ${const Color(0xffffffff)}',
'shadowColor: ${const Color(0xffff0000)}',
'surfaceTintColor: ${const Color(0xff0000ff)}',
'textStyle.inherit: true',
'textStyle.color: Color(0xff00ff00)',
'textStyle.color: ${const Color(0xff00ff00)}',
'borderRadius: BorderRadiusDirectional.circular(10.0)',
]);
});
@ -392,7 +392,7 @@ void main() {
final RenderPhysicalShape tintModel = getModel(tester);
// Final color should be the base with a tint of 0.14 opacity or 0xff192c33
expect(tintModel.color, equals(const Color(0xff192c33)));
expect(tintModel.color, isSameColorAs(const Color(0xff192c33)));
});
}); // Surface Tint Overlay group
@ -452,7 +452,7 @@ void main() {
);
await tester.pumpAndSettle(); // wait for the elevation animation to finish
final RenderPhysicalShape model = getModel(tester);
expect(model.color, equals(test.color));
expect(model.color, isSameColorAs(test.color));
}
});
@ -513,8 +513,8 @@ void main() {
);
final RenderPhysicalShape model = getModel(tester);
expect(model.color, equals(surfaceColorWithOverlay));
expect(model.color, isNot(equals(surfaceColor)));
expect(model.color, isSameColorAs(surfaceColorWithOverlay));
expect(model.color, isNot(isSameColorAs(surfaceColor)));
});
testWidgets('Expected overlay color can be computed using colorWithOverlay', (WidgetTester tester) async {

View File

@ -1298,7 +1298,7 @@ void main() {
expect(
description.join('\n'),
equalsIgnoringHashCodes(
'style: MenuStyle#00000(backgroundColor: WidgetStatePropertyAll(MaterialColor(primary value: Color(0xfff44336))), elevation: WidgetStatePropertyAll(10.0))\n'
'style: MenuStyle#00000(backgroundColor: WidgetStatePropertyAll(MaterialColor(primary value: ${const Color(0xfff44336)})), elevation: WidgetStatePropertyAll(10.0))\n'
'clipBehavior: Clip.none'),
);
});
@ -2972,7 +2972,7 @@ void main() {
equalsIgnoringHashCodes(
<String>[
'focusNode: null',
'menuStyle: MenuStyle#00000(backgroundColor: WidgetStatePropertyAll(MaterialColor(primary value: Color(0xff4caf50))), elevation: WidgetStatePropertyAll(20.0), shape: WidgetStatePropertyAll(RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.zero)))',
'menuStyle: MenuStyle#00000(backgroundColor: WidgetStatePropertyAll(MaterialColor(primary value: ${const Color(0xff4caf50)})), elevation: WidgetStatePropertyAll(20.0), shape: WidgetStatePropertyAll(RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.zero)))',
'alignmentOffset: null',
'clipBehavior: hardEdge',
],

View File

@ -58,16 +58,16 @@ void main() {
.toList();
expect(description[0], 'height: 200.0');
expect(description[1], 'backgroundColor: Color(0x00000099)');
expect(description[1], 'backgroundColor: ${const Color(0x00000099)}');
expect(description[2], 'elevation: 20.0');
expect(description[3], 'indicatorColor: Color(0x00000098)');
expect(description[3], 'indicatorColor: ${const Color(0x00000098)}');
expect(description[4], 'indicatorShape: CircleBorder(BorderSide(width: 0.0, style: none))');
expect(description[5], 'labelTextStyle: WidgetStatePropertyAll(TextStyle(inherit: true, size: 7.0))');
// Ignore instance address for IconThemeData.
expect(description[6].contains('iconTheme: WidgetStatePropertyAll(IconThemeData'), isTrue);
expect(description[6].contains('(color: Color(0x00000097))'), isTrue);
expect(description[6].contains('(color: ${const Color(0x00000097)})'), isTrue);
expect(description[7], 'labelBehavior: NavigationDestinationLabelBehavior.alwaysHide');
expect(description[8], 'overlayColor: WidgetStatePropertyAll(Color(0x00000096))');
expect(description[8], 'overlayColor: WidgetStatePropertyAll(${const Color(0x00000096)})');
});
testWidgets('NavigationBarThemeData values are used when no NavigationBar properties are specified', (WidgetTester tester) async {

View File

@ -53,15 +53,15 @@ void main() {
expect(description, equalsIgnoringHashCodes(
<String>[
'tileHeight: 50.0',
'backgroundColor: Color(0x00000099)',
'backgroundColor: ${const Color(0x00000099)}',
'elevation: 5.0',
'shadowColor: Color(0x00000098)',
'surfaceTintColor: Color(0x00000097)',
'indicatorColor: Color(0x00000096)',
'shadowColor: ${const Color(0x00000098)}',
'surfaceTintColor: ${const Color(0x00000097)}',
'indicatorColor: ${const Color(0x00000096)}',
'indicatorShape: RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.circular(2.0))',
'indicatorSize: Size(10.0, 10.0)',
'labelTextStyle: WidgetStatePropertyAll(TextStyle(inherit: true, size: 7.0))',
'iconTheme: WidgetStatePropertyAll(IconThemeData#00000(color: Color(0x00000095)))'
'iconTheme: WidgetStatePropertyAll(IconThemeData#00000(color: ${const Color(0x00000095)}))'
],
));
});

View File

@ -269,21 +269,21 @@ void main() {
.map((DiagnosticsNode node) => node.toString())
.toList();
expect(description[0], 'backgroundColor: Color(0x00000099)');
expect(description[0], 'backgroundColor: ${const Color(0x00000099)}');
expect(description[1], 'elevation: 5.0');
expect(description[2], 'unselectedLabelTextStyle: TextStyle(inherit: true, size: 7.0)');
expect(description[3], 'selectedLabelTextStyle: TextStyle(inherit: true, size: 9.0)');
// Ignore instance address for IconThemeData.
expect(description[4].contains('unselectedIconTheme: IconThemeData'), isTrue);
expect(description[4].contains('(color: Color(0x00000097))'), isTrue);
expect(description[4].contains('(color: ${const Color(0x00000097)})'), isTrue);
expect(description[5].contains('selectedIconTheme: IconThemeData'), isTrue);
expect(description[5].contains('(color: Color(0x00000098))'), isTrue);
expect(description[5].contains('(color: ${const Color(0x00000098)})'), isTrue);
expect(description[6], 'groupAlignment: 1.0');
expect(description[7], 'labelType: NavigationRailLabelType.selected');
expect(description[8], 'useIndicator: true');
expect(description[9], 'indicatorColor: Color(0x00000096)');
expect(description[9], 'indicatorColor: ${const Color(0x00000096)}');
expect(description[10], 'indicatorShape: CircleBorder(BorderSide(width: 0.0, style: none))');
});
}

View File

@ -114,18 +114,18 @@ void main() {
.toList();
expect(description, <String>[
'color: Color(0xfffffff1)',
'color: ${const Color(0xfffffff1)}',
'shape: RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.circular(2.0))',
'menuPadding: EdgeInsets(0.0, 12.0, 0.0, 12.0)',
'elevation: 2.0',
'shadowColor: Color(0xfffffff2)',
'surfaceTintColor: Color(0xfffffff3)',
'text style: TextStyle(inherit: true, color: Color(0xfffffff4))',
'shadowColor: ${const Color(0xfffffff2)}',
'surfaceTintColor: ${const Color(0xfffffff3)}',
'text style: TextStyle(inherit: true, color: ${const Color(0xfffffff4)})',
"labelTextStyle: Instance of '_WidgetStatePropertyWith<TextStyle?>'",
'enableFeedback: false',
'mouseCursor: WidgetStateMouseCursor(clickable)',
'position: over',
'iconColor: Color(0xfffffff8)',
'iconColor: ${const Color(0xfffffff8)}',
'iconSize: 31.0'
]);
});

View File

@ -69,8 +69,8 @@ void main() {
description,
equalsIgnoringHashCodes(<String>[
'mouseCursor: WidgetStatePropertyAll(SystemMouseCursor(click))',
'fillColor: WidgetStatePropertyAll(Color(0xfffffff0))',
'overlayColor: WidgetStatePropertyAll(Color(0xfffffff1))',
'fillColor: WidgetStatePropertyAll(${const Color(0xfffffff0)})',
'overlayColor: WidgetStatePropertyAll(${const Color(0xfffffff1)})',
'splashRadius: 1.0',
'materialTapTargetSize: MaterialTapTargetSize.shrinkWrap',
'visualDensity: VisualDensity#00000(h: 0.0, v: 0.0)',

View File

@ -2046,8 +2046,8 @@ void main() {
'divisions: 4',
'labelStart: "lowerValue"',
'labelEnd: "upperValue"',
'activeColor: MaterialColor(primary value: Color(0xff2196f3))',
'inactiveColor: MaterialColor(primary value: Color(0xff9e9e9e))',
'activeColor: MaterialColor(primary value: ${const Color(0xff2196f3)})',
'inactiveColor: MaterialColor(primary value: ${const Color(0xff9e9e9e)})',
]);
});

View File

@ -86,11 +86,11 @@ void main() {
.toList();
expect(description[0], 'elevation: WidgetStatePropertyAll(3.0)');
expect(description[1], 'backgroundColor: WidgetStatePropertyAll(Color(0xfffffff1))');
expect(description[2], 'shadowColor: WidgetStatePropertyAll(Color(0xfffffff2))');
expect(description[3], 'surfaceTintColor: WidgetStatePropertyAll(Color(0xfffffff3))');
expect(description[4], 'overlayColor: WidgetStatePropertyAll(Color(0xfffffff4))');
expect(description[5], 'side: WidgetStatePropertyAll(BorderSide(color: Color(0xfffffff5), width: 2.0))');
expect(description[1], 'backgroundColor: WidgetStatePropertyAll(${const Color(0xfffffff1)})');
expect(description[2], 'shadowColor: WidgetStatePropertyAll(${const Color(0xfffffff2)})');
expect(description[3], 'surfaceTintColor: WidgetStatePropertyAll(${const Color(0xfffffff3)})');
expect(description[4], 'overlayColor: WidgetStatePropertyAll(${const Color(0xfffffff4)})');
expect(description[5], 'side: WidgetStatePropertyAll(BorderSide(color: ${const Color(0xfffffff5)}, width: 2.0))');
expect(description[6], 'shape: WidgetStatePropertyAll(StadiumBorder(BorderSide(width: 0.0, style: none)))');
expect(description[7], 'padding: WidgetStatePropertyAll(EdgeInsets.all(16.0))');
expect(description[8], 'textStyle: WidgetStatePropertyAll(TextStyle(inherit: true, size: 24.0))');

View File

@ -78,10 +78,10 @@ void main() {
.map((DiagnosticsNode node) => node.toString())
.toList();
expect(description[0], 'backgroundColor: Color(0xfffffff1)');
expect(description[0], 'backgroundColor: ${const Color(0xfffffff1)}');
expect(description[1], 'elevation: 3.5');
expect(description[2], 'surfaceTintColor: Color(0xfffffff3)');
expect(description[3], 'side: BorderSide(color: Color(0xfffffff5), width: 2.5)');
expect(description[2], 'surfaceTintColor: ${const Color(0xfffffff3)}');
expect(description[3], 'side: BorderSide(color: ${const Color(0xfffffff5)}, width: 2.5)');
expect(description[4], 'shape: RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.zero)');
expect(description[5], 'headerHeight: 35.5');
expect(description[6], 'headerTextStyle: TextStyle(inherit: true, size: 24.0)');

View File

@ -3136,9 +3136,9 @@ void main() {
'max: 100.0',
'divisions: 10',
'label: "Set a value"',
'activeColor: MaterialColor(primary value: Color(0xff2196f3))',
'inactiveColor: MaterialColor(primary value: Color(0xff9e9e9e))',
'secondaryActiveColor: MaterialColor(primary value: Color(0xff607d8b))',
'activeColor: MaterialColor(primary value: ${const Color(0xff2196f3)})',
'inactiveColor: MaterialColor(primary value: ${const Color(0xff9e9e9e)})',
'secondaryActiveColor: MaterialColor(primary value: ${const Color(0xff607d8b)})',
]);
});

View File

@ -72,22 +72,22 @@ void main() {
expect(description, <String>[
'trackHeight: 7.0',
'activeTrackColor: Color(0xff000001)',
'inactiveTrackColor: Color(0xff000002)',
'secondaryActiveTrackColor: Color(0xff000003)',
'disabledActiveTrackColor: Color(0xff000004)',
'disabledInactiveTrackColor: Color(0xff000005)',
'disabledSecondaryActiveTrackColor: Color(0xff000006)',
'activeTickMarkColor: Color(0xff000007)',
'inactiveTickMarkColor: Color(0xff000008)',
'disabledActiveTickMarkColor: Color(0xff000009)',
'disabledInactiveTickMarkColor: Color(0xff000010)',
'thumbColor: Color(0xff000011)',
'overlappingShapeStrokeColor: Color(0xff000012)',
'disabledThumbColor: Color(0xff000013)',
'overlayColor: Color(0xff000014)',
'valueIndicatorColor: Color(0xff000015)',
'valueIndicatorStrokeColor: Color(0xff000015)',
'activeTrackColor: ${const Color(0xff000001)}',
'inactiveTrackColor: ${const Color(0xff000002)}',
'secondaryActiveTrackColor: ${const Color(0xff000003)}',
'disabledActiveTrackColor: ${const Color(0xff000004)}',
'disabledInactiveTrackColor: ${const Color(0xff000005)}',
'disabledSecondaryActiveTrackColor: ${const Color(0xff000006)}',
'activeTickMarkColor: ${const Color(0xff000007)}',
'inactiveTickMarkColor: ${const Color(0xff000008)}',
'disabledActiveTickMarkColor: ${const Color(0xff000009)}',
'disabledInactiveTickMarkColor: ${const Color(0xff000010)}',
'thumbColor: ${const Color(0xff000011)}',
'overlappingShapeStrokeColor: ${const Color(0xff000012)}',
'disabledThumbColor: ${const Color(0xff000013)}',
'overlayColor: ${const Color(0xff000014)}',
'valueIndicatorColor: ${const Color(0xff000015)}',
'valueIndicatorStrokeColor: ${const Color(0xff000015)}',
"overlayShape: Instance of 'RoundSliderOverlayShape'",
"tickMarkShape: Instance of 'RoundSliderTickMarkShape'",
"thumbShape: Instance of 'RoundSliderThumbShape'",
@ -98,7 +98,7 @@ void main() {
"rangeTrackShape: Instance of 'RoundedRectRangeSliderTrackShape'",
"rangeValueIndicatorShape: Instance of 'PaddleRangeSliderValueIndicatorShape'",
'showValueIndicator: always',
'valueIndicatorTextStyle: TextStyle(inherit: true, color: Color(0xff000000))',
'valueIndicatorTextStyle: TextStyle(inherit: true, color: ${const Color(0xff000000)})',
'mouseCursor: WidgetStateMouseCursor(clickable)',
'allowedInteraction: tapOnly'
]);
@ -423,7 +423,8 @@ void main() {
);
expect(material, paints..shadow(color: Colors.black)..circle(color: sliderTheme.disabledThumbColor));
expect(material, isNot(paints..circle(color: sliderTheme.thumbColor)));
expect(material, isNot(paints..rrect(color: sliderTheme.activeTrackColor)));
// These 2 colors are too close to distinguish.
// expect(material, isNot(paints..rrect(color: sliderTheme.activeTrackColor)));
expect(material, isNot(paints..rrect(color: sliderTheme.inactiveTrackColor)));
expect(material, isNot(paints..rrect(color: sliderTheme.secondaryActiveTrackColor)));
@ -440,7 +441,8 @@ void main() {
..circle(color: sliderTheme.disabledThumbColor),
);
expect(material, isNot(paints..circle(color: sliderTheme.thumbColor)));
expect(material, isNot(paints..rrect(color: sliderTheme.activeTrackColor)));
// These 2 colors are too close to distinguish.
// expect(material, isNot(paints..rrect(color: sliderTheme.activeTrackColor)));
expect(material, isNot(paints..rrect(color: sliderTheme.inactiveTrackColor)));
expect(material, isNot(paints..rrect(color: sliderTheme.secondaryActiveTrackColor)));
expect(material, isNot(paints..circle(color: sliderTheme.activeTickMarkColor)));
@ -457,7 +459,8 @@ void main() {
);
expect(material, paints..circle(color: sliderTheme.disabledThumbColor));
expect(material, isNot(paints..circle(color: sliderTheme.thumbColor)));
expect(material, isNot(paints..rrect(color: sliderTheme.activeTrackColor)));
// These colors are too close to distinguish.
// expect(material, isNot(paints..rrect(color: sliderTheme.activeTrackColor)));
expect(material, isNot(paints..rrect(color: sliderTheme.inactiveTrackColor)));
expect(material, isNot(paints..rrect(color: sliderTheme.secondaryActiveTrackColor)));
@ -684,22 +687,22 @@ void main() {
const Color middleGrey = Color(0xff7f7f7f);
expect(lerp.trackHeight, equals(4.0));
expect(lerp.activeTrackColor, equals(middleGrey.withAlpha(0xff)));
expect(lerp.inactiveTrackColor, equals(middleGrey.withAlpha(0x3d)));
expect(lerp.secondaryActiveTrackColor, equals(middleGrey.withAlpha(0x8a)));
expect(lerp.disabledActiveTrackColor, equals(middleGrey.withAlpha(0x52)));
expect(lerp.disabledInactiveTrackColor, equals(middleGrey.withAlpha(0x1f)));
expect(lerp.disabledSecondaryActiveTrackColor, equals(middleGrey.withAlpha(0x1f)));
expect(lerp.activeTickMarkColor, equals(middleGrey.withAlpha(0x8a)));
expect(lerp.inactiveTickMarkColor, equals(middleGrey.withAlpha(0x8a)));
expect(lerp.disabledActiveTickMarkColor, equals(middleGrey.withAlpha(0x1f)));
expect(lerp.disabledInactiveTickMarkColor, equals(middleGrey.withAlpha(0x1f)));
expect(lerp.thumbColor, equals(middleGrey.withAlpha(0xff)));
expect(lerp.disabledThumbColor, equals(middleGrey.withAlpha(0x52)));
expect(lerp.overlayColor, equals(middleGrey.withAlpha(0x1f)));
expect(lerp.valueIndicatorColor, equals(middleGrey.withAlpha(0xff)));
expect(lerp.valueIndicatorStrokeColor, equals(middleGrey.withAlpha(0xff)));
expect(lerp.valueIndicatorTextStyle!.color, equals(middleGrey.withAlpha(0xff)));
expect(lerp.activeTrackColor, isSameColorAs(middleGrey.withAlpha(0xff)));
expect(lerp.inactiveTrackColor, isSameColorAs(middleGrey.withAlpha(0x3d)));
expect(lerp.secondaryActiveTrackColor, isSameColorAs(middleGrey.withAlpha(0x8a)));
expect(lerp.disabledActiveTrackColor, isSameColorAs(middleGrey.withAlpha(0x52)));
expect(lerp.disabledInactiveTrackColor, isSameColorAs(middleGrey.withAlpha(0x1f)));
expect(lerp.disabledSecondaryActiveTrackColor, isSameColorAs(middleGrey.withAlpha(0x1f)));
expect(lerp.activeTickMarkColor, isSameColorAs(middleGrey.withAlpha(0x8a)));
expect(lerp.inactiveTickMarkColor, isSameColorAs(middleGrey.withAlpha(0x8a)));
expect(lerp.disabledActiveTickMarkColor, isSameColorAs(middleGrey.withAlpha(0x1f)));
expect(lerp.disabledInactiveTickMarkColor, isSameColorAs(middleGrey.withAlpha(0x1f)));
expect(lerp.thumbColor, isSameColorAs(middleGrey.withAlpha(0xff)));
expect(lerp.disabledThumbColor, isSameColorAs(middleGrey.withAlpha(0x52)));
expect(lerp.overlayColor, isSameColorAs(middleGrey.withAlpha(0x1f)));
expect(lerp.valueIndicatorColor, isSameColorAs(middleGrey.withAlpha(0xff)));
expect(lerp.valueIndicatorStrokeColor, isSameColorAs(middleGrey.withAlpha(0xff)));
expect(lerp.valueIndicatorTextStyle!.color, isSameColorAs(middleGrey.withAlpha(0xff)));
});
testWidgets('Default slider track draws correctly', (WidgetTester tester) async {

View File

@ -437,7 +437,7 @@ void main() {
// There is a somewhat complicated background color calculation based
// off of the surface color. For the default light theme it
// should be this value.
expect(renderModel.color, equals(const Color(0xFF333333)));
expect(renderModel.color, isSameColorAs(const Color(0xFF333333)));
});
testWidgets('Material3 - Light theme SnackBar has dark background', (WidgetTester tester) async {

View File

@ -82,17 +82,17 @@ void main() {
.toList();
expect(description, <String>[
'backgroundColor: Color(0xffffffff)',
'actionTextColor: Color(0xff0000aa)',
'disabledActionTextColor: Color(0xff00aa00)',
'contentTextStyle: TextStyle(inherit: true, color: Color(0xff123456))',
'backgroundColor: ${const Color(0xffffffff)}',
'actionTextColor: ${const Color(0xff0000aa)}',
'disabledActionTextColor: ${const Color(0xff00aa00)}',
'contentTextStyle: TextStyle(inherit: true, color: ${const Color(0xff123456)})',
'elevation: 2.0',
'shape: RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.circular(2.0))',
'behavior: SnackBarBehavior.floating',
'width: 400.0',
'insetPadding: EdgeInsets.all(10.0)',
'showCloseIcon: false',
'closeIconColor: Color(0xff0000aa)',
'closeIconColor: ${const Color(0xff0000aa)}',
'actionOverflowThreshold: 0.5',
'dismissDirection: DismissDirection.down',
]);
@ -127,7 +127,7 @@ void main() {
final RenderParagraph content = _getSnackBarTextRenderObject(tester, text);
expect(content.text.style, Typography.material2018().white.titleMedium);
expect(material.color, const Color(0xFF333333));
expect(material.color, isSameColorAs(const Color(0xFF333333)));
expect(material.elevation, 6.0);
expect(material.shape, null);
});

View File

@ -76,13 +76,13 @@ void main() {
.map((DiagnosticsNode node) => node.toString())
.toList();
expect(description[0], 'thumbColor: WidgetStatePropertyAll(Color(0xfffffff0))');
expect(description[1], 'trackColor: WidgetStatePropertyAll(Color(0xfffffff1))');
expect(description[2], 'trackOutlineColor: WidgetStatePropertyAll(Color(0xfffffff3))');
expect(description[0], 'thumbColor: WidgetStatePropertyAll(${const Color(0xfffffff0)})');
expect(description[1], 'trackColor: WidgetStatePropertyAll(${const Color(0xfffffff1)})');
expect(description[2], 'trackOutlineColor: WidgetStatePropertyAll(${const Color(0xfffffff3)})');
expect(description[3], 'trackOutlineWidth: WidgetStatePropertyAll(6.0)');
expect(description[4], 'materialTapTargetSize: MaterialTapTargetSize.shrinkWrap');
expect(description[5], 'mouseCursor: WidgetStatePropertyAll(SystemMouseCursor(click))');
expect(description[6], 'overlayColor: WidgetStatePropertyAll(Color(0xfffffff2))');
expect(description[6], 'overlayColor: WidgetStatePropertyAll(${const Color(0xfffffff2)})');
expect(description[7], 'splashRadius: 1.0');
expect(description[8], 'thumbIcon: WidgetStatePropertyAll(Icon(IconData(U+0007B)))');
expect(description[9], 'padding: EdgeInsets.all(4.0)');

View File

@ -14317,7 +14317,7 @@ void main() {
expect(description, <String>[
'enabled: false',
'decoration: InputDecoration(labelText: "foo")',
'style: TextStyle(inherit: true, color: Color(0xff00ff00))',
'style: TextStyle(inherit: true, color: ${const Color(0xff00ff00)})',
'autofocus: true',
'autocorrect: false',
'smartDashesType: disabled',
@ -14331,7 +14331,7 @@ void main() {
'cursorWidth: 1.0',
'cursorHeight: 1.0',
'cursorRadius: Radius.circular(0.0)',
'cursorColor: Color(0xff00ff00)',
'cursorColor: ${const Color(0xff00ff00)}',
'keyboardAppearance: Brightness.dark',
'scrollPadding: EdgeInsets.zero',
'selection disabled',

View File

@ -51,9 +51,9 @@ void main() {
.toList();
expect(description, <String>[
'cursorColor: Color(0xffeeffaa)',
'selectionColor: Color(0x88888888)',
'selectionHandleColor: Color(0xaabbccdd)',
'cursorColor: ${const Color(0xffeeffaa)}',
'selectionColor: ${const Color(0x88888888)}',
'selectionHandleColor: ${const Color(0xaabbccdd)}',
]);
});

View File

@ -737,8 +737,8 @@ void main() {
0.5,
);
expect(lerped.extension<MyThemeExtensionA>()!.color1, const Color(0xff7f7f7f));
expect(lerped.extension<MyThemeExtensionA>()!.color2, const Color(0xff90ab7d));
expect(lerped.extension<MyThemeExtensionA>()!.color1, isSameColorAs(const Color(0xff7f7f7f)));
expect(lerped.extension<MyThemeExtensionA>()!.color2, isSameColorAs(const Color(0xff90ab7d)));
expect(lerped.extension<MyThemeExtensionB>()!.textStyle, const TextStyle(fontSize: 75));
// Missing from 2nd ThemeData
@ -756,8 +756,8 @@ void main() {
),
0.5,
);
expect(lerped.extension<MyThemeExtensionA>()!.color1, Colors.black); // Not lerped
expect(lerped.extension<MyThemeExtensionA>()!.color2, Colors.amber); // Not lerped
expect(lerped.extension<MyThemeExtensionA>()!.color1, isSameColorAs(Colors.black)); // Not lerped
expect(lerped.extension<MyThemeExtensionA>()!.color2, isSameColorAs(Colors.amber)); // Not lerped
expect(lerped.extension<MyThemeExtensionB>()!.textStyle, const TextStyle(fontSize: 75));
// Missing from 1st ThemeData
@ -775,8 +775,8 @@ void main() {
),
0.5,
);
expect(lerped.extension<MyThemeExtensionA>()!.color1, const Color(0xff7f7f7f));
expect(lerped.extension<MyThemeExtensionA>()!.color2, const Color(0xff90ab7d));
expect(lerped.extension<MyThemeExtensionA>()!.color1, isSameColorAs(const Color(0xff7f7f7f)));
expect(lerped.extension<MyThemeExtensionA>()!.color2, isSameColorAs(const Color(0xff90ab7d)));
expect(lerped.extension<MyThemeExtensionB>()!.textStyle, const TextStyle(fontSize: 100)); // Not lerped
});

View File

@ -101,30 +101,30 @@ void main() {
.toList();
expect(description, equalsIgnoringHashCodes(<String>[
'backgroundColor: Color(0xfffffff0)',
'cancelButtonStyle: ButtonStyle#00000(foregroundColor: WidgetStatePropertyAll(Color(0xfffffff1)))',
'confirmButtonStyle: ButtonStyle#00000(foregroundColor: WidgetStatePropertyAll(Color(0xfffffff2)))',
'dayPeriodBorderSide: BorderSide(color: Color(0xfffffff3))',
'dayPeriodColor: Color(0x00000000)',
'dayPeriodShape: RoundedRectangleBorder(BorderSide(color: Color(0xfffffff5)), BorderRadius.zero)',
'dayPeriodTextColor: Color(0xfffffff6)',
'dayPeriodTextStyle: TextStyle(inherit: true, color: Color(0xfffffff7))',
'dialBackgroundColor: Color(0xfffffff8)',
'dialHandColor: Color(0xfffffff9)',
'dialTextColor: Color(0xfffffffa)',
'dialTextStyle: TextStyle(inherit: true, color: Color(0xfffffffb))',
'backgroundColor: ${const Color(0xfffffff0)}',
'cancelButtonStyle: ButtonStyle#00000(foregroundColor: WidgetStatePropertyAll(${const Color(0xfffffff1)}))',
'confirmButtonStyle: ButtonStyle#00000(foregroundColor: WidgetStatePropertyAll(${const Color(0xfffffff2)}))',
'dayPeriodBorderSide: BorderSide(color: ${const Color(0xfffffff3)})',
'dayPeriodColor: ${const Color(0x00000000)}',
'dayPeriodShape: RoundedRectangleBorder(BorderSide(color: ${const Color(0xfffffff5)}), BorderRadius.zero)',
'dayPeriodTextColor: ${const Color(0xfffffff6)}',
'dayPeriodTextStyle: TextStyle(inherit: true, color: ${const Color(0xfffffff7)})',
'dialBackgroundColor: ${const Color(0xfffffff8)}',
'dialHandColor: ${const Color(0xfffffff9)}',
'dialTextColor: ${const Color(0xfffffffa)}',
'dialTextStyle: TextStyle(inherit: true, color: ${const Color(0xfffffffb)})',
'elevation: 1.0',
'entryModeIconColor: Color(0xfffffffc)',
'helpTextStyle: TextStyle(inherit: true, color: Color(0xfffffffd))',
'hourMinuteColor: Color(0xfffffffe)',
'hourMinuteShape: RoundedRectangleBorder(BorderSide(color: Color(0xffffffff)), BorderRadius.zero)',
'hourMinuteTextColor: Color(0xfffffff0)',
'hourMinuteTextStyle: TextStyle(inherit: true, color: Color(0xfffffff1))',
'inputDecorationTheme: InputDecorationTheme#ff861(labelStyle: TextStyle(inherit: true, color: Color(0xfffffff2)))',
'entryModeIconColor: ${const Color(0xfffffffc)}',
'helpTextStyle: TextStyle(inherit: true, color: ${const Color(0xfffffffd)})',
'hourMinuteColor: ${const Color(0xfffffffe)}',
'hourMinuteShape: RoundedRectangleBorder(BorderSide(color: ${const Color(0xffffffff)}), BorderRadius.zero)',
'hourMinuteTextColor: ${const Color(0xfffffff0)}',
'hourMinuteTextStyle: TextStyle(inherit: true, color: ${const Color(0xfffffff1)})',
'inputDecorationTheme: InputDecorationTheme#ff861(labelStyle: TextStyle(inherit: true, color: ${const Color(0xfffffff2)}))',
'padding: EdgeInsets.all(1.0)',
'shape: RoundedRectangleBorder(BorderSide(color: Color(0xfffffff3)), BorderRadius.zero)',
'timeSelectorSeparatorColor: WidgetStatePropertyAll(Color(0xfffffff4))',
'timeSelectorSeparatorTextStyle: WidgetStatePropertyAll(TextStyle(inherit: true, color: Color(0xfffffff5)))'
'shape: RoundedRectangleBorder(BorderSide(color: ${const Color(0xfffffff3)}), BorderRadius.zero)',
'timeSelectorSeparatorColor: WidgetStatePropertyAll(${const Color(0xfffffff4)})',
'timeSelectorSeparatorTextStyle: WidgetStatePropertyAll(TextStyle(inherit: true, color: ${const Color(0xfffffff5)}))'
]));
});

View File

@ -1923,10 +1923,10 @@ void main() {
expect(description, <String>[
'Buttons are enabled',
'color: MaterialColor(primary value: Color(0xff4caf50))',
'disabledColor: MaterialColor(primary value: Color(0xff2196f3))',
'selectedBorderColor: MaterialColor(primary value: Color(0xffe91e63))',
'disabledBorderColor: MaterialColor(primary value: Color(0xffffeb3b))',
'color: MaterialColor(primary value: ${const Color(0xff4caf50)})',
'disabledColor: MaterialColor(primary value: ${const Color(0xff2196f3)})',
'selectedBorderColor: MaterialColor(primary value: ${const Color(0xffe91e63)})',
'disabledBorderColor: MaterialColor(primary value: ${const Color(0xffffeb3b)})',
'borderRadius: BorderRadius.circular(7.0)',
'borderWidth: 3.0',
'direction: Axis.vertical',

View File

@ -103,17 +103,17 @@ void main() {
'textStyle.inherit: true',
'textStyle.size: 10.0',
'constraints: BoxConstraints(0.0<=w<=Infinity, 10.0<=h<=20.0)',
'color: Color(0xfffffff0)',
'selectedColor: Color(0xfffffff1)',
'disabledColor: Color(0xfffffff2)',
'fillColor: Color(0xfffffff3)',
'focusColor: Color(0xfffffff4)',
'highlightColor: Color(0xfffffff5)',
'hoverColor: Color(0xfffffff6)',
'splashColor: Color(0xfffffff7)',
'borderColor: Color(0xfffffff8)',
'selectedBorderColor: Color(0xfffffff9)',
'disabledBorderColor: Color(0xfffffffa)',
'color: ${const Color(0xfffffff0)}',
'selectedColor: ${const Color(0xfffffff1)}',
'disabledColor: ${const Color(0xfffffff2)}',
'fillColor: ${const Color(0xfffffff3)}',
'focusColor: ${const Color(0xfffffff4)}',
'highlightColor: ${const Color(0xfffffff5)}',
'hoverColor: ${const Color(0xfffffff6)}',
'splashColor: ${const Color(0xfffffff7)}',
'borderColor: ${const Color(0xfffffff8)}',
'selectedBorderColor: ${const Color(0xfffffff9)}',
'disabledBorderColor: ${const Color(0xfffffffa)}',
'borderRadius: BorderRadius.circular(4.0)',
'borderWidth: 2.0',
]);

View File

@ -87,7 +87,7 @@ void main() {
'vertical offset: 10.0',
'position: above',
'semantics: excluded',
'decoration: BoxDecoration(color: Color(0xffffffff))',
'decoration: BoxDecoration(color: ${const Color(0xffffffff)})',
'textStyle: TextStyle(inherit: true, decoration: TextDecoration.underline)',
'textAlign: TextAlign.center',
'wait duration: $wait',

View File

@ -13,6 +13,65 @@ class SillyBorder extends BoxBorder {
dynamic noSuchMethod(Invocation invocation) => null;
}
bool _sideMatches(BorderSide x, BorderSide y) {
const double limit = 1/255;
return (x.color.a - y.color.a).abs() < limit
&& (x.color.r - y.color.r).abs() < limit
&& (x.color.g - y.color.g).abs() < limit
&& (x.color.b - y.color.b).abs() < limit
&& x.width == y.width
&& x.style == y.style
&& x.strokeAlign == y.strokeAlign;
}
class _BorderMatches extends Matcher {
_BorderMatches(this._target);
final dynamic _target;
@override
Description describe(Description description) {
description.add('expected $_target');
return description;
}
@override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
return item is Border &&
_target is Border &&
_sideMatches(item.top, _target.top) &&
_sideMatches(item.right, _target.right) &&
_sideMatches(item.bottom, _target.bottom) &&
_sideMatches(item.left, _target.left);
}
}
Matcher _matchesBorder(dynamic border) => _BorderMatches(border);
class _BorderDirectionalMatches extends Matcher {
_BorderDirectionalMatches(this._target);
final dynamic _target;
@override
Description describe(Description description) {
description.add('expected $_target');
return description;
}
@override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
return item is BorderDirectional &&
_target is BorderDirectional &&
_sideMatches(item.top, _target.top) &&
_sideMatches(item.start, _target.start) &&
_sideMatches(item.bottom, _target.bottom) &&
_sideMatches(item.end, _target.end);
}
}
Matcher _matchesBorderDirectional(dynamic border) => _BorderDirectionalMatches(border);
void main() {
test('BoxBorder.lerp', () {
// names of the form fooAtX are foo, lerped X% of the way to null
@ -73,10 +132,10 @@ void main() {
expect(BoxBorder.lerp(directionalWithTop10, null, 0.25), const BorderDirectional(top: BorderSide(width: 7.5)));
expect(BoxBorder.lerp(null, directionalWithTop10, 0.25), const BorderDirectional(top: BorderSide(width: 2.5)));
expect(BoxBorder.lerp(directionalWithTop10, visualWithTop100, 0.25), const Border(top: BorderSide(width: 32.5)));
expect(BoxBorder.lerp(visualWithSides10, directionalWithMagentaTop5, 0.25), visualWithSides10At75 + directionalWithMagentaTop5At25);
expect(BoxBorder.lerp(visualWithSides10, directionalWithMagentaTop5, 0.25), _matchesBorder(visualWithSides10At75 + directionalWithMagentaTop5At25));
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.25), Border(top: BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.25)!)));
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.25), visualWithSides10At50);
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.25), visualWithYellowTop5At75 + directionalWithSides10At25);
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.25), _matchesBorder(visualWithSides10At50));
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.25), _matchesBorderDirectional(visualWithYellowTop5At75 + directionalWithSides10At25));
expect(() => BoxBorder.lerp(const SillyBorder(), const Border(), 0.25), throwsFlutterError);
expect(BoxBorder.lerp(null, null, 0.75), null);
@ -85,10 +144,10 @@ void main() {
expect(BoxBorder.lerp(directionalWithTop10, null, 0.75), const BorderDirectional(top: BorderSide(width: 2.5)));
expect(BoxBorder.lerp(null, directionalWithTop10, 0.75), const BorderDirectional(top: BorderSide(width: 7.5)));
expect(BoxBorder.lerp(directionalWithTop10, visualWithTop100, 0.75), const Border(top: BorderSide(width: 77.5)));
expect(BoxBorder.lerp(visualWithSides10, directionalWithMagentaTop5, 0.75), visualWithSides10At25 + directionalWithMagentaTop5At75);
expect(BoxBorder.lerp(visualWithSides10, directionalWithMagentaTop5, 0.75), _matchesBorder(visualWithSides10At25 + directionalWithMagentaTop5At75));
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.75), Border(top: BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.75)!)));
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.75), directionalWithSides10At50);
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.75), visualWithYellowTop5At25 + directionalWithSides10At75);
expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.75), _matchesBorderDirectional(directionalWithSides10At50));
expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.75), _matchesBorderDirectional(visualWithYellowTop5At25 + directionalWithSides10At75));
expect(() => BoxBorder.lerp(const SillyBorder(), const Border(), 0.75), throwsFlutterError);
expect(BoxBorder.lerp(null, null, 1.0), null);

View File

@ -123,7 +123,7 @@ void main() {
test('BorderSide - toString', () {
expect(
const BorderSide(color: Color(0xFFAABBCC), width: 1.2345).toString(),
'BorderSide(color: Color(0xffaabbcc), width: 1.2)',
'BorderSide(color: ${const Color(0xffaabbcc)}, width: 1.2)',
);
});

View File

@ -56,7 +56,7 @@ void main() {
);
expect(side1.toString(), equals('BorderSide'));
expect(side2.toString(), equals('BorderSide(color: Color(0xff00ffff), width: 2.0)'));
expect(side2.toString(), equals('BorderSide(color: ${const Color(0xff00ffff)}, width: 2.0)'));
});
test('Border control test', () {
@ -156,8 +156,8 @@ void main() {
});
test('BoxShadow toString test', () {
expect(const BoxShadow(blurRadius: 4.0).toString(), equals('BoxShadow(Color(0xff000000), Offset(0.0, 0.0), 4.0, 0.0, BlurStyle.normal)'));
expect(const BoxShadow(blurRadius: 4.0, blurStyle: BlurStyle.solid).toString(), equals('BoxShadow(Color(0xff000000), Offset(0.0, 0.0), 4.0, 0.0, BlurStyle.solid)'));
expect(const BoxShadow(blurRadius: 4.0).toString(), equals('BoxShadow(${const Color(0xff000000)}, Offset(0.0, 0.0), 4.0, 0.0, BlurStyle.normal)'));
expect(const BoxShadow(blurRadius: 4.0, blurStyle: BlurStyle.solid).toString(), equals('BoxShadow(${const Color(0xff000000)}, Offset(0.0, 0.0), 4.0, 0.0, BlurStyle.solid)'));
});
testWidgets('BoxShadow BoxStyle.solid', (WidgetTester tester) async {

View File

@ -443,23 +443,23 @@ void main() {
const ColorSwatch<int> swatchB = ColorSwatch<int>(0xFFFFFFFF, <int, Color>{1: Color(0xFFFFFFFF)});
expect(
ColorSwatch.lerp(swatchA, swatchB, 0.0),
const ColorSwatch<int>(0x00000000, <int, Color>{1: Color(0x00000000)}),
isSameColorAs(const ColorSwatch<int>(0x00000000, <int, Color>{1: Color(0x00000000)})),
);
expect(
ColorSwatch.lerp(swatchA, swatchB, 0.5),
const ColorSwatch<int>(0x7F7F7F7F, <int, Color>{1: Color(0x7F7F7F7F)}),
isSameColorAs(const ColorSwatch<int>(0x7F7F7F7F, <int, Color>{1: Color(0x7F7F7F7F)})),
);
expect(
ColorSwatch.lerp(swatchA, swatchB, 1.0),
const ColorSwatch<int>(0xFFFFFFFF, <int, Color>{1: Color(0xFFFFFFFF)}),
isSameColorAs(const ColorSwatch<int>(0xFFFFFFFF, <int, Color>{1: Color(0xFFFFFFFF)})),
);
expect(
ColorSwatch.lerp(swatchA, swatchB, -0.1),
const ColorSwatch<int>(0x00000000, <int, Color>{1: Color(0x00000000)}),
isSameColorAs(const ColorSwatch<int>(0x00000000, <int, Color>{1: Color(0x00000000)})),
);
expect(
ColorSwatch.lerp(swatchA, swatchB, 1.1),
const ColorSwatch<int>(0xFFFFFFFF, <int, Color>{1: Color(0xFFFFFFFF)}),
isSameColorAs(const ColorSwatch<int>(0xFFFFFFFF, <int, Color>{1: Color(0xFFFFFFFF)})),
);
});

View File

@ -15,36 +15,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
// TODO(gaaclarke): Unify the different instances of _ColorMatcher.
/// Positive result if the colors would be mapped to the same argb8888 color.
class _ColorMatcher extends Matcher {
_ColorMatcher(this._target);
final ui.Color _target;
@override
Description describe(Description description) {
return description.add('matches "$_target"');
}
@override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
if (item is ui.Color) {
return item.colorSpace == _target.colorSpace &&
(item.a - _target.a).abs() <= 0.004 &&
(item.r - _target.r).abs() <= 0.004 &&
(item.g - _target.g).abs() <= 0.004 &&
(item.b - _target.b).abs() <= 0.004;
} else {
return false;
}
}
}
Matcher _matchesColor(ui.Color color) {
return _ColorMatcher(color);
}
void main() {
testWidgets('ImageDecoration.lerp 1', (WidgetTester tester) async {
final MemoryImage green = MemoryImage(Uint8List.fromList(<int>[
@ -208,17 +178,17 @@ void main() {
return getPixel(x, y);
}
const Color lime = Color(0xFF00FF00);
expect(getBlockPixel(0), _matchesColor(lime)); // pure green
expect(getBlockPixel(1), _matchesColor(lime)); // 100% green 0% red
expect(getBlockPixel(2), _matchesColor(const Color(0xFF19E600)));
expect(getBlockPixel(3), _matchesColor(const Color(0xFF33CC00)));
expect(getBlockPixel(4), _matchesColor(const Color(0xFF808000))); // 50-50 mix green/red
expect(getBlockPixel(5), _matchesColor(const Color(0xFFCD3200)));
expect(getBlockPixel(6), _matchesColor(const Color(0xFFE61900)));
expect(getBlockPixel(7), _matchesColor(const Color(0xFFFF0000))); // 0% green 100% red
expect(getBlockPixel(8), _matchesColor(const Color(0xFFFF0000))); // pure red
expect(getBlockPixel(0), isSameColorAs(lime)); // pure green
expect(getBlockPixel(1), isSameColorAs(lime)); // 100% green 0% red
expect(getBlockPixel(2), isSameColorAs(const Color(0xFF19E600)));
expect(getBlockPixel(3), isSameColorAs(const Color(0xFF33CC00)));
expect(getBlockPixel(4), isSameColorAs(const Color(0xFF808000))); // 50-50 mix green/red
expect(getBlockPixel(5), isSameColorAs(const Color(0xFFCD3200)));
expect(getBlockPixel(6), isSameColorAs(const Color(0xFFE61900)));
expect(getBlockPixel(7), isSameColorAs(const Color(0xFFFF0000))); // 0% green 100% red
expect(getBlockPixel(8), isSameColorAs(const Color(0xFFFF0000))); // pure red
for (int index = 9; index < 40; index += 1) {
expect(getBlockPixel(index), _matchesColor(lime));
expect(getBlockPixel(index), isSameColorAs(lime));
}
}

View File

@ -3,7 +3,7 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:ui' as ui show Color, ColorFilter, Image;
import 'dart:ui' as ui show ColorFilter, Image;
import 'package:fake_async/fake_async.dart';
import 'package:flutter/foundation.dart';
@ -14,36 +14,6 @@ import '../image_data.dart';
import '../painting/mocks_for_image_cache.dart';
import '../rendering/rendering_tester.dart';
/// Positive result if the colors would be mapped to the same argb8888 color.
class _ColorMatcher extends Matcher {
_ColorMatcher(this._target);
final ui.Color _target;
@override
Description describe(Description description) {
return description.add('matches "$_target"');
}
@override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
if (item is ui.Color) {
return item.colorSpace == _target.colorSpace &&
(item.a - _target.a).abs() <= (1 / 255) &&
(item.r - _target.r).abs() <= (1 / 255) &&
(item.g - _target.g).abs() <= (1 / 255) &&
(item.b - _target.b).abs() <= (1 / 255);
} else {
return false;
}
}
}
Matcher _matchesColor(ui.Color color) {
return _ColorMatcher(color);
}
class TestCanvas implements Canvas {
final List<Invocation> invocations = <Invocation>[];
@ -356,7 +326,7 @@ void main() {
expect(call.positionalArguments[3], isA<Paint>());
final Paint paint = call.positionalArguments[3] as Paint;
expect(paint.colorFilter, colorFilter);
expect(paint.color, _matchesColor(const Color(0x7F000000))); // 0.5 opacity
expect(paint.color, isSameColorAs(const Color(0x7F000000))); // 0.5 opacity
expect(paint.filterQuality, FilterQuality.high);
expect(paint.isAntiAlias, true);
expect(paint.invertColors, isTrue);
@ -407,19 +377,24 @@ void main() {
expect(error.diagnostics.length, 4);
expect(error.diagnostics[2], isA<DiagnosticsProperty<DecorationImage>>());
expect(error.diagnostics[3], isA<DiagnosticsProperty<ImageConfiguration>>());
expect(error.toStringDeep(),
expect(error.toStringDeep(wrapWidth: 640),
'FlutterError\n'
' DecorationImage.matchTextDirection can only be used when a\n'
' TextDirection is available.\n'
' When DecorationImagePainter.paint() was called, there was no text\n'
' direction provided in the ImageConfiguration object to match.\n'
' DecorationImage.matchTextDirection can only be used when a '
'TextDirection is available.\n'
' When DecorationImagePainter.paint() was called, there was no text '
'direction provided in the ImageConfiguration object to match.\n'
' The DecorationImage was:\n'
' DecorationImage(SynchronousTestImageProvider(),\n'
' ColorFilter.mode(Color(0xff00ff00), BlendMode.src),\n'
' BoxFit.contain, Alignment.center, centerSlice:\n'
' Rect.fromLTRB(10.0, 20.0, 40.0, 60.0), ImageRepeat.repeatY,\n'
' match text direction, scale 0.5, opacity 0.5,\n'
' FilterQuality.medium, invert colors, use anti-aliasing)\n'
' DecorationImage(SynchronousTestImageProvider(), '
'ColorFilter.mode(${const Color(0xff00ff00)}, BlendMode.src), '
'BoxFit.contain, Alignment.center, '
'centerSlice: Rect.fromLTRB(10.0, 20.0, 40.0, 60.0), '
'ImageRepeat.repeatY, '
'match text direction, '
'scale 0.5, '
'opacity 0.5, '
'FilterQuality.medium, '
'invert colors, '
'use anti-aliasing)\n'
' The ImageConfiguration was:\n'
' ImageConfiguration(size: Size(100.0, 100.0))\n',
);
@ -520,17 +495,17 @@ void main() {
BoxDecoration.lerp(
const BoxDecoration(),
const BoxDecoration(gradient: gradient),
0.25,
0.2,
),
const BoxDecoration(gradient: LinearGradient(colors: <Color>[ Color(0x00000000), Color(0x40FFFFFF) ])),
const BoxDecoration(gradient: LinearGradient(colors: <Color>[ Color(0x00000000), Color(0x33FFFFFF) ])),
);
expect(
BoxDecoration.lerp(
const BoxDecoration(),
const BoxDecoration(gradient: gradient),
0.75,
1/3,
),
const BoxDecoration(gradient: LinearGradient(colors: <Color>[ Color(0x00000000), Color(0xBFFFFFFF) ])),
const BoxDecoration(gradient: LinearGradient(colors: <Color>[ Color(0x00000000), Color(0x55FFFFFF) ])),
);
expect(
BoxDecoration.lerp(

View File

@ -74,13 +74,13 @@ void main() {
expect(
start.toString(),
equals(
'FlutterLogoDecoration(textColor: Color(0xffd4f144), style: stacked)',
'FlutterLogoDecoration(textColor: ${const Color(0xffd4f144)}, style: stacked)',
),
);
expect(
FlutterLogoDecoration.lerp(null, end, 0.5).toString(),
equals(
'FlutterLogoDecoration(textColor: Color(0xff81d4fa), style: stacked, transition -1.0:0.5)',
'FlutterLogoDecoration(textColor: ${const Color(0xff81d4fa)}, style: stacked, transition -1.0:0.5)',
),
);
});

View File

@ -12,6 +12,125 @@ import 'dart:math' as math;
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
bool _listDoubleMatches(List<double>? x, List<double>? y) {
if (x == null && y == null) {
return true;
}
if (x == null || y == null) {
return false;
}
if (x.length != y.length) {
return false;
}
for (int i = 0; i < x.length; i++) {
if ((x[i] - y[i]).abs() >= 0.0001) {
return false;
}
}
return true;
}
bool _listColorMatches(List<Color> x, List<Color> y) {
if (x.length != y.length) {
return false;
}
const double limit = 1/255;
for (int i = 0; i < x.length; i++) {
if ((x[i].a - y[i].a).abs() >= limit ||
(x[i].r - y[i].r).abs() >= limit ||
(x[i].g - y[i].g).abs() >= limit ||
(x[i].b - y[i].b).abs() >= limit) {
return false;
}
}
return true;
}
class _LinearGradientMatcher extends Matcher {
_LinearGradientMatcher(this._target);
final LinearGradient _target;
@override
Description describe(Description description) {
description.add('expected $_target');
return description;
}
@override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
return item is LinearGradient &&
item.begin == _target.begin &&
item.end == _target.end &&
item.tileMode == _target.tileMode &&
item.transform == _target.transform &&
_listColorMatches(item.colors, _target.colors) &&
_listDoubleMatches(item.stops, _target.stops);
}
}
Matcher _matchesLinearGradient(LinearGradient target) =>
_LinearGradientMatcher(target);
class _RadialGradientMatcher extends Matcher {
_RadialGradientMatcher(this._target);
final RadialGradient _target;
@override
Description describe(Description description) {
description.add('expected $_target');
return description;
}
@override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
if (item is RadialGradient) {
return item.center == _target.center &&
item.radius == _target.radius &&
item.tileMode == _target.tileMode &&
item.transform == _target.transform &&
item.focal == _target.focal &&
item.focalRadius == _target.focalRadius &&
_listColorMatches(item.colors, _target.colors) &&
_listDoubleMatches(item.stops, _target.stops);
} else {
return false;
}
}
}
Matcher _matchesRadialGradient(RadialGradient target) =>
_RadialGradientMatcher(target);
class _SweepGradientMatcher extends Matcher {
_SweepGradientMatcher(this._target);
final SweepGradient _target;
@override
Description describe(Description description) {
description.add('expected $_target');
return description;
}
@override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
if (item is SweepGradient) {
return item.center == _target.center &&
item.startAngle == _target.startAngle &&
item.endAngle == _target.endAngle &&
item.tileMode == _target.tileMode &&
item.transform == _target.transform &&
_listColorMatches(item.colors, _target.colors) &&
_listDoubleMatches(item.stops, _target.stops);
} else {
return false;
}
}
}
Matcher _matchesSweepGradient(SweepGradient target) =>
_SweepGradientMatcher(target);
void main() {
test('LinearGradient scale test', () {
const LinearGradient testGradient = LinearGradient(
@ -25,7 +144,7 @@ void main() {
);
final LinearGradient? actual = LinearGradient.lerp(null, testGradient, 0.25);
expect(actual, const LinearGradient(
expect(actual, _matchesLinearGradient(const LinearGradient(
begin: Alignment.bottomRight,
end: Alignment(0.7, 1.0),
colors: <Color>[
@ -33,7 +152,7 @@ void main() {
Color(0x04777777),
Color(0x11444444),
],
));
)));
});
test('LinearGradient lerp test', () {
@ -55,7 +174,7 @@ void main() {
);
final LinearGradient? actual = LinearGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const LinearGradient(
expect(actual, _matchesLinearGradient(const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.centerLeft,
colors: <Color>[
@ -63,7 +182,7 @@ void main() {
Color(0x77777777),
],
stops: <double>[0, 1],
));
)));
});
test('LinearGradient.lerp identical a,b', () {
@ -104,7 +223,7 @@ void main() {
);
final LinearGradient? actual = LinearGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const LinearGradient(
expect(actual, _matchesLinearGradient(const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.centerLeft,
colors: <Color>[
@ -117,7 +236,7 @@ void main() {
0.5,
1.0,
],
));
)));
});
test('LinearGradient lerp test with unequal number of colors', () {
@ -136,7 +255,7 @@ void main() {
);
final LinearGradient? actual = LinearGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const LinearGradient(
expect(actual, _matchesLinearGradient(const LinearGradient(
colors: <Color>[
Color(0x33333333),
Color(0x55555555),
@ -147,7 +266,7 @@ void main() {
0.5,
1.0,
],
));
)));
});
test('LinearGradient lerp test with stops and unequal number of colors', () {
@ -175,7 +294,7 @@ void main() {
);
final LinearGradient? actual = LinearGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const LinearGradient(
expect(actual, _matchesLinearGradient(const LinearGradient(
colors: <Color>[
Color(0x3B3B3B3B),
Color(0x55555555),
@ -188,7 +307,7 @@ void main() {
0.7,
1.0,
],
));
)));
});
test('LinearGradient lerp test with transforms', () {
@ -229,7 +348,7 @@ void main() {
],
).toString(),
equals(
'LinearGradient(begin: Alignment.topLeft, end: Alignment.bottomLeft, colors: [Color(0x33333333), Color(0x66666666)], tileMode: TileMode.clamp, transform: GradientRotation(radians: 1.6))',
'LinearGradient(begin: Alignment.topLeft, end: Alignment.bottomLeft, colors: [${const Color(0x33333333)}, ${const Color(0x66666666)}], tileMode: TileMode.clamp, transform: GradientRotation(radians: 1.6))',
),
);
});
@ -388,7 +507,7 @@ void main() {
);
final RadialGradient? actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const RadialGradient(
expect(actual, _matchesRadialGradient(const RadialGradient(
center: Alignment.topCenter,
radius: 15.0,
colors: <Color>[
@ -399,7 +518,7 @@ void main() {
0.0,
1.0,
],
));
)));
});
test('RadialGradient.lerp identical a,b', () {
@ -441,7 +560,7 @@ void main() {
final RadialGradient? actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const RadialGradient(
expect(actual, _matchesRadialGradient(const RadialGradient(
center: Alignment.topCenter,
radius: 15.0,
colors: <Color>[
@ -454,7 +573,7 @@ void main() {
0.5,
1.0,
],
));
)));
expect(actual!.focal, isNull);
});
@ -475,7 +594,7 @@ void main() {
);
final RadialGradient? actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const RadialGradient(
expect(actual, _matchesRadialGradient(const RadialGradient(
colors: <Color>[
Color(0x33333333),
Color(0x55555555),
@ -486,7 +605,7 @@ void main() {
0.5,
1.0,
],
));
)));
});
test('RadialGradient lerp test with stops and unequal number of colors', () {
@ -514,7 +633,7 @@ void main() {
);
final RadialGradient? actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const RadialGradient(
expect(actual, _matchesRadialGradient(const RadialGradient(
colors: <Color>[
Color(0x3B3B3B3B),
Color(0x55555555),
@ -527,7 +646,7 @@ void main() {
0.7,
1.0,
],
));
)));
});
test('RadialGradient lerp test with transforms', () {
@ -587,7 +706,7 @@ void main() {
);
final RadialGradient? actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const RadialGradient(
expect(actual, _matchesRadialGradient(const RadialGradient(
center: Alignment.topCenter,
focal: Alignment.center,
radius: 15.0,
@ -600,10 +719,10 @@ void main() {
0.0,
1.0,
],
));
)));
final RadialGradient? actual2 = RadialGradient.lerp(testGradient1, testGradient3, 0.5);
expect(actual2, const RadialGradient(
expect(actual2, _matchesRadialGradient(const RadialGradient(
center: Alignment.topCenter,
focal: Alignment(-0.5, 0.0),
radius: 15.0,
@ -616,7 +735,7 @@ void main() {
0.0,
1.0,
],
));
)));
});
@ -666,7 +785,7 @@ void main() {
);
final SweepGradient? actual = SweepGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const SweepGradient(
expect(actual, _matchesSweepGradient(const SweepGradient(
center: Alignment.topCenter,
startAngle: math.pi / 4,
endAngle: math.pi * 3/4,
@ -678,7 +797,7 @@ void main() {
0.0,
1.0,
],
));
)));
});
test('SweepGradient.lerp identical a,b', () {
@ -720,7 +839,7 @@ void main() {
);
final SweepGradient? actual = SweepGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const SweepGradient(
expect(actual, _matchesSweepGradient(const SweepGradient(
center: Alignment.topCenter,
startAngle: math.pi / 4,
endAngle: math.pi * 3/4,
@ -734,7 +853,7 @@ void main() {
0.5,
1.0,
],
));
)));
});
test('SweepGradient lerp test with unequal number of colors', () {
@ -753,7 +872,7 @@ void main() {
);
final SweepGradient? actual = SweepGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const SweepGradient(
expect(actual, _matchesSweepGradient(const SweepGradient(
colors: <Color>[
Color(0x33333333),
Color(0x55555555),
@ -764,7 +883,7 @@ void main() {
0.5,
1.0,
],
));
)));
});
test('SweepGradient lerp test with stops and unequal number of colors', () {
@ -792,7 +911,7 @@ void main() {
);
final SweepGradient? actual = SweepGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const SweepGradient(
expect(actual, _matchesSweepGradient(const SweepGradient(
colors: <Color>[
Color(0x3B3B3B3B),
Color(0x55555555),
@ -805,7 +924,7 @@ void main() {
0.7,
1.0,
],
));
)));
});
test('SweepGradient lerp test with transforms', () {
@ -846,14 +965,14 @@ void main() {
final SweepGradient actual = testGradient.scale(0.5);
expect(actual, const SweepGradient(
expect(actual, _matchesSweepGradient(const SweepGradient(
center: Alignment.topLeft,
endAngle: math.pi / 2,
colors: <Color>[
Color(0x80333333),
Color(0x80666666),
],
));
)));
});
test('SweepGradient withOpacity test', () {
@ -916,12 +1035,12 @@ void main() {
],
);
expect(Gradient.lerp(testGradient1, testGradient3, 0.0), testGradient1);
expect(Gradient.lerp(testGradient1, testGradient3, 0.5), testGradient2);
expect(Gradient.lerp(testGradient1, testGradient3, 1.0), testGradient3);
expect(Gradient.lerp(testGradient3, testGradient1, 0.0), testGradient3);
expect(Gradient.lerp(testGradient3, testGradient1, 0.5), testGradient2);
expect(Gradient.lerp(testGradient3, testGradient1, 1.0), testGradient1);
expect(Gradient.lerp(testGradient1, testGradient3, 0.0), _matchesRadialGradient(testGradient1));
expect(Gradient.lerp(testGradient1, testGradient3, 0.5), _matchesRadialGradient(testGradient2));
expect(Gradient.lerp(testGradient1, testGradient3, 1.0), _matchesRadialGradient(testGradient3));
expect(Gradient.lerp(testGradient3, testGradient1, 0.0), _matchesRadialGradient(testGradient3));
expect(Gradient.lerp(testGradient3, testGradient1, 0.5), _matchesRadialGradient(testGradient2));
expect(Gradient.lerp(testGradient3, testGradient1, 1.0), _matchesRadialGradient(testGradient1));
});
test('Gradient lerp test (LinearGradient to RadialGradient)', () {

View File

@ -85,7 +85,7 @@ void main() {
expect(const LinearBorderEdge(size: 0.5, alignment: -0.5).toString(), 'LinearBorderEdge(size: 0.5, alignment: -0.5)');
expect(LinearBorder.none.toString(), 'LinearBorder.none');
const BorderSide side = BorderSide(width: 10.0, color: Color(0xff123456));
expect(const LinearBorder(side: side).toString(), 'LinearBorder(side: BorderSide(color: Color(0xff123456), width: 10.0))');
expect(const LinearBorder(side: side).toString(), 'LinearBorder(side: BorderSide(color: ${const Color(0xff123456)}, width: 10.0))');
expect(
const LinearBorder(
side: side,
@ -95,7 +95,7 @@ void main() {
bottom: LinearBorderEdge(size: 0.75, alignment: 0.75),
).toString(),
'LinearBorder('
'side: BorderSide(color: Color(0xff123456), width: 10.0), '
'side: BorderSide(color: ${const Color(0xff123456)}, width: 10.0), '
'start: LinearBorderEdge(size: 0.0, alignment: -0.75), '
'end: LinearBorderEdge(size: 0.25, alignment: -0.5), '
'top: LinearBorderEdge(size: 0.5, alignment: 0.5), '

View File

@ -41,49 +41,49 @@ void main() {
final Border b2 = Border.all(color: const Color(0xFF0000FF));
expect(
(b1 + b2).toString(),
'Border.all(BorderSide(color: Color(0xff00ff00))) + '
'Border.all(BorderSide(color: Color(0xff0000ff)))',
'Border.all(BorderSide(color: ${const Color(0xff00ff00)})) + '
'Border.all(BorderSide(color: ${const Color(0xff0000ff)}))',
);
expect(
(b1 + (b2 + b2)).toString(),
'Border.all(BorderSide(color: Color(0xff00ff00))) + '
'Border.all(BorderSide(color: Color(0xff0000ff), width: 2.0))',
'Border.all(BorderSide(color: ${const Color(0xff00ff00)})) + '
'Border.all(BorderSide(color: ${const Color(0xff0000ff)}, width: 2.0))',
);
expect(
((b1 + b2) + b2).toString(),
'Border.all(BorderSide(color: Color(0xff00ff00))) + '
'Border.all(BorderSide(color: Color(0xff0000ff), width: 2.0))',
'Border.all(BorderSide(color: ${const Color(0xff00ff00)})) + '
'Border.all(BorderSide(color: ${const Color(0xff0000ff)}, width: 2.0))',
);
expect((b1 + b2) + b2, b1 + (b2 + b2));
expect(
(b1 + b2).scale(3.0).toString(),
'Border.all(BorderSide(color: Color(0xff00ff00), width: 3.0)) + '
'Border.all(BorderSide(color: Color(0xff0000ff), width: 3.0))',
'Border.all(BorderSide(color: ${const Color(0xff00ff00)}, width: 3.0)) + '
'Border.all(BorderSide(color: ${const Color(0xff0000ff)}, width: 3.0))',
);
expect(
(b1 + b2).scale(0.0).toString(),
'Border.all(BorderSide(color: Color(0xff00ff00), width: 0.0, style: none)) + '
'Border.all(BorderSide(color: Color(0xff0000ff), width: 0.0, style: none))',
'Border.all(BorderSide(color: ${const Color(0xff00ff00)}, width: 0.0, style: none)) + '
'Border.all(BorderSide(color: ${const Color(0xff0000ff)}, width: 0.0, style: none))',
);
expect(
ShapeBorder.lerp(b2 + b1, b1 + b2, 0.0).toString(),
'Border.all(BorderSide(color: Color(0xff0000ff))) + '
'Border.all(BorderSide(color: Color(0xff00ff00)))',
'Border.all(BorderSide(color: ${const Color(0xff0000ff)})) + '
'Border.all(BorderSide(color: ${const Color(0xff00ff00)}))',
);
expect(
ShapeBorder.lerp(b2 + b1, b1 + b2, 0.25).toString(),
'Border.all(BorderSide(color: Color(0xff003fbf))) + '
'Border.all(BorderSide(color: Color(0xff00bf3f)))',
ShapeBorder.lerp(b2 + b1, b1 + b2, 0.20).toString(),
'Border.all(BorderSide(color: ${const Color(0xff0033cc)})) + '
'Border.all(BorderSide(color: ${const Color(0xff00cc33)}))',
);
expect(
ShapeBorder.lerp(b2 + b1, b1 + b2, 0.5).toString(),
'Border.all(BorderSide(color: Color(0xff007f7f))) + '
'Border.all(BorderSide(color: Color(0xff007f7f)))',
ShapeBorder.lerp(b2 + b1, b1 + b2, 1/3).toString(),
'Border.all(BorderSide(color: ${const Color(0xff0055aa)})) + '
'Border.all(BorderSide(color: ${const Color(0xff00aa55)}))',
);
expect(
ShapeBorder.lerp(b2 + b1, b1 + b2, 1.0).toString(),
'Border.all(BorderSide(color: Color(0xff00ff00))) + '
'Border.all(BorderSide(color: Color(0xff0000ff)))',
'Border.all(BorderSide(color: ${const Color(0xff00ff00)})) + '
'Border.all(BorderSide(color: ${const Color(0xff0000ff)}))',
);
expect((b1 + b2).dimensions, const EdgeInsets.all(2.0));
const Rect rect = Rect.fromLTRB(11.0, 15.0, 299.0, 175.0);
@ -106,49 +106,49 @@ void main() {
const BorderDirectional b2 = BorderDirectional(top: side2, start: side2, end: side2, bottom: side2);
expect(
(b1 + b2).toString(),
'BorderDirectional(top: BorderSide(color: Color(0xff00ff00)), start: BorderSide(color: Color(0xff00ff00)), end: BorderSide(color: Color(0xff00ff00)), bottom: BorderSide(color: Color(0xff00ff00))) + '
'BorderDirectional(top: BorderSide(color: Color(0xff0000ff)), start: BorderSide(color: Color(0xff0000ff)), end: BorderSide(color: Color(0xff0000ff)), bottom: BorderSide(color: Color(0xff0000ff)))',
'BorderDirectional(top: BorderSide(color: ${const Color(0xff00ff00)}), start: BorderSide(color: ${const Color(0xff00ff00)}), end: BorderSide(color: ${const Color(0xff00ff00)}), bottom: BorderSide(color: ${const Color(0xff00ff00)})) + '
'BorderDirectional(top: BorderSide(color: ${const Color(0xff0000ff)}), start: BorderSide(color: ${const Color(0xff0000ff)}), end: BorderSide(color: ${const Color(0xff0000ff)}), bottom: BorderSide(color: ${const Color(0xff0000ff)}))',
);
expect(
(b1 + (b2 + b2)).toString(),
'BorderDirectional(top: BorderSide(color: Color(0xff00ff00)), start: BorderSide(color: Color(0xff00ff00)), end: BorderSide(color: Color(0xff00ff00)), bottom: BorderSide(color: Color(0xff00ff00))) + '
'BorderDirectional(top: BorderSide(color: Color(0xff0000ff), width: 2.0), start: BorderSide(color: Color(0xff0000ff), width: 2.0), end: BorderSide(color: Color(0xff0000ff), width: 2.0), bottom: BorderSide(color: Color(0xff0000ff), width: 2.0))',
'BorderDirectional(top: BorderSide(color: ${const Color(0xff00ff00)}), start: BorderSide(color: ${const Color(0xff00ff00)}), end: BorderSide(color: ${const Color(0xff00ff00)}), bottom: BorderSide(color: ${const Color(0xff00ff00)})) + '
'BorderDirectional(top: BorderSide(color: ${const Color(0xff0000ff)}, width: 2.0), start: BorderSide(color: ${const Color(0xff0000ff)}, width: 2.0), end: BorderSide(color: ${const Color(0xff0000ff)}, width: 2.0), bottom: BorderSide(color: ${const Color(0xff0000ff)}, width: 2.0))',
);
expect(
((b1 + b2) + b2).toString(),
'BorderDirectional(top: BorderSide(color: Color(0xff00ff00)), start: BorderSide(color: Color(0xff00ff00)), end: BorderSide(color: Color(0xff00ff00)), bottom: BorderSide(color: Color(0xff00ff00))) + '
'BorderDirectional(top: BorderSide(color: Color(0xff0000ff), width: 2.0), start: BorderSide(color: Color(0xff0000ff), width: 2.0), end: BorderSide(color: Color(0xff0000ff), width: 2.0), bottom: BorderSide(color: Color(0xff0000ff), width: 2.0))',
'BorderDirectional(top: BorderSide(color: ${const Color(0xff00ff00)}), start: BorderSide(color: ${const Color(0xff00ff00)}), end: BorderSide(color: ${const Color(0xff00ff00)}), bottom: BorderSide(color: ${const Color(0xff00ff00)})) + '
'BorderDirectional(top: BorderSide(color: ${const Color(0xff0000ff)}, width: 2.0), start: BorderSide(color: ${const Color(0xff0000ff)}, width: 2.0), end: BorderSide(color: ${const Color(0xff0000ff)}, width: 2.0), bottom: BorderSide(color: ${const Color(0xff0000ff)}, width: 2.0))',
);
expect((b1 + b2) + b2, b1 + (b2 + b2));
expect(
(b1 + b2).scale(3.0).toString(),
'BorderDirectional(top: BorderSide(color: Color(0xff00ff00), width: 3.0), start: BorderSide(color: Color(0xff00ff00), width: 3.0), end: BorderSide(color: Color(0xff00ff00), width: 3.0), bottom: BorderSide(color: Color(0xff00ff00), width: 3.0)) + '
'BorderDirectional(top: BorderSide(color: Color(0xff0000ff), width: 3.0), start: BorderSide(color: Color(0xff0000ff), width: 3.0), end: BorderSide(color: Color(0xff0000ff), width: 3.0), bottom: BorderSide(color: Color(0xff0000ff), width: 3.0))',
'BorderDirectional(top: BorderSide(color: ${const Color(0xff00ff00)}, width: 3.0), start: BorderSide(color: ${const Color(0xff00ff00)}, width: 3.0), end: BorderSide(color: ${const Color(0xff00ff00)}, width: 3.0), bottom: BorderSide(color: ${const Color(0xff00ff00)}, width: 3.0)) + '
'BorderDirectional(top: BorderSide(color: ${const Color(0xff0000ff)}, width: 3.0), start: BorderSide(color: ${const Color(0xff0000ff)}, width: 3.0), end: BorderSide(color: ${const Color(0xff0000ff)}, width: 3.0), bottom: BorderSide(color: ${const Color(0xff0000ff)}, width: 3.0))',
);
expect(
(b1 + b2).scale(0.0).toString(),
'BorderDirectional(top: BorderSide(color: Color(0xff00ff00), width: 0.0, style: none), start: BorderSide(color: Color(0xff00ff00), width: 0.0, style: none), end: BorderSide(color: Color(0xff00ff00), width: 0.0, style: none), bottom: BorderSide(color: Color(0xff00ff00), width: 0.0, style: none)) + '
'BorderDirectional(top: BorderSide(color: Color(0xff0000ff), width: 0.0, style: none), start: BorderSide(color: Color(0xff0000ff), width: 0.0, style: none), end: BorderSide(color: Color(0xff0000ff), width: 0.0, style: none), bottom: BorderSide(color: Color(0xff0000ff), width: 0.0, style: none))',
'BorderDirectional(top: BorderSide(color: ${const Color(0xff00ff00)}, width: 0.0, style: none), start: BorderSide(color: ${const Color(0xff00ff00)}, width: 0.0, style: none), end: BorderSide(color: ${const Color(0xff00ff00)}, width: 0.0, style: none), bottom: BorderSide(color: ${const Color(0xff00ff00)}, width: 0.0, style: none)) + '
'BorderDirectional(top: BorderSide(color: ${const Color(0xff0000ff)}, width: 0.0, style: none), start: BorderSide(color: ${const Color(0xff0000ff)}, width: 0.0, style: none), end: BorderSide(color: ${const Color(0xff0000ff)}, width: 0.0, style: none), bottom: BorderSide(color: ${const Color(0xff0000ff)}, width: 0.0, style: none))',
);
expect(
ShapeBorder.lerp(b2 + b1, b1 + b2, 0.0).toString(),
'BorderDirectional(top: BorderSide(color: Color(0xff0000ff)), start: BorderSide(color: Color(0xff0000ff)), end: BorderSide(color: Color(0xff0000ff)), bottom: BorderSide(color: Color(0xff0000ff))) + '
'BorderDirectional(top: BorderSide(color: Color(0xff00ff00)), start: BorderSide(color: Color(0xff00ff00)), end: BorderSide(color: Color(0xff00ff00)), bottom: BorderSide(color: Color(0xff00ff00)))',
'BorderDirectional(top: BorderSide(color: ${const Color(0xff0000ff)}), start: BorderSide(color: ${const Color(0xff0000ff)}), end: BorderSide(color: ${const Color(0xff0000ff)}), bottom: BorderSide(color: ${const Color(0xff0000ff)})) + '
'BorderDirectional(top: BorderSide(color: ${const Color(0xff00ff00)}), start: BorderSide(color: ${const Color(0xff00ff00)}), end: BorderSide(color: ${const Color(0xff00ff00)}), bottom: BorderSide(color: ${const Color(0xff00ff00)}))',
);
expect(
ShapeBorder.lerp(b2 + b1, b1 + b2, 0.25).toString(),
'BorderDirectional(top: BorderSide(color: Color(0xff003fbf)), start: BorderSide(color: Color(0xff003fbf)), end: BorderSide(color: Color(0xff003fbf)), bottom: BorderSide(color: Color(0xff003fbf))) + '
'BorderDirectional(top: BorderSide(color: Color(0xff00bf3f)), start: BorderSide(color: Color(0xff00bf3f)), end: BorderSide(color: Color(0xff00bf3f)), bottom: BorderSide(color: Color(0xff00bf3f)))',
ShapeBorder.lerp(b2 + b1, b1 + b2, 0.20).toString(),
'BorderDirectional(top: BorderSide(color: ${const Color(0xff0033cc)}), start: BorderSide(color: ${const Color(0xff0033cc)}), end: BorderSide(color: ${const Color(0xff0033cc)}), bottom: BorderSide(color: ${const Color(0xff0033cc)})) + '
'BorderDirectional(top: BorderSide(color: ${const Color(0xff00cc33)}), start: BorderSide(color: ${const Color(0xff00cc33)}), end: BorderSide(color: ${const Color(0xff00cc33)}), bottom: BorderSide(color: ${const Color(0xff00cc33)}))',
);
expect(
ShapeBorder.lerp(b2 + b1, b1 + b2, 0.5).toString(),
'BorderDirectional(top: BorderSide(color: Color(0xff007f7f)), start: BorderSide(color: Color(0xff007f7f)), end: BorderSide(color: Color(0xff007f7f)), bottom: BorderSide(color: Color(0xff007f7f))) + '
'BorderDirectional(top: BorderSide(color: Color(0xff007f7f)), start: BorderSide(color: Color(0xff007f7f)), end: BorderSide(color: Color(0xff007f7f)), bottom: BorderSide(color: Color(0xff007f7f)))',
ShapeBorder.lerp(b2 + b1, b1 + b2, 1/3).toString(),
'BorderDirectional(top: BorderSide(color: ${const Color(0xff0055aa)}), start: BorderSide(color: ${const Color(0xff0055aa)}), end: BorderSide(color: ${const Color(0xff0055aa)}), bottom: BorderSide(color: ${const Color(0xff0055aa)})) + '
'BorderDirectional(top: BorderSide(color: ${const Color(0xff00aa55)}), start: BorderSide(color: ${const Color(0xff00aa55)}), end: BorderSide(color: ${const Color(0xff00aa55)}), bottom: BorderSide(color: ${const Color(0xff00aa55)}))',
);
expect(
ShapeBorder.lerp(b2 + b1, b1 + b2, 1.0).toString(),
'BorderDirectional(top: BorderSide(color: Color(0xff00ff00)), start: BorderSide(color: Color(0xff00ff00)), end: BorderSide(color: Color(0xff00ff00)), bottom: BorderSide(color: Color(0xff00ff00))) + '
'BorderDirectional(top: BorderSide(color: Color(0xff0000ff)), start: BorderSide(color: Color(0xff0000ff)), end: BorderSide(color: Color(0xff0000ff)), bottom: BorderSide(color: Color(0xff0000ff)))',
'BorderDirectional(top: BorderSide(color: ${const Color(0xff00ff00)}), start: BorderSide(color: ${const Color(0xff00ff00)}), end: BorderSide(color: ${const Color(0xff00ff00)}), bottom: BorderSide(color: ${const Color(0xff00ff00)})) + '
'BorderDirectional(top: BorderSide(color: ${const Color(0xff0000ff)}), start: BorderSide(color: ${const Color(0xff0000ff)}), end: BorderSide(color: ${const Color(0xff0000ff)}), bottom: BorderSide(color: ${const Color(0xff0000ff)}))',
);
expect((b1 + b2).dimensions, const EdgeInsetsDirectional.fromSTEB(2.0, 2.0, 2.0, 2.0));
const Rect rect = Rect.fromLTRB(11.0, 15.0, 299.0, 175.0);

View File

@ -141,7 +141,7 @@ void main() {
expect(
s2.toString(),
equals(
'TextStyle(inherit: true, color: Color(0xff00ff00), size: 10.0, weight: 800, height: 100.0x, leadingDistribution: even)',
'TextStyle(inherit: true, color: ${const Color(0xff00ff00)}, size: 10.0, weight: 800, height: 100.0x, leadingDistribution: even)',
),
);
@ -478,7 +478,7 @@ void main() {
const TextStyle s2 = TextStyle(backgroundColor: Color(0xFF00FF00));
expect(s2.backgroundColor, const Color(0xFF00FF00));
expect(s2.toString(), 'TextStyle(inherit: true, backgroundColor: Color(0xff00ff00))');
expect(s2.toString(), 'TextStyle(inherit: true, backgroundColor: ${const Color(0xff00ff00)})');
final ui.TextStyle ts2 = s2.getTextStyle();
@ -488,7 +488,7 @@ void main() {
// test to just check for the color by using a regular expression.
expect(
ts2.toString(),
matches(RegExp(r'background: Paint\(Color\(0xff00ff00\).*\)')),
matches(RegExp(r'background: Paint\(Color\(.*\).*\)')),
);
});

View File

@ -193,7 +193,7 @@ void main() {
}
expect(result, isNotNull);
expect(
result.toStringDeep(),
result.toStringDeep(wrapWidth: 640),
equalsIgnoringHashCodes(
'FlutterError\n'
' The size property was assigned a size inappropriately.\n'
@ -206,21 +206,21 @@ void main() {
' constraints: BoxConstraints(w=800.0, h=600.0)\n'
' size: Size(800.0, 600.0)\n'
' decoration: BoxDecoration:\n'
' color: Color(0xff00ff00)\n'
' color: ${const Color(0xff00ff00)}\n'
' configuration: ImageConfiguration()\n'
' However, this second render object is not, or is no longer, a\n'
' child of the first, and it is therefore a violation of the\n'
' RenderBox layout protocol to use that size in the layout of the\n'
' first render object.\n'
' If the size was obtained at a time where it was valid to read the\n'
' size (because the second render object above was a child of the\n'
' first at the time), then it should be adopted using\n'
' debugAdoptSize at that time.\n'
' If the size comes from a grandchild or a render object from an\n'
' entirely different part of the render tree, then there is no way\n'
' to be notified when the size changes and therefore attempts to\n'
' read that size are almost certainly a source of bugs. A different\n'
' approach should be used.\n',
' However, this second render object is not, or is no longer, a '
'child of the first, and it is therefore a violation of the '
'RenderBox layout protocol to use that size in the layout of the '
'first render object.\n'
' If the size was obtained at a time where it was valid to read '
'the size (because the second render object above was a child of '
'the first at the time), then it should be adopted using '
'debugAdoptSize at that time.\n'
' If the size comes from a grandchild or a render object from an '
'entirely different part of the render tree, then there is no way '
'to be notified when the size changes and therefore attempts to '
'read that size are almost certainly a source of bugs. A different '
'approach should be used.\n',
),
);
expect(result.diagnostics.where((DiagnosticsNode node) => node.level == DiagnosticLevel.hint).length, 2);

View File

@ -944,7 +944,7 @@ void main() {
paragraph.paint(paintingContext, Offset.zero);
expect(paintingContext.canvas.drawnRect, const Rect.fromLTWH(14.0, 0.0, 56.0, 14.0));
expect(paintingContext.canvas.drawnRectPaint!.style, PaintingStyle.fill);
expect(paintingContext.canvas.drawnRectPaint!.color, selectionColor);
expect(paintingContext.canvas.drawnRectPaint!.color, isSameColorAs(selectionColor));
// Selection highlight is painted before text.
expect(paintingContext.canvas.drawnItemTypes, <Type>[Rect, ui.Paragraph]);
@ -952,7 +952,7 @@ void main() {
paragraph.paint(paintingContext, Offset.zero);
expect(paintingContext.canvas.drawnRect, const Rect.fromLTWH(28.0, 0.0, 28.0, 14.0));
expect(paintingContext.canvas.drawnRectPaint!.style, PaintingStyle.fill);
expect(paintingContext.canvas.drawnRectPaint!.color, selectionColor);
expect(paintingContext.canvas.drawnRectPaint!.color, isSameColorAs(selectionColor));
});
// Regression test for https://github.com/flutter/flutter/issues/126652.
@ -979,7 +979,7 @@ void main() {
paragraph.paint(paintingContext, Offset.zero);
expect(paintingContext.canvas.drawnRect!.isEmpty, false);
expect(paintingContext.canvas.drawnRectPaint!.style, PaintingStyle.fill);
expect(paintingContext.canvas.drawnRectPaint!.color, selectionColor);
expect(paintingContext.canvas.drawnRectPaint!.color, isSameColorAs(selectionColor));
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/61016
test('getPositionForOffset works', () async {

View File

@ -68,17 +68,17 @@ void main() {
expect(box, hasAGoodToStringDeep);
expect(
box.toStringDeep(minLevel: DiagnosticLevel.info),
box.toStringDeep(minLevel: DiagnosticLevel.info, wrapWidth: 300),
equalsIgnoringHashCodes(
'RenderDecoratedBox#00000\n'
' │ parentData: <none>\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │ decoration: BoxDecoration:\n'
' │ color: Color(0xff0000ff)\n'
' │ configuration: ImageConfiguration(bundle:\n'
'PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform:\n'
'android)\n'
' │ color: ${const Color(0xff0000ff)}\n'
' │ configuration: ImageConfiguration(bundle: '
'PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform: '
'android)\n'
'\n'
' └─child: RenderPadding#00000\n'
' │ parentData: <none> (can use size)\n'

View File

@ -715,7 +715,7 @@ void main() {
renderColoredBox.paint(mockContext, Offset.zero);
expect(mockCanvas.rects.single, const Rect.fromLTWH(0, 0, 800, 600));
expect(mockCanvas.paints.single.color, colorToPaint);
expect(mockCanvas.paints.single.color, isSameColorAs(colorToPaint));
expect(mockContext.children, isEmpty);
expect(mockContext.offsets, isEmpty);
});
@ -731,7 +731,7 @@ void main() {
renderColoredBox.paint(mockContext, Offset.zero);
expect(mockCanvas.rects.single, const Rect.fromLTWH(0, 0, 800, 600));
expect(mockCanvas.paints.single.color, colorToPaint);
expect(mockCanvas.paints.single.color, isSameColorAs(colorToPaint));
expect(mockContext.children.single, renderSizedBox);
expect(mockContext.offsets.single, Offset.zero);
});

View File

@ -75,7 +75,7 @@ void main() {
final RenderBox box = tester.renderObject(find.byType(Container));
expect(
box.toStringDeep(minLevel: DiagnosticLevel.info),
box.toStringDeep(minLevel: DiagnosticLevel.info, wrapWidth: 640),
equalsIgnoringHashCodes(
'RenderPadding#00000 relayoutBoundary=up1\n'
' │ parentData: offset=Offset(0.0, 0.0) (can use size)\n'
@ -94,10 +94,8 @@ void main() {
' │ constraints: BoxConstraints(w=53.0, h=78.0)\n'
' │ size: Size(53.0, 78.0)\n'
' │ decoration: BoxDecoration:\n'
' │ color: Color(0x7f0000ff)\n'
' │ configuration: ImageConfiguration(bundle:\n'
' │ PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform:\n'
' │ android)\n'
' │ color: ${const Color(0x7f0000ff)}\n'
' │ configuration: ImageConfiguration(bundle: PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform: android)\n'
'\n'
' └─child: _RenderColoredBox#00000\n'
' │ parentData: <none> (can use size)\n'
@ -130,10 +128,8 @@ void main() {
' constraints: BoxConstraints(w=25.0, h=33.0)\n'
' size: Size(25.0, 33.0)\n'
' decoration: BoxDecoration:\n'
' color: Color(0xffffff00)\n'
' configuration: ImageConfiguration(bundle:\n'
' PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform:\n'
' android)\n',
' color: ${const Color(0xffffff00)}\n'
' configuration: ImageConfiguration(bundle: PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform: android)\n',
),
);
});
@ -150,67 +146,67 @@ void main() {
// Using the redundant value to ensure the test is explicitly for
// debug diagnostics, regardless of any changes to the default value.
// ignore: avoid_redundant_argument_values
box.toStringDeep(minLevel: DiagnosticLevel.debug),
box.toStringDeep(minLevel: DiagnosticLevel.debug, wrapWidth: 600),
equalsIgnoringHashCodes(
'RenderPadding#00000 relayoutBoundary=up1\n'
' │ creator: Padding ← Container ← Align ← _FocusInheritedScope ←\n'
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus\n'
' │ ← FocusTraversalGroup ← MediaQuery ← _MediaQueryFromView ←\n'
'_PipelineOwnerScope ← _ViewScope ← ⋯\n'
'RenderPadding#0f959 relayoutBoundary=up1\n'
' │ creator: Padding ← Container ← Align ← _FocusInheritedScope ← '
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus'
'FocusTraversalGroup ← MediaQuery ← _MediaQueryFromView ← '
'_PipelineOwnerScope ← _ViewScope ← ⋯\n'
' │ parentData: offset=Offset(0.0, 0.0) (can use size)\n'
' │ constraints: BoxConstraints(0.0<=w<=800.0, 0.0<=h<=600.0)\n'
' │ size: Size(63.0, 88.0)\n'
' │ padding: EdgeInsets.all(5.0)\n'
'\n'
' └─child: RenderConstrainedBox#00000 relayoutBoundary=up2\n'
' │ creator: ConstrainedBox ← Padding ← Container ← Align ←\n'
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ←\n'
'_FocusInheritedScope ← Focus ← FocusTraversalGroup ← MediaQuery\n'
' │ ← _MediaQueryFromView ← _PipelineOwnerScope ← ⋯\n'
' └─child: RenderConstrainedBox#df6d6 relayoutBoundary=up2\n'
' │ creator: ConstrainedBox ← Padding ← Container ← Align ← '
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← '
'_FocusInheritedScope ← Focus ← FocusTraversalGroup ← MediaQuery'
'_MediaQueryFromView ← _PipelineOwnerScope ← ⋯\n'
' │ parentData: offset=Offset(5.0, 5.0) (can use size)\n'
' │ constraints: BoxConstraints(0.0<=w<=790.0, 0.0<=h<=590.0)\n'
' │ size: Size(53.0, 78.0)\n'
' │ additionalConstraints: BoxConstraints(w=53.0, h=78.0)\n'
'\n'
' └─child: RenderDecoratedBox#00000\n'
' │ creator: DecoratedBox ← ConstrainedBox ← Padding ← Container ←\n'
' │ Align ← _FocusInheritedScope ← _FocusScopeWithExternalFocusNode\n'
' │ ← _FocusInheritedScope ← Focus ← FocusTraversalGroup ←\n'
' MediaQuery ← _MediaQueryFromView ← ⋯\n'
' └─child: RenderDecoratedBox#7b39b\n'
' │ creator: DecoratedBox ← ConstrainedBox ← Padding ← '
'Container ← Align ← _FocusInheritedScope ← '
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus ← '
'FocusTraversalGroup ← MediaQuery ← _MediaQueryFromView ← ⋯\n'
' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=53.0, h=78.0)\n'
' │ size: Size(53.0, 78.0)\n'
' │ decoration: BoxDecoration:\n'
' │ color: Color(0x7f0000ff)\n'
' │ configuration: ImageConfiguration(bundle:\n'
' │ PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform:\n'
'android)\n'
' │ color: ${const Color(0x7f0000ff)}\n'
' │ configuration: ImageConfiguration(bundle: '
'PlatformAssetBundle#fe53b(), devicePixelRatio: 3.0, platform: '
'android)\n'
'\n'
' └─child: _RenderColoredBox#00000\n'
' │ creator: ColoredBox ← DecoratedBox ← ConstrainedBox ← Padding ←\n'
' │ Container ← Align ← _FocusInheritedScope ←\n'
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus\n'
' │ ← FocusTraversalGroup ← MediaQuery ← ⋯\n'
' └─child: _RenderColoredBox#6bd0d\n'
' │ creator: ColoredBox ← DecoratedBox ← ConstrainedBox ← '
'Padding ← Container ← Align ← _FocusInheritedScope ← '
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus'
'FocusTraversalGroup ← MediaQuery ← ⋯\n'
' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=53.0, h=78.0)\n'
' │ size: Size(53.0, 78.0)\n'
' │ behavior: opaque\n'
'\n'
' └─child: RenderPadding#00000\n'
' │ creator: Padding ← ColoredBox ← DecoratedBox ← ConstrainedBox ←\n'
' │ Padding ← Container ← Align ← _FocusInheritedScope ←\n'
' │ _FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus\n'
' ← FocusTraversalGroup ← ⋯\n'
' └─child: RenderPadding#d92f7\n'
' │ creator: Padding ← ColoredBox ← DecoratedBox ← '
'ConstrainedBox ← Padding ← Container ← Align ← '
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← '
'_FocusInheritedScope ← Focus ← FocusTraversalGroup ← ⋯\n'
' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=53.0, h=78.0)\n'
' │ size: Size(53.0, 78.0)\n'
' │ padding: EdgeInsets.all(7.0)\n'
'\n'
' └─child: RenderPositionedBox#00000\n'
' │ creator: Align ← Padding ← ColoredBox ← DecoratedBox ←\n'
' │ ConstrainedBox ← Padding ← Container ← Align ←\n'
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ←\n'
'_FocusInheritedScope ← Focus ← ⋯\n'
' └─child: RenderPositionedBox#aaa32\n'
' │ creator: Align ← Padding ← ColoredBox ← '
'DecoratedBox ← ConstrainedBox ← Padding ← Container ← Align ← '
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← '
'_FocusInheritedScope ← Focus ← ⋯\n'
' │ parentData: offset=Offset(7.0, 7.0) (can use size)\n'
' │ constraints: BoxConstraints(w=39.0, h=64.0)\n'
' │ size: Size(39.0, 64.0)\n'
@ -218,30 +214,30 @@ void main() {
' │ widthFactor: expand\n'
' │ heightFactor: expand\n'
'\n'
' └─child: RenderConstrainedBox#00000 relayoutBoundary=up1\n'
' │ creator: SizedBox ← Align ← Padding ← ColoredBox ← DecoratedBox ←\n'
' │ ConstrainedBox ← Padding ← Container ← Align ←\n'
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ←\n'
'_FocusInheritedScope ← ⋯\n'
' └─child: RenderConstrainedBox#49805 relayoutBoundary=up1\n'
' │ creator: SizedBox ← Align ← Padding ← ColoredBox ← '
'DecoratedBox ← ConstrainedBox ← Padding ← Container ← Align ← '
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← '
'_FocusInheritedScope ← ⋯\n'
' │ parentData: offset=Offset(14.0, 31.0) (can use size)\n'
' │ constraints: BoxConstraints(0.0<=w<=39.0, 0.0<=h<=64.0)\n'
' │ size: Size(25.0, 33.0)\n'
' │ additionalConstraints: BoxConstraints(w=25.0, h=33.0)\n'
'\n'
' └─child: RenderDecoratedBox#00000\n'
' creator: DecoratedBox ← SizedBox ← Align ← Padding ← ColoredBox ←\n'
' DecoratedBox ← ConstrainedBox ← Padding ← Container ← Align ←\n'
' _FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← ⋯\n'
' └─child: RenderDecoratedBox#7843f\n'
' creator: DecoratedBox ← SizedBox ← Align ← '
'Padding ← ColoredBox ← DecoratedBox ← ConstrainedBox ← Padding ← '
'Container ← Align ← _FocusInheritedScope ← '
'_FocusScopeWithExternalFocusNode ← ⋯\n'
' parentData: <none> (can use size)\n'
' constraints: BoxConstraints(w=25.0, h=33.0)\n'
' size: Size(25.0, 33.0)\n'
' decoration: BoxDecoration:\n'
' color: Color(0xffffff00)\n'
' configuration: ImageConfiguration(bundle:\n'
' PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform:\n'
' android)\n'
),
);
' color: ${const Color(0xffffff00)}\n'
' configuration: ImageConfiguration(bundle: '
'PlatformAssetBundle#fe53b(), devicePixelRatio: 3.0, platform: '
'android)\n'
));
});
testWidgets('has expected fine diagnostics', (WidgetTester tester) async {
@ -253,13 +249,13 @@ void main() {
final RenderBox box = tester.renderObject(find.byType(Container));
expect(
box.toStringDeep(minLevel: DiagnosticLevel.fine),
box.toStringDeep(minLevel: DiagnosticLevel.fine, wrapWidth: 600),
equalsIgnoringHashCodes(
'RenderPadding#00000 relayoutBoundary=up1\n'
' │ creator: Padding ← Container ← Align ← _FocusInheritedScope ←\n'
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus\n'
' │ ← FocusTraversalGroup ← MediaQuery ← _MediaQueryFromView ←\n'
'_PipelineOwnerScope ← _ViewScope ← ⋯\n'
'RenderPadding#68510 relayoutBoundary=up1\n'
' │ creator: Padding ← Container ← Align ← _FocusInheritedScope ← '
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus'
'FocusTraversalGroup ← MediaQuery ← _MediaQueryFromView ← '
'_PipelineOwnerScope ← _ViewScope ← ⋯\n'
' │ parentData: offset=Offset(0.0, 0.0) (can use size)\n'
' │ constraints: BoxConstraints(0.0<=w<=800.0, 0.0<=h<=600.0)\n'
' │ layer: null\n'
@ -268,11 +264,11 @@ void main() {
' │ padding: EdgeInsets.all(5.0)\n'
' │ textDirection: null\n'
'\n'
' └─child: RenderConstrainedBox#00000 relayoutBoundary=up2\n'
' │ creator: ConstrainedBox ← Padding ← Container ← Align ←\n'
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ←\n'
'_FocusInheritedScope ← Focus ← FocusTraversalGroup ← MediaQuery\n'
' │ ← _MediaQueryFromView ← _PipelineOwnerScope ← ⋯\n'
' └─child: RenderConstrainedBox#69988 relayoutBoundary=up2\n'
' │ creator: ConstrainedBox ← Padding ← Container ← Align ← '
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← '
'_FocusInheritedScope ← Focus ← FocusTraversalGroup ← MediaQuery'
'_MediaQueryFromView ← _PipelineOwnerScope ← ⋯\n'
' │ parentData: offset=Offset(5.0, 5.0) (can use size)\n'
' │ constraints: BoxConstraints(0.0<=w<=790.0, 0.0<=h<=590.0)\n'
' │ layer: null\n'
@ -280,33 +276,32 @@ void main() {
' │ size: Size(53.0, 78.0)\n'
' │ additionalConstraints: BoxConstraints(w=53.0, h=78.0)\n'
'\n'
' └─child: RenderDecoratedBox#00000\n'
' │ creator: DecoratedBox ← ConstrainedBox ← Padding ← Container ←\n'
' │ Align ← _FocusInheritedScope ← _FocusScopeWithExternalFocusNode\n'
' │ ← _FocusInheritedScope ← Focus ← FocusTraversalGroup ←\n'
' MediaQuery ← _MediaQueryFromView ← ⋯\n'
' └─child: RenderDecoratedBox#c7049\n'
' │ creator: DecoratedBox ← ConstrainedBox ← Padding ← '
'Container ← Align ← _FocusInheritedScope ← '
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus ← '
'FocusTraversalGroup ← MediaQuery ← _MediaQueryFromView ← ⋯\n'
' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=53.0, h=78.0)\n'
' │ layer: null\n'
' │ semantics node: null\n'
' │ size: Size(53.0, 78.0)\n'
' │ decoration: BoxDecoration:\n'
' │ color: Color(0x7f0000ff)\n'
' │ color: ${const Color(0x7f0000ff)}\n'
' │ image: null\n'
' │ border: null\n'
' │ borderRadius: null\n'
' │ boxShadow: null\n'
' │ gradient: null\n'
' │ shape: rectangle\n'
' │ configuration: ImageConfiguration(bundle:\n'
' │ PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform:\n'
' │ android)\n'
' │ configuration: ImageConfiguration(bundle: '
'PlatformAssetBundle#23b2a(), devicePixelRatio: 3.0, platform: android)\n'
'\n'
' └─child: _RenderColoredBox#00000\n'
' │ creator: ColoredBox ← DecoratedBox ← ConstrainedBox ← Padding ←\n'
' │ Container ← Align ← _FocusInheritedScope ←\n'
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus\n'
' │ ← FocusTraversalGroup ← MediaQuery ← ⋯\n'
' └─child: _RenderColoredBox#c8805\n'
' │ creator: ColoredBox ← DecoratedBox ← ConstrainedBox ← '
'Padding ← Container ← Align ← _FocusInheritedScope ← '
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus'
'FocusTraversalGroup ← MediaQuery ← ⋯\n'
' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=53.0, h=78.0)\n'
' │ layer: null\n'
@ -314,11 +309,11 @@ void main() {
' │ size: Size(53.0, 78.0)\n'
' │ behavior: opaque\n'
'\n'
' └─child: RenderPadding#00000\n'
' │ creator: Padding ← ColoredBox ← DecoratedBox ← ConstrainedBox ←\n'
' │ Padding ← Container ← Align ← _FocusInheritedScope ←\n'
' │ _FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus\n'
' ← FocusTraversalGroup ← ⋯\n'
' └─child: RenderPadding#0fab7\n'
' │ creator: Padding ← ColoredBox ← DecoratedBox ← '
'ConstrainedBox ← Padding ← Container ← Align ← '
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← '
'_FocusInheritedScope ← Focus ← FocusTraversalGroup ← ⋯\n'
' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=53.0, h=78.0)\n'
' │ layer: null\n'
@ -327,11 +322,11 @@ void main() {
' │ padding: EdgeInsets.all(7.0)\n'
' │ textDirection: null\n'
'\n'
' └─child: RenderPositionedBox#00000\n'
' │ creator: Align ← Padding ← ColoredBox ← DecoratedBox ←\n'
' │ ConstrainedBox ← Padding ← Container ← Align ←\n'
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ←\n'
'_FocusInheritedScope ← Focus ← ⋯\n'
' └─child: RenderPositionedBox#458fb\n'
' │ creator: Align ← Padding ← ColoredBox ← '
'DecoratedBox ← ConstrainedBox ← Padding ← Container ← Align ← '
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← '
'_FocusInheritedScope ← Focus ← ⋯\n'
' │ parentData: offset=Offset(7.0, 7.0) (can use size)\n'
' │ constraints: BoxConstraints(w=39.0, h=64.0)\n'
' │ layer: null\n'
@ -342,11 +337,11 @@ void main() {
' │ widthFactor: expand\n'
' │ heightFactor: expand\n'
'\n'
' └─child: RenderConstrainedBox#00000 relayoutBoundary=up1\n'
' │ creator: SizedBox ← Align ← Padding ← ColoredBox ← DecoratedBox ←\n'
' │ ConstrainedBox ← Padding ← Container ← Align ←\n'
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ←\n'
'_FocusInheritedScope ← ⋯\n'
' └─child: RenderConstrainedBox#16613 relayoutBoundary=up1\n'
' │ creator: SizedBox ← Align ← Padding ← ColoredBox ← '
'DecoratedBox ← ConstrainedBox ← Padding ← Container ← Align ← '
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← '
'_FocusInheritedScope ← ⋯\n'
' │ parentData: offset=Offset(14.0, 31.0) (can use size)\n'
' │ constraints: BoxConstraints(0.0<=w<=39.0, 0.0<=h<=64.0)\n'
' │ layer: null\n'
@ -354,26 +349,26 @@ void main() {
' │ size: Size(25.0, 33.0)\n'
' │ additionalConstraints: BoxConstraints(w=25.0, h=33.0)\n'
'\n'
' └─child: RenderDecoratedBox#00000\n'
' creator: DecoratedBox ← SizedBox ← Align ← Padding ← ColoredBox ←\n'
' DecoratedBox ← ConstrainedBox ← Padding ← Container ← Align ←\n'
' _FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← ⋯\n'
' └─child: RenderDecoratedBox#52bc3\n'
' creator: DecoratedBox ← SizedBox ← Align ← '
'Padding ← ColoredBox ← DecoratedBox ← ConstrainedBox ← Padding ← '
'Container ← Align ← _FocusInheritedScope ← '
'_FocusScopeWithExternalFocusNode ← ⋯\n'
' parentData: <none> (can use size)\n'
' constraints: BoxConstraints(w=25.0, h=33.0)\n'
' layer: null\n'
' semantics node: null\n'
' size: Size(25.0, 33.0)\n'
' decoration: BoxDecoration:\n'
' color: Color(0xffffff00)\n'
' color: ${const Color(0xffffff00)}\n'
' image: null\n'
' border: null\n'
' borderRadius: null\n'
' boxShadow: null\n'
' gradient: null\n'
' shape: rectangle\n'
' configuration: ImageConfiguration(bundle:\n'
' PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform:\n'
' android)\n'
' configuration: ImageConfiguration(bundle: '
'PlatformAssetBundle#23b2a(), devicePixelRatio: 3.0, platform: android)\n'
),
);
});
@ -387,14 +382,14 @@ void main() {
final RenderBox box = tester.renderObject(find.byType(Container));
expect(
box.toStringDeep(minLevel: DiagnosticLevel.hidden),
box.toStringDeep(minLevel: DiagnosticLevel.hidden, wrapWidth: 600),
equalsIgnoringHashCodes(
'RenderPadding#00000 relayoutBoundary=up1\n'
'RenderPadding#4a353 relayoutBoundary=up1\n'
' │ needsCompositing: false\n'
' │ creator: Padding ← Container ← Align ← _FocusInheritedScope ←\n'
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus\n'
' │ ← FocusTraversalGroup ← MediaQuery ← _MediaQueryFromView ←\n'
'_PipelineOwnerScope ← _ViewScope ← ⋯\n'
' │ creator: Padding ← Container ← Align ← _FocusInheritedScope ← '
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus'
'FocusTraversalGroup ← MediaQuery ← _MediaQueryFromView ← '
'_PipelineOwnerScope ← _ViewScope ← ⋯\n'
' │ parentData: offset=Offset(0.0, 0.0) (can use size)\n'
' │ constraints: BoxConstraints(0.0<=w<=800.0, 0.0<=h<=600.0)\n'
' │ layer: null\n'
@ -405,12 +400,12 @@ void main() {
' │ padding: EdgeInsets.all(5.0)\n'
' │ textDirection: null\n'
'\n'
' └─child: RenderConstrainedBox#00000 relayoutBoundary=up2\n'
' └─child: RenderConstrainedBox#e3b23 relayoutBoundary=up2\n'
' │ needsCompositing: false\n'
' │ creator: ConstrainedBox ← Padding ← Container ← Align ←\n'
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ←\n'
'_FocusInheritedScope ← Focus ← FocusTraversalGroup ← MediaQuery\n'
' │ ← _MediaQueryFromView ← _PipelineOwnerScope ← ⋯\n'
' │ creator: ConstrainedBox ← Padding ← Container ← Align ← '
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← '
'_FocusInheritedScope ← Focus ← FocusTraversalGroup ← MediaQuery'
'_MediaQueryFromView ← _PipelineOwnerScope ← ⋯\n'
' │ parentData: offset=Offset(5.0, 5.0) (can use size)\n'
' │ constraints: BoxConstraints(0.0<=w<=790.0, 0.0<=h<=590.0)\n'
' │ layer: null\n'
@ -420,12 +415,12 @@ void main() {
' │ size: Size(53.0, 78.0)\n'
' │ additionalConstraints: BoxConstraints(w=53.0, h=78.0)\n'
'\n'
' └─child: RenderDecoratedBox#00000\n'
' └─child: RenderDecoratedBox#1ca6c\n'
' │ needsCompositing: false\n'
' │ creator: DecoratedBox ← ConstrainedBox ← Padding ← Container ←\n'
' │ Align ← _FocusInheritedScope ← _FocusScopeWithExternalFocusNode\n'
' │ ← _FocusInheritedScope ← Focus ← FocusTraversalGroup ←\n'
' MediaQuery ← _MediaQueryFromView ← ⋯\n'
' │ creator: DecoratedBox ← ConstrainedBox ← Padding ← '
'Container ← Align ← _FocusInheritedScope ← '
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus ← '
'FocusTraversalGroup ← MediaQuery ← _MediaQueryFromView ← ⋯\n'
' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=53.0, h=78.0)\n'
' │ layer: null\n'
@ -434,23 +429,23 @@ void main() {
' │ isSemanticBoundary: false\n'
' │ size: Size(53.0, 78.0)\n'
' │ decoration: BoxDecoration:\n'
' │ color: Color(0x7f0000ff)\n'
' │ color: ${const Color(0x7f0000ff)}\n'
' │ image: null\n'
' │ border: null\n'
' │ borderRadius: null\n'
' │ boxShadow: null\n'
' │ gradient: null\n'
' │ shape: rectangle\n'
' │ configuration: ImageConfiguration(bundle:\n'
' │ PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform:\n'
'android)\n'
' │ configuration: ImageConfiguration(bundle: '
'PlatformAssetBundle#fe2c8(), devicePixelRatio: 3.0, platform: '
'android)\n'
'\n'
' └─child: _RenderColoredBox#00000\n'
' └─child: _RenderColoredBox#cff14\n'
' │ needsCompositing: false\n'
' │ creator: ColoredBox ← DecoratedBox ← ConstrainedBox ← Padding ←\n'
' │ Container ← Align ← _FocusInheritedScope ←\n'
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus\n'
' │ ← FocusTraversalGroup ← MediaQuery ← ⋯\n'
' │ creator: ColoredBox ← DecoratedBox ← ConstrainedBox ← '
'Padding ← Container ← Align ← _FocusInheritedScope ← '
'_FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus'
'FocusTraversalGroup ← MediaQuery ← ⋯\n'
' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=53.0, h=78.0)\n'
' │ layer: null\n'
@ -460,12 +455,12 @@ void main() {
' │ size: Size(53.0, 78.0)\n'
' │ behavior: opaque\n'
'\n'
' └─child: RenderPadding#00000\n'
' └─child: RenderPadding#f6d0f\n'
' │ needsCompositing: false\n'
' │ creator: Padding ← ColoredBox ← DecoratedBox ← ConstrainedBox ←\n'
' │ Padding ← Container ← Align ← _FocusInheritedScope ←\n'
' │ _FocusScopeWithExternalFocusNode ← _FocusInheritedScope ← Focus\n'
' ← FocusTraversalGroup ← ⋯\n'
' │ creator: Padding ← ColoredBox ← DecoratedBox ← '
'ConstrainedBox ← Padding ← Container ← Align ← '
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← '
'_FocusInheritedScope ← Focus ← FocusTraversalGroup ← ⋯\n'
' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=53.0, h=78.0)\n'
' │ layer: null\n'
@ -476,12 +471,12 @@ void main() {
' │ padding: EdgeInsets.all(7.0)\n'
' │ textDirection: null\n'
'\n'
' └─child: RenderPositionedBox#00000\n'
' └─child: RenderPositionedBox#4f7d2\n'
' │ needsCompositing: false\n'
' │ creator: Align ← Padding ← ColoredBox ← DecoratedBox \n'
' │ ConstrainedBox ← Padding ← Container ← Align ←\n'
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ←\n'
'_FocusInheritedScope ← Focus ← ⋯\n'
' │ creator: Align ← Padding ← ColoredBox ← DecoratedBox '
'← ConstrainedBox ← Padding ← Container ← Align ← '
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← '
'_FocusInheritedScope ← Focus ← ⋯\n'
' │ parentData: offset=Offset(7.0, 7.0) (can use size)\n'
' │ constraints: BoxConstraints(w=39.0, h=64.0)\n'
' │ layer: null\n'
@ -494,12 +489,12 @@ void main() {
' │ widthFactor: expand\n'
' │ heightFactor: expand\n'
'\n'
' └─child: RenderConstrainedBox#00000 relayoutBoundary=up1\n'
' └─child: RenderConstrainedBox#81408 relayoutBoundary=up1\n'
' │ needsCompositing: false\n'
' │ creator: SizedBox ← Align ← Padding ← ColoredBox ← DecoratedBox ←\n'
' │ ConstrainedBox ← Padding ← Container ← Align ←\n'
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ←\n'
'_FocusInheritedScope ← ⋯\n'
' │ creator: SizedBox ← Align ← Padding ← ColoredBox ← '
'DecoratedBox ← ConstrainedBox ← Padding ← Container ← Align ← '
'_FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← '
'_FocusInheritedScope ← ⋯\n'
' │ parentData: offset=Offset(14.0, 31.0) (can use size)\n'
' │ constraints: BoxConstraints(0.0<=w<=39.0, 0.0<=h<=64.0)\n'
' │ layer: null\n'
@ -509,11 +504,12 @@ void main() {
' │ size: Size(25.0, 33.0)\n'
' │ additionalConstraints: BoxConstraints(w=25.0, h=33.0)\n'
'\n'
' └─child: RenderDecoratedBox#00000\n'
' └─child: RenderDecoratedBox#b5693\n'
' needsCompositing: false\n'
' creator: DecoratedBox ← SizedBox ← Align ← Padding ← ColoredBox ←\n'
' DecoratedBox ← ConstrainedBox ← Padding ← Container ← Align ←\n'
' _FocusInheritedScope ← _FocusScopeWithExternalFocusNode ← ⋯\n'
' creator: DecoratedBox ← SizedBox ← Align ← '
'Padding ← ColoredBox ← DecoratedBox ← ConstrainedBox ← Padding ← '
'Container ← Align ← _FocusInheritedScope ← '
'_FocusScopeWithExternalFocusNode ← ⋯\n'
' parentData: <none> (can use size)\n'
' constraints: BoxConstraints(w=25.0, h=33.0)\n'
' layer: null\n'
@ -522,16 +518,15 @@ void main() {
' isSemanticBoundary: false\n'
' size: Size(25.0, 33.0)\n'
' decoration: BoxDecoration:\n'
' color: Color(0xffffff00)\n'
' color: ${const Color(0xffffff00)}\n'
' image: null\n'
' border: null\n'
' borderRadius: null\n'
' boxShadow: null\n'
' gradient: null\n'
' shape: rectangle\n'
' configuration: ImageConfiguration(bundle:\n'
' PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform:\n'
' android)\n'
' configuration: ImageConfiguration(bundle: '
'PlatformAssetBundle#fe2c8(), devicePixelRatio: 3.0, platform: android)\n'
),
);
});
@ -552,16 +547,17 @@ void main() {
}
expect(error, isNotNull);
expect(
error.toStringDeep(),
error.toStringDeep(wrapWidth: 600),
'FlutterError\n'
' BoxDecoration painter had mismatching save and restore calls.\n'
' Before painting the decoration, the canvas save count was 0.\n'
' After painting it, the canvas save count was 2. Every call to\n'
' save() or saveLayer() must be matched by a call to restore().\n'
' The decoration was:\n'
' BoxDecoration(color: Color(0xffffff00))\n'
' The painter was:\n'
' BoxPainter for BoxDecoration(color: Color(0xffffff00))\n',
' BoxDecoration painter had mismatching save and restore calls.\n'
' Before painting the decoration, the canvas save count was 0. '
'After painting it, the canvas save count was 2. Every call to '
'save() or saveLayer() must be matched by a call to restore().\n'
' The decoration was:\n'
' BoxDecoration(color: ${const Color(0xffffff00)})\n'
' The painter was:\n'
' BoxPainter for BoxDecoration(color: '
'${const Color(0xffffff00)})\n',
);
});
});

View File

@ -2316,6 +2316,7 @@ class _LoggingTestFocusNode extends FocusNode {
String prefixLineOne = '',
String? prefixOtherLines,
DiagnosticLevel minLevel = DiagnosticLevel.debug,
int wrapWidth = 65,
}) {
throw StateError("Shouldn't call toStringDeep here");
}

View File

@ -1261,7 +1261,7 @@ void main() {
expect(element, hasAGoodToStringDeep);
expect(
element.toStringDeep(),
element.toStringDeep(wrapWidth: 200),
equalsIgnoringHashCodes(
'Column-[GlobalKey#00000](direction: vertical, mainAxisAlignment: start, crossAxisAlignment: center, renderObject: RenderFlex#00000)\n'
'├Container\n'
@ -1270,7 +1270,7 @@ void main() {
'├Container-[GlobalKey#00000]\n'
'│└LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up1)\n'
'│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2)\n'
'├ColoredBox(color: MaterialColor(primary value: Color(0xff4caf50)), renderObject: _RenderColoredBox#00000 relayoutBoundary=up1)\n'
'├ColoredBox(color: MaterialColor(primary value: ${const Color(0xff4caf50)}), renderObject: _RenderColoredBox#00000 relayoutBoundary=up1)\n'
'│└Container\n'
'│ └LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up2)\n'
'│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up3)\n'

View File

@ -27,7 +27,7 @@ void main() {
expect(lerped.weight, 550.0);
expect(lerped.grade, 18.75);
expect(lerped.opticalSize, 45.75);
expect(lerped.color, const Color(0xBF7F7F7F));
expect(lerped.color, isSameColorAs(const Color(0xBF7F7F7F)));
expect(lerped.opacity, 0.625);
expect(lerped.shadows, const <Shadow>[Shadow(color: Color(0xAAAAAAAA), blurRadius: 0.75, offset: Offset(0.75, 0.75))]);
});
@ -52,7 +52,7 @@ void main() {
expect(lerped.weight, 150.0);
expect(lerped.grade, 6.25);
expect(lerped.opticalSize, 11.25);
expect(lerped.color, const Color(0x40FFFFFF));
expect(lerped.color, isSameColorAs(const Color(0x40FFFFFF)));
expect(lerped.opacity, 0.25);
expect(lerped.shadows, const <Shadow>[Shadow(color: Color(0xFFFFFFFF), blurRadius: 0.25, offset: Offset(0.25, 0.25))]);
});
@ -71,7 +71,7 @@ void main() {
expect(lerped.weight, 450.0);
expect(lerped.grade, 18.75);
expect(lerped.opticalSize, 33.75);
expect(lerped.color, const Color(0xBFFFFFFF));
expect(lerped.color, isSameColorAs(const Color(0xBFFFFFFF)));
expect(lerped.opacity, 0.75);
expect(lerped.shadows, const <Shadow>[Shadow(color: Color(0xFFFFFFFF), blurRadius: 0.75, offset: Offset(0.75, 0.75))]);
});

View File

@ -42,7 +42,7 @@ void main() {
end: const BoxDecoration(color: Color(0xFFFFFF00)),
);
final BoxDecoration result = tween.lerp(0.25) as BoxDecoration;
expect(result.color, const Color(0xFF3FFF00));
expect(result.color, isSameColorAs(const Color(0xFF3FFF00)));
});
testWidgets('EdgeInsetsTween control test', (WidgetTester tester) async {

View File

@ -4410,7 +4410,7 @@ void main() {
expect(description, <String>[
'data: something',
'semanticsLabel: something else',
'style: TextStyle(inherit: true, color: Color(0xff00ff00))',
'style: TextStyle(inherit: true, color: ${const Color(0xff00ff00)})',
'autofocus: true',
'showCursor: true',
'minLines: 2',
@ -4421,7 +4421,7 @@ void main() {
'cursorWidth: 1.0',
'cursorHeight: 1.0',
'cursorRadius: Radius.circular(0.0)',
'cursorColor: Color(0xff00ff00)',
'cursorColor: ${const Color(0xff00ff00)}',
'selection disabled',
'scrollPhysics: ClampingScrollPhysics',
]);

View File

@ -61,7 +61,7 @@ void main() {
RenderDecoratedBox actualBox = tester.renderObject(find.byType(DecoratedBox));
BoxDecoration actualDecoration = actualBox.decoration as BoxDecoration;
expect(actualDecoration.color, const Color(0xFFFFFFFF));
expect(actualDecoration.color, isSameColorAs(const Color(0xFFFFFFFF)));
expect(actualDecoration.boxShadow![0].blurRadius, 10.0);
expect(actualDecoration.boxShadow![0].spreadRadius, 4.0);
expect(actualDecoration.boxShadow![0].color, const Color(0x66000000));
@ -72,7 +72,7 @@ void main() {
actualBox = tester.renderObject(find.byType(DecoratedBox));
actualDecoration = actualBox.decoration as BoxDecoration;
expect(actualDecoration.color, const Color(0xFF7F7F7F));
expect(actualDecoration.color, isSameColorAs(const Color(0xFF7F7F7F)));
expect(actualDecoration.border, isA<Border>());
final Border border = actualDecoration.border! as Border;
expect(border.left.width, 2.5);
@ -118,10 +118,10 @@ void main() {
RenderDecoratedBox actualBox = tester.renderObject(find.byType(DecoratedBox));
BoxDecoration actualDecoration = actualBox.decoration as BoxDecoration;
expect(actualDecoration.color, const Color(0xFFFFFFFF));
expect(actualDecoration.color, isSameColorAs(const Color(0xFFFFFFFF)));
expect(actualDecoration.boxShadow![0].blurRadius, 10.0);
expect(actualDecoration.boxShadow![0].spreadRadius, 4.0);
expect(actualDecoration.boxShadow![0].color, const Color(0x66000000));
expect(actualDecoration.boxShadow![0].color, isSameColorAs(const Color(0x66000000)));
controller.value = 0.5;
@ -131,12 +131,12 @@ void main() {
// Same as the test above but the values should be much closer to the
// tween's end values given the easeOut curve.
expect(actualDecoration.color, const Color(0xFF505050));
expect(actualDecoration.color, isSameColorAs(const Color(0xFF505050)));
expect(actualDecoration.border, isA<Border>());
final Border border = actualDecoration.border! as Border;
expect(border.left.width, moreOrLessEquals(1.9, epsilon: 0.1));
expect(border.left.style, BorderStyle.solid);
expect(border.left.color, const Color(0xFF151515));
expect(border.left.color, isSameColorAs(const Color(0xFF151515)));
expect(actualDecoration.borderRadius!.resolve(TextDirection.ltr).topLeft.x, moreOrLessEquals(6.8, epsilon: 0.1));
expect(actualDecoration.shape, BoxShape.rectangle);
expect(actualDecoration.boxShadow![0].blurRadius, moreOrLessEquals(3.1, epsilon: 0.1));

View File

@ -62,7 +62,7 @@ void main() {
test('toString formats correctly', () {
const WidgetStateProperty<Color?> colorProperty = WidgetStatePropertyAll<Color?>(Color(0xFFFFFFFF));
expect(colorProperty.toString(), equals('WidgetStatePropertyAll(Color(0xffffffff))'));
expect(colorProperty.toString(), equals('WidgetStatePropertyAll(${const Color(0xffffffff)})'));
const WidgetStateProperty<double?> doubleProperty = WidgetStatePropertyAll<double?>(33 + 1/3);
expect(doubleProperty.toString(), equals('WidgetStatePropertyAll(33.3)'));
@ -124,7 +124,7 @@ void main() {
borderSide2,
0.0,
)!.resolve(enabled)!;
expect(borderSide.color, const Color(0xffff0000));
expect(borderSide.color, isSameColorAs(const Color(0xffff0000)));
expect(borderSide.width, 4.0);
// Using `0.5` interpolation value.
@ -133,7 +133,7 @@ void main() {
borderSide2,
0.5,
)!.resolve(enabled)!;
expect(borderSide.color, const Color(0xff7f007f));
expect(borderSide.color, isSameColorAs(const Color(0xff7f007f)));
expect(borderSide.width, 8.0);
// Using `1.0` interpolation value.
@ -142,7 +142,7 @@ void main() {
borderSide2,
1.0,
)!.resolve(enabled)!;
expect(borderSide.color, const Color(0xff0000ff));
expect(borderSide.color, isSameColorAs(const Color(0xff0000ff)));
expect(borderSide.width, 12.0);
});
}

View File

@ -222,9 +222,11 @@ const Matcher isNotInCard = _IsNotInCard();
/// Asserts that the object represents the same color as [color] when used to paint.
///
/// Specifically this matcher checks the object is of type [Color] and its [Color.value]
/// equals to that of the given [color].
Matcher isSameColorAs(Color color) => _ColorMatcher(targetColor: color);
/// Specifically this matcher checks the object is of type [Color] and its color
/// components fall below the delta specified by [threshold].
Matcher isSameColorAs(Color color, {double threshold = 0.004}) {
return _ColorMatcher(color, threshold);
}
/// Asserts that an object's toString() is a plausible one-line description.
///
@ -2117,22 +2119,25 @@ class _CoversSameAreaAs extends Matcher {
}
class _ColorMatcher extends Matcher {
const _ColorMatcher({
required this.targetColor,
});
_ColorMatcher(this._target, this._threshold);
final Color targetColor;
final ui.Color _target;
final double _threshold;
@override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
if (item is Color) {
return item == targetColor || item.value == targetColor.value;
}
return false;
Description describe(Description description) {
return description.add('matches color "$_target" with threshold "$_threshold".');
}
@override
Description describe(Description description) => description.add('matches color $targetColor');
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
return item is ui.Color &&
item.colorSpace == _target.colorSpace &&
(item.a - _target.a).abs() <= _threshold &&
(item.r - _target.r).abs() <= _threshold &&
(item.g - _target.g).abs() <= _threshold &&
(item.b - _target.b).abs() <= _threshold;
}
}
int _countDifferentPixels(Uint8List imageA, Uint8List imageB) {

View File

@ -86,6 +86,19 @@ typedef _ContextPainterFunction = void Function(PaintingContext context, Offset
/// The signature of functions that paint directly on a canvas.
typedef _CanvasPainterFunction = void Function(Canvas canvas);
bool _colorsMatch(Color x, Color? y) {
if (y == null) {
return false;
} else {
const double limit = 1/255;
return x.colorSpace == y.colorSpace &&
(x.a - y.a).abs() < limit &&
(x.r - y.r).abs() < limit &&
(x.g - y.g).abs() < limit &&
(x.b - y.b).abs() < limit;
}
}
/// Builder interface for patterns used to match display lists (canvas calls).
///
/// The [paints] matcher returns a [PaintPattern] so that you can build the
@ -944,7 +957,7 @@ abstract class _DrawCommandPaintPredicate extends _PaintPredicate {
@mustCallSuper
void verifyArguments(List<dynamic> arguments) {
final Paint paintArgument = arguments[paintArgumentIndex] as Paint;
if (color != null && paintArgument.color != color) {
if (color != null && !_colorsMatch(paintArgument.color, color)) {
throw FlutterError(
'It called $methodName with a paint whose color, '
'${paintArgument.color}, was not exactly the expected color ($color).'
@ -1421,7 +1434,7 @@ class _ShadowPredicate extends _PaintPredicate {
}
}
final Color actualColor = arguments[1] as Color;
if (color != null && actualColor != color) {
if (color != null && !_colorsMatch(actualColor, color)) {
throw FlutterError(
'It called $methodName with a color, $actualColor, which was not '
'exactly the expected color ($color).'

View File

@ -301,7 +301,7 @@ void main() {
'Expected contrast ratio of at least 4.5 but found 1.17 for a font '
'size of 14.0.\n'
'The computed colors was:\n'
'light - Color(0xfffafafa), dark - Color(0xffffeb3b)\n'
'light - ${const Color(0xfffafafa)}, dark - ${const Color(0xffffeb3b)}\n'
'See also: https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html',
);
handle.dispose();
@ -333,7 +333,7 @@ void main() {
'Expected contrast ratio of at least 4.5 but found 1.16 for a font '
'size of 14.0.\n'
'The computed colors was:\n'
'light - Color(0xfffef7ff), dark - Color(0xffffeb3b)\n'
'light - ${const Color(0xfffef7ff)}, dark - ${const Color(0xffffeb3b)}\n'
'See also: https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html',
);
handle.dispose();

View File

@ -357,6 +357,16 @@ void main() {
const _CustomColor(0xFF123456),
isSameColorAs(const _CustomColor(0xFF123456, isEqual: false)),
);
expect(
const Color(0x00000000),
isNot(isSameColorAs(const Color(0x00000002))),
);
expect(
const Color(0x00000000),
isSameColorAs(const Color(0x00000002), threshold: 0.008),
);
});
group('coversSameAreaAs', () {