extend method

void extend(
  1. MultiAnimationSequence secondSequence
)

Implementation

void extend(MultiAnimationSequence secondSequence) {
  double currentMaxTime = 0;
  sequences.forEach((key, value) {
    double maxTime = value.getAllTimeStamps().last;
    if (maxTime > currentMaxTime) {
      currentMaxTime = maxTime;
    }
  });

  secondSequence.sequences.forEach((key, value) {
    if (!sequences.containsKey(key)) {
      switch (key) {
        case AnimationProperty.opacity:
          sequences[key] = AnimationSequence<double>();
          break;
        case AnimationProperty.alignment:
        case AnimationProperty.transformAlignment:
        case AnimationProperty.childAlignment:
          sequences[key] = AnimationSequence<Alignment>();
          break;
        case AnimationProperty.width:
        case AnimationProperty.height:
          sequences[key] = AnimationSequence<Dimension>();
          break;
        case AnimationProperty.margin:
        case AnimationProperty.padding:
          sequences[key] = AnimationSequence<EdgeInsets>();
          break;
        case AnimationProperty.backgroundDecoration:
        case AnimationProperty.foregroundDecoration:
          sequences[key] = AnimationSequence<BoxDecoration>();
          break;
        case AnimationProperty.shadows:
        case AnimationProperty.insetShadows:
          sequences[key] = AnimationSequence<List<ShapeShadow>>();
          break;
        case AnimationProperty.shapeBorder:
          sequences[key] = AnimationSequence<MorphableShapeBorder>();
          break;
        case AnimationProperty.transform:
          sequences[key] = AnimationSequence<SmoothMatrix4>();
          break;
        case AnimationProperty.textStyle:
          sequences[key] = AnimationSequence<DynamicTextStyle>();
          break;
      }
    }

    double lastTime = (sequences[key]?.getAllTimeStamps().last) ?? 0.0;
    value.data[0].delay +=
        Duration(milliseconds: (currentMaxTime - lastTime).round());
    sequences[key]?.data.addAll(value.data);
  });
}