Skip to content

Commit 784f19c

Browse files
authored
Fix BorderSide.none requiring explicit transparent color for UnderlineInputBorder (#145329)
Fix could have been "paint transparent when Border none" but, following other Borders, we will just not paint anything. Fix flutter/flutter#143746
1 parent e1c6445 commit 784f19c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/flutter/lib/src/material/input_border.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ class UnderlineInputBorder extends InputBorder {
243243
double gapPercentage = 0.0,
244244
TextDirection? textDirection,
245245
}) {
246+
if (borderSide.style == BorderStyle.none) {
247+
return;
248+
}
249+
246250
if (borderRadius.bottomLeft != Radius.zero || borderRadius.bottomRight != Radius.zero) {
247251
// This prevents the border from leaking the color due to anti-aliasing rounding errors.
248252
final BorderRadius updatedBorderRadius = BorderRadius.only(

packages/flutter/test/material/input_decorator_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9729,4 +9729,18 @@ void main() {
97299729
expect(tester.renderObject<RenderBox>(find.text('COUNTER')).size, Size.zero);
97309730
});
97319731
});
9732+
9733+
testWidgets('UnderlineInputBorder with BorderStyle.none should not show anything', (WidgetTester tester) async {
9734+
// Regression test for https://github.com/flutter/flutter/issues/143746
9735+
const InputDecoration decoration = InputDecoration(
9736+
enabledBorder: UnderlineInputBorder(
9737+
borderSide: BorderSide(style: BorderStyle.none),
9738+
borderRadius: BorderRadius.all(Radius.circular(4)),
9739+
),
9740+
);
9741+
9742+
await tester.pumpWidget(buildInputDecorator(decoration: decoration));
9743+
final RenderBox box = tester.renderObject(find.byType(InputDecorator));
9744+
expect(box, isNot(paints..drrect()));
9745+
});
97329746
}

0 commit comments

Comments
 (0)