@@ -66,10 +66,11 @@ class GeoSerie {
66
66
{required this .name,
67
67
required this .type,
68
68
this .id,
69
- this .geoPoints,
70
69
this .surface,
71
70
this .boundary,
72
- this .centroid});
71
+ this .centroid,
72
+ List <GeoPoint >? geoPoints})
73
+ : this .geoPoints = geoPoints ?? < GeoPoint > [];
73
74
74
75
/// Name if the geoserie
75
76
String name;
@@ -81,7 +82,7 @@ class GeoSerie {
81
82
GeoSerieType type;
82
83
83
84
/// The list of [GeoPoint] in the serie
84
- List <GeoPoint >? geoPoints;
85
+ List <GeoPoint > geoPoints;
85
86
86
87
/// The surface of a geometry
87
88
num ? surface;
@@ -100,12 +101,14 @@ class GeoSerie {
100
101
: name = "${json ["name" ]}" ,
101
102
id = int .parse ("${json ["id" ]}" ),
102
103
surface = double .tryParse ("${json ["surface" ]}" ),
103
- type = _typeFromString ("${json ["type" ]}" );
104
+ type = _typeFromString ("${json ["type" ]}" ),
105
+ this .geoPoints = < GeoPoint > [];
104
106
105
107
/// Make a [GeoSerie] from name and serie type
106
108
GeoSerie .fromNameAndType (
107
109
{required this .name, required String typeStr, this .id})
108
- : type = _typeFromString (typeStr);
110
+ : type = _typeFromString (typeStr),
111
+ this .geoPoints = < GeoPoint > [];
109
112
110
113
/// [name] the name of the [GeoSerie]
111
114
/// [typeStr] the type of the serie: group, line or polygon
@@ -128,10 +131,7 @@ class GeoSerie {
128
131
/// Get a list of [LatLng] from this [GeoSerie]
129
132
List <LatLng > toLatLng ({bool ignoreErrors = false }) {
130
133
final points = < LatLng > [];
131
- if (geoPoints == null ) {
132
- return points;
133
- }
134
- for (final geoPoint in geoPoints! ) {
134
+ for (final geoPoint in geoPoints) {
135
135
try {
136
136
points.add (geoPoint.point);
137
137
} catch (_) {
@@ -146,10 +146,8 @@ class GeoSerie {
146
146
/// Convert to a geojson coordinates string
147
147
String toGeoJsonCoordinatesString () {
148
148
final coords = < String > [];
149
- if (geoPoints == null ) {
150
- return "[]" ;
151
- }
152
- for (final geoPoint in geoPoints! ) {
149
+
150
+ for (final geoPoint in geoPoints) {
153
151
coords.add (geoPoint.toGeoJsonCoordinatesString ());
154
152
}
155
153
return "[" + coords.join ("," ) + "]" ;
0 commit comments