Unverified Commit eddba97d authored by Mehmet Fidanboylu's avatar Mehmet Fidanboylu Committed by GitHub

Fix behavior change due to incorrect initial floating setting (#55651)

parent 6cf9c7cc
......@@ -1915,8 +1915,10 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
super.initState();
final bool labelIsInitiallyFloating = widget.decoration.floatingLabelBehavior == FloatingLabelBehavior.always
// ignore: deprecated_member_use_from_same_package
|| (widget.decoration.hasFloatingPlaceholder && widget._labelShouldWithdraw);
|| (widget.decoration.floatingLabelBehavior != FloatingLabelBehavior.never &&
// ignore: deprecated_member_use_from_same_package
widget.decoration.hasFloatingPlaceholder &&
widget._labelShouldWithdraw);
_floatingLabelController = AnimationController(
duration: _kTransitionDuration,
......
......@@ -3910,4 +3910,18 @@ void main() {
expect(tester.getTopLeft(find.text('label')).dy, -4.0);
});
testWidgets('InputDecorator floating label obeys floatingLabelBehavior', (WidgetTester tester) async {
await tester.pumpWidget(
buildInputDecorator(
decoration: const InputDecoration(
labelText: 'label',
floatingLabelBehavior: FloatingLabelBehavior.never,
),
),
);
// Passing floating behavior never results in a dy offset of 20
// because the label is not initially floating.
expect(tester.getTopLeft(find.text('label')).dy, 20.0);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment