parse method

  1. @override
GeoLocation parse(
  1. String content
)
override

Pareses the given textual representation

Implementation

@override
GeoLocation parse(String content) {
  final semicolonIndex = content.indexOf(';');
  if (semicolonIndex == -1) {
    throw FormatException('Invalid GEO property $content');
  }
  final latitudeText = content.substring(0, semicolonIndex);
  final latitude = double.tryParse(latitudeText);
  if (latitude == null) {
    throw FormatException(
      'Invalid GEO property - unable to parse latitude value '
      '$latitudeText in  $content',
    );
  }
  final longitudeText = content.substring(semicolonIndex + 1);
  final longitude = double.tryParse(longitudeText);
  if (longitude == null) {
    throw FormatException(
      'Invalid GEO property - unable to parse longitude value '
      '$longitudeText in  $content',
    );
  }

  return GeoLocation(latitude, longitude);
}