mirror of
https://github.com/flutter/flutter
synced 2024-10-13 03:32:55 +00:00
TextField intrinsic height layout bug (#66291)
Fixes a bug when TextField is wrapped in IntrinsicHeight and visual density is below standard.
This commit is contained in:
parent
3907e490a0
commit
4c7f746374
|
@ -1261,10 +1261,11 @@ class _RenderDecoration extends RenderBox {
|
|||
+ (label == null ? 0.0 : decoration.floatingLabelHeight)
|
||||
+ _lineHeight(width, <RenderBox>[prefix, input, suffix])
|
||||
+ subtextHeight
|
||||
+ contentPadding.bottom;
|
||||
+ contentPadding.bottom
|
||||
+ densityOffset.dy;
|
||||
final double minContainerHeight = decoration.isDense || expands
|
||||
? 0.0
|
||||
: kMinInteractiveDimension + densityOffset.dy;
|
||||
: kMinInteractiveDimension;
|
||||
return math.max(containerHeight, minContainerHeight);
|
||||
}
|
||||
|
||||
|
|
|
@ -4311,4 +4311,44 @@ void main() {
|
|||
expect(textTop, greaterThan(textFieldTop));
|
||||
expect(textTop, lessThan(textFieldBottom));
|
||||
});
|
||||
|
||||
testWidgets('visual density is included in the intrinsic height calculation', (WidgetTester tester) async {
|
||||
final UniqueKey key = UniqueKey();
|
||||
final UniqueKey intrinsicHeightKey = UniqueKey();
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Material(
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return Theme(
|
||||
data: Theme.of(context).copyWith(visualDensity: VisualDensity.compact),
|
||||
child: Center(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 35.0,
|
||||
child: TextField(
|
||||
key: key,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 35.0,
|
||||
child: IntrinsicHeight(
|
||||
child: TextField(
|
||||
key: intrinsicHeightKey,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
final double height = tester.getSize(find.byKey(key)).height;
|
||||
final double intrinsicHeight = tester.getSize(find.byKey(intrinsicHeightKey)).height;
|
||||
expect(intrinsicHeight, equals(height));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue