createGroup method

AnimationGroup<TKey> createGroup(
  1. Duration duration,
  2. Curve curve, {
  3. double initialValue = 0.0,
})

Creates a fresh AnimationGroup, disposing any prior one first. initialValue is 0.0 for expandAll (forward), 1.0 for collapseAll (reverse). Wires the constructor-injected onTick and onStatusChanged callbacks.

Implementation

AnimationGroup<TKey> createGroup(
  Duration duration,
  Curve curve, {
  double initialValue = 0.0,
}) {
  disposeGroup();
  final controller = AnimationController(
    vsync: _vsync,
    duration: duration,
    value: initialValue,
  );
  final group = AnimationGroup<TKey>(
    controller: controller,
    curve: curve,
  );
  controller.addListener(_onTick);
  controller.addStatusListener((status) {
    if (status == AnimationStatus.completed ||
        status == AnimationStatus.dismissed) {
      _onStatusChanged(status);
    }
  });
  _group = group;
  _generation++;
  return group;
}