@@ -425,7 +425,6 @@ class _HeroState extends State<Hero> {
425
425
}
426
426
427
427
// Everything known about a hero flight that's to be started or diverted.
428
- @immutable
429
428
class _HeroFlightManifest {
430
429
_HeroFlightManifest ({
431
430
required this .type,
@@ -455,8 +454,10 @@ class _HeroFlightManifest {
455
454
456
455
Object get tag => fromHero.widget.tag;
457
456
457
+ CurvedAnimation ? _animation;
458
+
458
459
Animation <double > get animation {
459
- return CurvedAnimation (
460
+ return _animation ?? = CurvedAnimation (
460
461
parent: (type == HeroFlightDirection .push) ? toRoute.animation! : fromRoute.animation! ,
461
462
curve: Curves .fastOutSlowIn,
462
463
reverseCurve: isDiverted ? null : Curves .fastOutSlowIn.flipped,
@@ -505,6 +506,11 @@ class _HeroFlightManifest {
505
506
return '_HeroFlightManifest($type tag: $tag from route: ${fromRoute .settings } '
506
507
'to route: ${toRoute .settings } with hero: $fromHero to $toHero )${isValid ? '' : ', INVALID' }' ;
507
508
}
509
+
510
+ @mustCallSuper
511
+ void dispose () {
512
+ _animation? .dispose ();
513
+ }
508
514
}
509
515
510
516
// Builds the in-flight hero widget.
@@ -531,7 +537,13 @@ class _HeroFlight {
531
537
late ProxyAnimation _proxyAnimation;
532
538
// The manifest will be available once `start` is called, throughout the
533
539
// flight's lifecycle.
534
- late _HeroFlightManifest manifest;
540
+ _HeroFlightManifest ? _manifest;
541
+ _HeroFlightManifest get manifest => _manifest! ;
542
+ set manifest (_HeroFlightManifest value) {
543
+ _manifest? .dispose ();
544
+ _manifest = value;
545
+ }
546
+
535
547
OverlayEntry ? overlayEntry;
536
548
bool _aborted = false ;
537
549
@@ -634,6 +646,7 @@ class _HeroFlight {
634
646
_proxyAnimation.removeListener (onTick);
635
647
_proxyAnimation.removeStatusListener (_handleAnimationUpdate);
636
648
}
649
+ _manifest? .dispose ();
637
650
}
638
651
639
652
void onTick () {
0 commit comments