Skip to content

Commit 71a4c6f

Browse files
authored
Revert "Fix computeMinIntrinsicHeight in _RenderDecoration (flutter#87404)" (flutter#89667)
This reverts commit 5cf62e8.
1 parent 222a82e commit 71a4c6f

File tree

3 files changed

+14
-187
lines changed

3 files changed

+14
-187
lines changed

AUTHORS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,3 @@ Mirko Mucaria <skogsfrae@gmail.com>
8383
Karol Czeryna <karol.czeryna@gmail.com>
8484
Callum Moffat <callum@moffatman.com>
8585
Koutaro Mori <koutaro.mo@gmail.com>
86-
Sergei Smitskoi <sergflutterdev@gmail.com>

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

Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -971,17 +971,11 @@ class _RenderDecoration extends RenderBox {
971971
final BoxConstraints boxConstraints = layoutConstraints.loosen();
972972

973973
// Layout all the widgets used by InputDecorator
974+
boxToBaseline[prefix] = _layoutLineBox(prefix, boxConstraints);
975+
boxToBaseline[suffix] = _layoutLineBox(suffix, boxConstraints);
974976
boxToBaseline[icon] = _layoutLineBox(icon, boxConstraints);
975-
final BoxConstraints containerConstraints = boxConstraints.copyWith(
976-
maxWidth: boxConstraints.maxWidth - _boxSize(icon).width,
977-
);
978-
boxToBaseline[prefixIcon] = _layoutLineBox(prefixIcon, containerConstraints);
979-
boxToBaseline[suffixIcon] = _layoutLineBox(suffixIcon, containerConstraints);
980-
final BoxConstraints contentConstraints = containerConstraints.copyWith(
981-
maxWidth: containerConstraints.maxWidth - contentPadding.horizontal,
982-
);
983-
boxToBaseline[prefix] = _layoutLineBox(prefix, contentConstraints);
984-
boxToBaseline[suffix] = _layoutLineBox(suffix, contentConstraints);
977+
boxToBaseline[prefixIcon] = _layoutLineBox(prefixIcon, boxConstraints);
978+
boxToBaseline[suffixIcon] = _layoutLineBox(suffixIcon, boxConstraints);
985979

986980
final double inputWidth = math.max(
987981
0.0,
@@ -1017,14 +1011,18 @@ class _RenderDecoration extends RenderBox {
10171011
hint,
10181012
boxConstraints.copyWith(minWidth: inputWidth, maxWidth: inputWidth),
10191013
);
1020-
boxToBaseline[counter] = _layoutLineBox(counter, contentConstraints);
1014+
boxToBaseline[counter] = _layoutLineBox(counter, boxConstraints);
10211015

10221016
// The helper or error text can occupy the full width less the space
10231017
// occupied by the icon and counter.
10241018
boxToBaseline[helperError] = _layoutLineBox(
10251019
helperError,
1026-
contentConstraints.copyWith(
1027-
maxWidth: math.max(0.0, contentConstraints.maxWidth - _boxSize(counter).width),
1020+
boxConstraints.copyWith(
1021+
maxWidth: math.max(0.0, boxConstraints.maxWidth
1022+
- _boxSize(icon).width
1023+
- _boxSize(counter).width
1024+
- contentPadding.horizontal,
1025+
),
10281026
),
10291027
);
10301028

@@ -1269,45 +1267,15 @@ class _RenderDecoration extends RenderBox {
12691267

12701268
@override
12711269
double computeMinIntrinsicHeight(double width) {
1272-
final double iconHeight = _minHeight(icon, width);
1273-
final double iconWidth = _minWidth(icon, iconHeight);
1274-
1275-
width = math.max(width - iconWidth, 0.0);
1276-
1277-
final double prefixIconHeight = _minHeight(prefixIcon, width);
1278-
final double prefixIconWidth = _minWidth(prefixIcon, prefixIconHeight);
1279-
1280-
final double suffixIconHeight = _minHeight(suffixIcon, width);
1281-
final double suffixIconWidth = _minWidth(suffixIcon, suffixIconHeight);
1282-
1283-
width = math.max(width - contentPadding.horizontal, 0.0);
1284-
1285-
final double counterHeight = _minHeight(counter, width);
1286-
final double counterWidth = _minWidth(counter, counterHeight);
1287-
1288-
final double helperErrorAvailableWidth = math.max(width - counterWidth, 0.0);
1289-
final double helperErrorHeight = _minHeight(helperError, helperErrorAvailableWidth);
1290-
double subtextHeight = math.max(counterHeight, helperErrorHeight);
1270+
double subtextHeight = _lineHeight(width, <RenderBox?>[helperError, counter]);
12911271
if (subtextHeight > 0.0)
12921272
subtextHeight += subtextGap;
1293-
1294-
final double prefixHeight = _minHeight(prefix, width);
1295-
final double prefixWidth = _minWidth(prefix, prefixHeight);
1296-
1297-
final double suffixHeight = _minHeight(suffix, width);
1298-
final double suffixWidth = _minWidth(suffix, suffixHeight);
1299-
1300-
final double availableInputWidth = math.max(width - prefixWidth - suffixWidth - prefixIconWidth - suffixIconWidth, 0.0);
1301-
final double inputHeight = _lineHeight(availableInputWidth, <RenderBox?>[input, hint]);
1302-
final double inputMaxHeight = <double>[inputHeight, prefixHeight, suffixHeight].reduce(math.max);
1303-
13041273
final Offset densityOffset = decoration.visualDensity!.baseSizeAdjustment;
1305-
final double contentHeight = contentPadding.top
1274+
final double containerHeight = contentPadding.top
13061275
+ (label == null ? 0.0 : decoration.floatingLabelHeight)
1307-
+ inputMaxHeight
1276+
+ _lineHeight(width, <RenderBox?>[prefix, input, suffix])
13081277
+ contentPadding.bottom
13091278
+ densityOffset.dy;
1310-
final double containerHeight = <double>[iconHeight, contentHeight, prefixIconHeight, suffixIconHeight].reduce(math.max);
13111279
final double minContainerHeight = decoration.isDense! || expands
13121280
? 0.0
13131281
: kMinInteractiveDimension;

packages/flutter/test/material/input_decorator_test.dart

Lines changed: 0 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -5023,146 +5023,6 @@ void main() {
50235023
expect(tester.takeException(), isNull);
50245024
});
50255025

5026-
testWidgets('min intrinsic height for TextField with prefix icon', (WidgetTester tester) async {
5027-
// Regression test for: https://github.com/flutter/flutter/issues/87403
5028-
await tester.pumpWidget(MaterialApp(
5029-
home: Material(
5030-
child: Center(
5031-
child: SizedBox(
5032-
width: 100.0,
5033-
child: IntrinsicHeight(
5034-
child: Column(
5035-
children: <Widget>[
5036-
TextField(
5037-
controller: TextEditingController(text: 'input'),
5038-
maxLines: null,
5039-
decoration: const InputDecoration(
5040-
prefixIcon: Icon(Icons.search),
5041-
),
5042-
),
5043-
],
5044-
),
5045-
),
5046-
),
5047-
),
5048-
),
5049-
));
5050-
5051-
expect(tester.takeException(), isNull);
5052-
});
5053-
5054-
testWidgets('min intrinsic height for TextField with suffix icon', (WidgetTester tester) async {
5055-
// Regression test for: https://github.com/flutter/flutter/issues/87403
5056-
await tester.pumpWidget(MaterialApp(
5057-
home: Material(
5058-
child: Center(
5059-
child: SizedBox(
5060-
width: 100.0,
5061-
child: IntrinsicHeight(
5062-
child: Column(
5063-
children: <Widget>[
5064-
TextField(
5065-
controller: TextEditingController(text: 'input'),
5066-
maxLines: null,
5067-
decoration: const InputDecoration(
5068-
suffixIcon: Icon(Icons.search),
5069-
),
5070-
),
5071-
],
5072-
),
5073-
),
5074-
),
5075-
),
5076-
),
5077-
));
5078-
5079-
expect(tester.takeException(), isNull);
5080-
});
5081-
5082-
testWidgets('min intrinsic height for TextField with prefix', (WidgetTester tester) async {
5083-
// Regression test for: https://github.com/flutter/flutter/issues/87403
5084-
await tester.pumpWidget(MaterialApp(
5085-
home: Material(
5086-
child: Center(
5087-
child: SizedBox(
5088-
width: 100.0,
5089-
child: IntrinsicHeight(
5090-
child: Column(
5091-
children: <Widget>[
5092-
TextField(
5093-
controller: TextEditingController(text: 'input'),
5094-
maxLines: null,
5095-
decoration: const InputDecoration(
5096-
prefix: Text('prefix'),
5097-
),
5098-
),
5099-
],
5100-
),
5101-
),
5102-
),
5103-
),
5104-
),
5105-
));
5106-
5107-
expect(tester.takeException(), isNull);
5108-
});
5109-
5110-
testWidgets('min intrinsic height for TextField with suffix', (WidgetTester tester) async {
5111-
// Regression test for: https://github.com/flutter/flutter/issues/87403
5112-
await tester.pumpWidget(MaterialApp(
5113-
home: Material(
5114-
child: Center(
5115-
child: SizedBox(
5116-
width: 100.0,
5117-
child: IntrinsicHeight(
5118-
child: Column(
5119-
children: <Widget>[
5120-
TextField(
5121-
controller: TextEditingController(text: 'input'),
5122-
maxLines: null,
5123-
decoration: const InputDecoration(
5124-
suffix: Text('suffix'),
5125-
),
5126-
),
5127-
],
5128-
),
5129-
),
5130-
),
5131-
),
5132-
),
5133-
));
5134-
5135-
expect(tester.takeException(), isNull);
5136-
});
5137-
5138-
testWidgets('min intrinsic height for TextField with icon', (WidgetTester tester) async {
5139-
// Regression test for: https://github.com/flutter/flutter/issues/87403
5140-
await tester.pumpWidget(MaterialApp(
5141-
home: Material(
5142-
child: Center(
5143-
child: SizedBox(
5144-
width: 100.0,
5145-
child: IntrinsicHeight(
5146-
child: Column(
5147-
children: <Widget>[
5148-
TextField(
5149-
controller: TextEditingController(text: 'input'),
5150-
maxLines: null,
5151-
decoration: const InputDecoration(
5152-
icon: Icon(Icons.search),
5153-
),
5154-
),
5155-
],
5156-
),
5157-
),
5158-
),
5159-
),
5160-
),
5161-
));
5162-
5163-
expect(tester.takeException(), isNull);
5164-
});
5165-
51665026
testWidgets('InputDecorationTheme floatingLabelStyle overrides label widget styles when the widget is a text widget (focused)', (WidgetTester tester) async {
51675027
const TextStyle style16 = TextStyle(fontFamily: 'Ahem', fontSize: 16.0);
51685028
final TextStyle floatingLabelStyle = style16.merge(const TextStyle(color: Colors.indigo));

0 commit comments

Comments
 (0)