diff --git a/bin/internal/goldens.version b/bin/internal/goldens.version index 880c390523..3fe3e00da9 100644 --- a/bin/internal/goldens.version +++ b/bin/internal/goldens.version @@ -1 +1 @@ -95f60c7e328b53dd65de18a608830a872a92e3cd +17b9d558228edad27729a0c1823430d73cb26608 diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index 4dc5d7e2ba..b56592f7a6 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -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; diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index d79bd48f1a..03604a199e 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -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, + ); }