forked from firka/flutter
Fix leak in input_decorator [prod-leak-fix] (#155885)
Introduced by https://github.com/flutter/flutter/pull/153235.
This commit is contained in:
committed by
GitHub
parent
72edaa3d66
commit
bff135153d
@@ -1919,6 +1919,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
||||
_floatingLabelAnimation.dispose();
|
||||
_shakingLabelController.dispose();
|
||||
_borderGap.dispose();
|
||||
_curvedAnimation?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -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(),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user