Correct OutlineBorder gapStart when InputDecoration icon is specified (#18182)
This commit is contained in:
parent
25c4bc32b8
commit
e8bceabbb8
@ -1 +1 @@
|
||||
95f60c7e328b53dd65de18a608830a872a92e3cd
|
||||
17b9d558228edad27729a0c1823430d73cb26608
|
||||
|
@ -1037,12 +1037,15 @@ class _RenderDecoration extends RenderBox {
|
||||
}
|
||||
|
||||
if (label != null) {
|
||||
final double labelX = _boxParentData(label).offset.dx;
|
||||
switch (textDirection) {
|
||||
case TextDirection.rtl:
|
||||
decoration.borderGap.start = _boxParentData(label).offset.dx + label.size.width;
|
||||
decoration.borderGap.start = labelX + label.size.width;
|
||||
break;
|
||||
case TextDirection.ltr:
|
||||
decoration.borderGap.start = _boxParentData(label).offset.dx;
|
||||
// The value of _InputBorderGap.start is relative to the origin of the
|
||||
// _BorderContainer which is inset by the icon's width.
|
||||
decoration.borderGap.start = labelX - _boxSize(icon).width;
|
||||
break;
|
||||
}
|
||||
decoration.borderGap.extent = label.size.width * 0.75;
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@ -1428,4 +1430,52 @@ void main() {
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'InputDecorator OutlineBorder focused label with icon',
|
||||
(WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/18111
|
||||
|
||||
Widget buildFrame(TextDirection textDirection) {
|
||||
return new MaterialApp(
|
||||
home: new Scaffold(
|
||||
body: new Container(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
alignment: Alignment.center,
|
||||
child: new Directionality(
|
||||
textDirection: textDirection,
|
||||
child: const RepaintBoundary(
|
||||
child: const InputDecorator(
|
||||
isFocused: true,
|
||||
isEmpty: true,
|
||||
decoration: const InputDecoration(
|
||||
icon: const Icon(Icons.insert_link),
|
||||
labelText: 'primaryLink',
|
||||
hintText: 'Primary link to story',
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildFrame(TextDirection.ltr));
|
||||
await expectLater(
|
||||
find.byType(InputDecorator),
|
||||
matchesGoldenFile('input_decorator.outline_icon_label.ltr.png'),
|
||||
skip: !Platform.isLinux,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(buildFrame(TextDirection.rtl));
|
||||
await expectLater(
|
||||
find.byType(InputDecorator),
|
||||
matchesGoldenFile('input_decorator.outline_icon_label.rtl.png'),
|
||||
skip: !Platform.isLinux,
|
||||
);
|
||||
},
|
||||
skip: !Platform.isLinux,
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user