File tree 2 files changed +21
-2
lines changed
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -1555,14 +1555,14 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin
1555
1555
case TextDirection .rtl: // origin is on the right
1556
1556
startX = labelOffset.dx + labelWidth * (1.0 - scale);
1557
1557
floatStartX = startX;
1558
- if (prefixIcon != null && ! decoration.alignLabelWithHint) {
1558
+ if (prefixIcon != null && ! decoration.alignLabelWithHint && isOutlineBorder ) {
1559
1559
floatStartX += material3 ? _boxSize (prefixIcon).width - contentPadding.left : 0.0 ;
1560
1560
}
1561
1561
break ;
1562
1562
case TextDirection .ltr: // origin on the left
1563
1563
startX = labelOffset.dx;
1564
1564
floatStartX = startX;
1565
- if (prefixIcon != null && ! decoration.alignLabelWithHint) {
1565
+ if (prefixIcon != null && ! decoration.alignLabelWithHint && isOutlineBorder ) {
1566
1566
floatStartX += material3 ? - _boxSize (prefixIcon).width + contentPadding.left : 0.0 ;
1567
1567
}
1568
1568
break ;
Original file line number Diff line number Diff line change @@ -2842,6 +2842,25 @@ void main() {
2842
2842
expect (tester.getBottomLeft (find.text ('text' )).dx, 48.0 );
2843
2843
expect (getBorderWeight (tester), 2.0 );
2844
2844
});
2845
+
2846
+ testWidgets ('Floating label for filled input decoration is aligned with text' , (WidgetTester tester) async {
2847
+ await tester.pumpWidget (
2848
+ buildInputDecorator (
2849
+ useMaterial3: useMaterial3,
2850
+ decoration: const InputDecoration (
2851
+ prefixIcon: Icon (Icons .ac_unit),
2852
+ labelText: 'label' ,
2853
+ filled: true ,
2854
+ ),
2855
+ isFocused: true ,
2856
+ ),
2857
+ );
2858
+
2859
+ expect (tester.getSize (find.byType (InputDecorator )), const Size (800.0 , 56.0 ));
2860
+ expect (tester.getTopLeft (find.text ('label' )).dx, 48.0 );
2861
+ expect (tester.getBottomLeft (find.text ('text' )).dx, 48.0 );
2862
+ expect (getBorderWeight (tester), 2.0 );
2863
+ });
2845
2864
});
2846
2865
2847
2866
group ('3 point interpolation alignment' , () {
You can’t perform that action at this time.
0 commit comments