LatLng.from constructor

LatLng.from(
  1. dynamic value
)

Implementation

factory LatLng.from(dynamic value) {
  assert(value is LatLng ||
      (value is List &&
          value.isNotEmpty &&
          (value.first is int || value.first is double) &&
          (value.length == 2 || value.length == 3)));

  if (value is List &&
      value.isNotEmpty &&
      (value.first is int || value.first is double)) {
    if (value.length == 3) {
      return LatLng(
        value[0].toDouble(),
        value[1].toDouble(),
        value[2].toDouble(),
      );
    }

    if (value.length == 2) {
      return LatLng(
        value[0].toDouble(),
        value[1].toDouble(),
      );
    }
  }

  return value;
}