added from string constructor
This commit is contained in:
@@ -5,6 +5,15 @@ class LatLng {
|
||||
LatLng(this.lat, this.lng);
|
||||
LatLng.empty() : lat = 0, lng = 0;
|
||||
|
||||
/// must be formatted 'double, double'. For example 35.35217, 89.19659
|
||||
factory LatLng.fromString(String latLng) {
|
||||
final splitString = latLng.split(',');
|
||||
final lat = double.parse(splitString[0].trim());
|
||||
final lng = double.parse(splitString[1].trim());
|
||||
|
||||
return LatLng(lat, lng);
|
||||
}
|
||||
|
||||
factory LatLng.fromJson(Map<String, dynamic> json) {
|
||||
return LatLng(json['lat'] as double, json['lng'] as double);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user