Skip to content

Commit

Permalink
AnimatedCrossFade: optional disposing of invisible child
Browse files Browse the repository at this point in the history
  • Loading branch information
vanifatovvlad committed May 9, 2021
1 parent 41d9198 commit 2ea3e43
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Runtime/Widgets/AnimatedCrossFade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class AnimatedCrossFade : StatefulWidget
public float Duration { get; set; } = 0f;
public float? ReverseDuration { get; set; } = null;
public Alignment Alignment { get; set; } = Alignment.Center;
public bool KeepMounted { get; set; } = false;

public override State CreateState() => new AnimatedCrossFadeState();

Expand Down Expand Up @@ -38,6 +39,11 @@ public override void InitState()

_firstChild = CreateChild(context =>
{
if (!Widget.KeepMounted && _controller.IsCompleted)
{
return new Empty();
}

return new CompositeTransition
{
Key = _firstKey,
Expand All @@ -47,6 +53,11 @@ public override void InitState()
});
_secondChild = CreateChild(context =>
{
if (!Widget.KeepMounted && _controller.IsDismissed)
{
return new Empty();
}

return new CompositeTransition
{
Key = _secondKey,
Expand Down

0 comments on commit 2ea3e43

Please sign in to comment.