mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
Fix: InputDecorator fails with null border, non-null labelText (#14166)
This commit is contained in:
parent
2e4522f7ec
commit
629d325284
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue