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

This commit is contained in:
Hans Muller 2018-01-18 17:15:43 -08:00 committed by GitHub
parent 2e4522f7ec
commit 629d325284
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -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

View file

@ -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);
});
}