Fix memory leaks in CupertinoTextMagnifier
(#147208)
This commit is contained in:
parent
3e8408bb63
commit
1be28aa61a
@ -82,8 +82,10 @@ class _CupertinoTextMagnifierState extends State<CupertinoTextMagnifier>
|
|||||||
// set these values.
|
// set these values.
|
||||||
Offset _currentAdjustedMagnifierPosition = Offset.zero;
|
Offset _currentAdjustedMagnifierPosition = Offset.zero;
|
||||||
double _verticalFocalPointAdjustment = 0;
|
double _verticalFocalPointAdjustment = 0;
|
||||||
late AnimationController _ioAnimationController;
|
late final AnimationController _ioAnimationController;
|
||||||
late Animation<double> _ioAnimation;
|
late final Animation<double> _ioAnimation;
|
||||||
|
late final CurvedAnimation _ioCurvedAnimation;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -97,20 +99,21 @@ class _CupertinoTextMagnifierState extends State<CupertinoTextMagnifier>
|
|||||||
widget.controller.animationController = _ioAnimationController;
|
widget.controller.animationController = _ioAnimationController;
|
||||||
widget.magnifierInfo
|
widget.magnifierInfo
|
||||||
.addListener(_determineMagnifierPositionAndFocalPoint);
|
.addListener(_determineMagnifierPositionAndFocalPoint);
|
||||||
|
_ioCurvedAnimation = CurvedAnimation(
|
||||||
|
parent: _ioAnimationController,
|
||||||
|
curve: widget.animationCurve,
|
||||||
|
);
|
||||||
_ioAnimation = Tween<double>(
|
_ioAnimation = Tween<double>(
|
||||||
begin: 0.0,
|
begin: 0.0,
|
||||||
end: 1.0,
|
end: 1.0,
|
||||||
).animate(CurvedAnimation(
|
).animate(_ioCurvedAnimation);
|
||||||
parent: _ioAnimationController,
|
|
||||||
curve: widget.animationCurve,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
widget.controller.animationController = null;
|
widget.controller.animationController = null;
|
||||||
_ioAnimationController.dispose();
|
_ioAnimationController.dispose();
|
||||||
|
_ioCurvedAnimation.dispose();
|
||||||
widget.magnifierInfo
|
widget.magnifierInfo
|
||||||
.removeListener(_determineMagnifierPositionAndFocalPoint);
|
.removeListener(_determineMagnifierPositionAndFocalPoint);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||||
|
|
||||||
import '../widgets/process_text_utils.dart';
|
import '../widgets/process_text_utils.dart';
|
||||||
|
|
||||||
@ -288,7 +289,10 @@ void main() {
|
|||||||
expect(content!.plainText, 'How');
|
expect(content!.plainText, 'How');
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('stopping drag of end handle will show the toolbar', (WidgetTester tester) async {
|
testWidgets('stopping drag of end handle will show the toolbar',
|
||||||
|
// TODO(polina-c): remove when fixed https://github.com/flutter/flutter/issues/145600 [leak-tracking-opt-in]
|
||||||
|
experimentalLeakTesting: LeakTesting.settings.withTracked(classes: const <String>['CurvedAnimation']),
|
||||||
|
(WidgetTester tester) async {
|
||||||
final FocusNode focusNode = FocusNode();
|
final FocusNode focusNode = FocusNode();
|
||||||
addTearDown(focusNode.dispose);
|
addTearDown(focusNode.dispose);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user