FIX: UnderlineInputBorder hashCode and equality by including borderRadius (#118284)
This commit is contained in:
parent
957781a108
commit
f10965f2d3
@ -259,12 +259,13 @@ class UnderlineInputBorder extends InputBorder {
|
|||||||
if (other.runtimeType != runtimeType) {
|
if (other.runtimeType != runtimeType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return other is InputBorder
|
return other is UnderlineInputBorder
|
||||||
&& other.borderSide == borderSide;
|
&& other.borderSide == borderSide
|
||||||
|
&& other.borderRadius == borderRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => borderSide.hashCode;
|
int get hashCode => Object.hash(borderSide, borderRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draws a rounded rectangle around an [InputDecorator]'s container.
|
/// Draws a rounded rectangle around an [InputDecorator]'s container.
|
||||||
|
@ -5338,11 +5338,40 @@ void main() {
|
|||||||
gapPadding: 32.0,
|
gapPadding: 32.0,
|
||||||
));
|
));
|
||||||
expect(outlineInputBorder, isNot(const OutlineInputBorder()));
|
expect(outlineInputBorder, isNot(const OutlineInputBorder()));
|
||||||
|
expect(outlineInputBorder, isNot(const OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.red),
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(9.0)),
|
||||||
|
gapPadding: 32.0,
|
||||||
|
)));
|
||||||
|
expect(outlineInputBorder, isNot(const OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.blue),
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||||
|
gapPadding: 32.0,
|
||||||
|
)));
|
||||||
|
expect(outlineInputBorder, isNot(const OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.blue),
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(9.0)),
|
||||||
|
gapPadding: 33.0,
|
||||||
|
)));
|
||||||
|
|
||||||
// UnderlineInputBorder's equality is defined only by the borderSide
|
// UnderlineInputBorder's equality is defined by the borderSide and borderRadius
|
||||||
const UnderlineInputBorder underlineInputBorder = UnderlineInputBorder(borderSide: BorderSide(color: Colors.blue));
|
const UnderlineInputBorder underlineInputBorder = UnderlineInputBorder(
|
||||||
expect(underlineInputBorder, const UnderlineInputBorder(borderSide: BorderSide(color: Colors.blue)));
|
borderSide: BorderSide(color: Colors.blue),
|
||||||
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(5.0), topRight: Radius.circular(5.0)),
|
||||||
|
);
|
||||||
|
expect(underlineInputBorder, const UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.blue),
|
||||||
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(5.0), topRight: Radius.circular(5.0)),
|
||||||
|
));
|
||||||
expect(underlineInputBorder, isNot(const UnderlineInputBorder()));
|
expect(underlineInputBorder, isNot(const UnderlineInputBorder()));
|
||||||
|
expect(underlineInputBorder, isNot(const UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.red),
|
||||||
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(5.0), topRight: Radius.circular(5.0)),
|
||||||
|
)));
|
||||||
|
expect(underlineInputBorder, isNot(const UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.blue),
|
||||||
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(6.0), topRight: Radius.circular(6.0)),
|
||||||
|
)));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('InputBorder hashCodes', () {
|
test('InputBorder hashCodes', () {
|
||||||
@ -5358,11 +5387,39 @@ void main() {
|
|||||||
gapPadding: 32.0,
|
gapPadding: 32.0,
|
||||||
).hashCode);
|
).hashCode);
|
||||||
expect(outlineInputBorder.hashCode, isNot(const OutlineInputBorder().hashCode));
|
expect(outlineInputBorder.hashCode, isNot(const OutlineInputBorder().hashCode));
|
||||||
|
expect(outlineInputBorder.hashCode, isNot(const OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(9.0)),
|
||||||
|
borderSide: BorderSide(color: Colors.red),
|
||||||
|
gapPadding: 32.0,
|
||||||
|
).hashCode));
|
||||||
|
expect(outlineInputBorder.hashCode, isNot(const OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||||
|
borderSide: BorderSide(color: Colors.blue),
|
||||||
|
gapPadding: 32.0,
|
||||||
|
).hashCode));
|
||||||
|
expect(outlineInputBorder.hashCode, isNot(const OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(9.0)),
|
||||||
|
borderSide: BorderSide(color: Colors.blue),
|
||||||
|
gapPadding: 33.0,
|
||||||
|
).hashCode));
|
||||||
|
|
||||||
// UnderlineInputBorder's hashCode is defined only by the borderSide
|
// UnderlineInputBorder's hashCode is defined by the borderSide and borderRadius
|
||||||
const UnderlineInputBorder underlineInputBorder = UnderlineInputBorder(borderSide: BorderSide(color: Colors.blue));
|
const UnderlineInputBorder underlineInputBorder = UnderlineInputBorder(
|
||||||
expect(underlineInputBorder.hashCode, const UnderlineInputBorder(borderSide: BorderSide(color: Colors.blue)).hashCode);
|
borderSide: BorderSide(color: Colors.blue),
|
||||||
expect(underlineInputBorder.hashCode, isNot(const UnderlineInputBorder().hashCode));
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(5.0), topRight: Radius.circular(5.0)),
|
||||||
|
);
|
||||||
|
expect(underlineInputBorder.hashCode, const UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.blue),
|
||||||
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(5.0), topRight: Radius.circular(5.0)),
|
||||||
|
).hashCode);
|
||||||
|
expect(underlineInputBorder.hashCode, isNot(const UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.red),
|
||||||
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(5.0), topRight: Radius.circular(5.0)),
|
||||||
|
).hashCode));
|
||||||
|
expect(underlineInputBorder.hashCode, isNot(const UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.blue),
|
||||||
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(6.0), topRight: Radius.circular(6.0)),
|
||||||
|
).hashCode));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('InputDecorationTheme implements debugFillDescription', (WidgetTester tester) async {
|
testWidgets('InputDecorationTheme implements debugFillDescription', (WidgetTester tester) async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user