generateMorphSequence static method

Iterable<Morph> generateMorphSequence({
  1. required List<RoundedPolygon> polygons,
  2. required bool circularSequence,
  3. LoadingIndicatorForEachPolygon forEachPolygon = defaultForEachPolygon,
})

Implementation

static Iterable<Morph> generateMorphSequence({
  required List<RoundedPolygon> polygons,
  required bool circularSequence,
  LoadingIndicatorForEachPolygon forEachPolygon = defaultForEachPolygon,
}) sync* {
  if (polygons.isEmpty) return;
  final first = forEachPolygon(polygons[0]);
  var current = first;
  for (var i = 1; i < polygons.length; i++) {
    final next = forEachPolygon(polygons[i]);
    yield Morph(current, next);
    current = next;
  }
  if (circularSequence) {
    // Create a morph from the last shape to the first shape.
    yield Morph(current, first);
  }
}