这是indexloc提供的服务,不要输入任何密码
Skip to content

Fix leak in input_decorator [prod-leak-fix] #155885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions packages/flutter/lib/src/material/input_decorator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
_floatingLabelAnimation.dispose();
_shakingLabelController.dispose();
_borderGap.dispose();
_curvedAnimation?.dispose();
super.dispose();
}

Expand Down Expand Up @@ -2150,6 +2151,23 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
}
}

CurvedAnimation? _curvedAnimation;

FadeTransition _buildTransition(Widget child, Animation<double> animation) {
if (_curvedAnimation?.parent != animation) {
_curvedAnimation?.dispose();
_curvedAnimation = CurvedAnimation(
parent: animation,
curve: _kTransitionCurve,
);
}

return FadeTransition(
opacity: _curvedAnimation!,
child: child,
);
}

@override
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
Expand Down Expand Up @@ -2182,15 +2200,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
child: hintTextWidget,
) : AnimatedSwitcher(
duration: decoration.hintFadeDuration ?? _kHintFadeTransitionDuration,
transitionBuilder: (Widget child, Animation<double> animation) {
return FadeTransition(
opacity: CurvedAnimation(
parent: animation,
curve: _kTransitionCurve,
),
child: child,
);
},
transitionBuilder: _buildTransition,
child: showHint ? hintTextWidget : const SizedBox.shrink(),
);
}
Expand Down