_ChildEntry _newEntry(
            Widget child,
            AnimatedSwitcherTransitionBuilder builder,
            AnimationController controller,
            Animation <float> animation
            )
        {
            _ChildEntry entry = new _ChildEntry(
                widgetChild: child,
                transition: KeyedSubtree.wrap(builder(child, animation), this._childNumber),
                animation: animation,
                controller: controller
                );

            animation.addStatusListener((AnimationStatus status) => {
                if (status == AnimationStatus.dismissed)
                {
                    this.setState(() => {
                        D.assert(this.mounted);
                        D.assert(this._outgoingEntries.Contains(entry));
                        this._outgoingEntries.Remove(entry);
                        this._markChildWidgetCacheAsDirty();
                    });
                    controller.dispose();
                }
            });
            return(entry);
        }
 void _updateTransitionForEntry(_ChildEntry entry)
 {
     entry.transition = new KeyedSubtree(
         key: entry.transition.key,
         child: this.widget.transitionBuilder(entry.widgetChild, entry.animation)
         );
 }
Exemple #3
0
        void _addEntryForNewChild(bool animate)
        {
            D.assert(animate || _currentEntry == null);
            if (_currentEntry != null)
            {
                D.assert(animate);
                D.assert(!_outgoingEntries.Contains(_currentEntry));
                _outgoingEntries.Add(_currentEntry);
                _currentEntry.controller.reverse();
                _markChildWidgetCacheAsDirty();
                _currentEntry = null;
            }

            if (widget.child == null)
            {
                return;
            }

            AnimationController controller = new AnimationController(
                duration: widget.duration,
                reverseDuration: widget.reverseDuration,
                vsync: this
                );
            Animation <float> animation = new CurvedAnimation(
                parent: controller,
                curve: widget.switchInCurve,
                reverseCurve: widget.switchOutCurve
                );

            _currentEntry = _newEntry(
                child: widget.child,
                controller: controller,
                animation: animation,
                builder: widget.transitionBuilder
                );
            if (animate)
            {
                controller.forward();
            }
            else
            {
                D.assert(_outgoingEntries.isEmpty);
                controller.setValue(1.0f);
            }
        }