diff --git a/packages/flutter/lib/src/material/input_border.dart b/packages/flutter/lib/src/material/input_border.dart index 9b8dc4ce109d..82f081779171 100644 --- a/packages/flutter/lib/src/material/input_border.dart +++ b/packages/flutter/lib/src/material/input_border.dart @@ -259,12 +259,13 @@ class UnderlineInputBorder extends InputBorder { if (other.runtimeType != runtimeType) { return false; } - return other is InputBorder - && other.borderSide == borderSide; + return other is UnderlineInputBorder + && other.borderSide == borderSide + && other.borderRadius == borderRadius; } @override - int get hashCode => borderSide.hashCode; + int get hashCode => Object.hash(borderSide, borderRadius); } /// Draws a rounded rectangle around an [InputDecorator]'s container. diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index f2b3575cf14e..2ea7443a6921 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -5338,11 +5338,40 @@ void main() { gapPadding: 32.0, )); 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 - const UnderlineInputBorder underlineInputBorder = UnderlineInputBorder(borderSide: BorderSide(color: Colors.blue)); - expect(underlineInputBorder, const UnderlineInputBorder(borderSide: BorderSide(color: Colors.blue))); + // UnderlineInputBorder's equality is defined by the borderSide and borderRadius + const UnderlineInputBorder underlineInputBorder = UnderlineInputBorder( + 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( + 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', () { @@ -5358,11 +5387,39 @@ void main() { gapPadding: 32.0, ).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 - const UnderlineInputBorder underlineInputBorder = UnderlineInputBorder(borderSide: BorderSide(color: Colors.blue)); - expect(underlineInputBorder.hashCode, const UnderlineInputBorder(borderSide: BorderSide(color: Colors.blue)).hashCode); - expect(underlineInputBorder.hashCode, isNot(const UnderlineInputBorder().hashCode)); + // UnderlineInputBorder's hashCode is defined by the borderSide and borderRadius + const UnderlineInputBorder underlineInputBorder = UnderlineInputBorder( + borderSide: BorderSide(color: Colors.blue), + 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 {