mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Fix behavior change due to incorrect initial floating setting (#55651)
This commit is contained in:
parent
6cf9c7cc17
commit
eddba97d9a
@ -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);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user