Unverified Commit 629d3252 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Fix: InputDecorator fails with null border, non-null labelText (#14166)

parent 2e4522f7
......@@ -998,7 +998,8 @@ class _RenderDecoration extends RenderBox {
final double t = decoration.floatingLabelProgress;
// The center of the outline border label ends up a little below the
// center of the top border line.
final double floatingY = decoration.border.isOutline ? -labelHeight * 0.25 : contentPadding.top;
final bool isOutlineBorder = decoration.border != null && decoration.border.isOutline;
final double floatingY = isOutlineBorder ? -labelHeight * 0.25 : contentPadding.top;
final double scale = lerpDouble(1.0, 0.75, t);
final double dx = textDirection == TextDirection.rtl
? labelOffset.dx + label.size.width * (1.0 - scale) // origin is on the right
......
......@@ -913,4 +913,23 @@ void main() {
"InputDecorator-[<'key'>](decoration: InputDecoration(border: UnderlineInputBorder()), baseStyle: TextStyle(<all styles inherited>), isFocused: false, isEmpty: false)",
);
});
testWidgets('InputDecorator with null border and label', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/14165
await tester.pumpWidget(
buildInputDecorator(
// isEmpty: false (default)
// isFocused: false (default)
decoration: const InputDecoration(
labelText: 'label',
border: null,
),
),
);
expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 56.0));
expect(getBorderWeight(tester), 0.0);
expect(tester.getTopLeft(find.text('label')).dy, 12.0);
expect(tester.getBottomLeft(find.text('label')).dy, 24.0);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment