AnimationId.parse constructor

AnimationId.parse(
  1. String id
)

Parse the id into an AnimationId object.

It expects the id to be in the format of:

"moveId#latitude,longitude,destZoom[#customId]"

Implementation

factory AnimationId.parse(String id) {
  final parts = id.split('#');
  final moveId = AnimatedMoveId.values.byName(parts[0]);
  final destParts = parts[1].split(',');
  final lat = double.parse(destParts[0]);
  final lng = double.parse(destParts[1]);
  final zoom = double.parse(destParts[2]);
  final customId = parts.length == 3 ? parts[2] : null;

  return AnimationId(
    moveId: moveId,
    destLocation: LatLng(lat, lng),
    destZoom: zoom,
    customId: customId,
  );
}