Skip to content

Commit b9ec0a1

Browse files
fix a bug where the controller was used before it has been created (#108)
1 parent 88e9514 commit b9ec0a1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

arcgis_map_sdk/lib/src/arcgis_map_sdk.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class ArcgisMap extends StatefulWidget {
8686

8787
class _ArcgisMapState extends State<ArcgisMap> {
8888
final int _mapId = _nextMapCreationId++;
89-
late ArcgisMapController controller;
89+
ArcgisMapController? controller;
9090

9191
late ArcgisMapOptions _arcgisMapOptions = ArcgisMapOptions(
9292
apiKey: widget.apiKey,
@@ -117,7 +117,7 @@ class _ArcgisMapState extends State<ArcgisMap> {
117117

118118
Future<void> onPlatformViewCreated(int id) async {
119119
controller = await ArcgisMapController.init(id);
120-
widget.onMapCreated?.call(controller);
120+
widget.onMapCreated?.call(controller!);
121121
}
122122

123123
@override
@@ -139,11 +139,11 @@ class _ArcgisMapState extends State<ArcgisMap> {
139139
void didUpdateWidget(ArcgisMap oldWidget) {
140140
super.didUpdateWidget(oldWidget);
141141
if ((widget.basemap != null) && oldWidget.basemap != widget.basemap) {
142-
controller.toggleBaseMap(baseMap: widget.basemap!);
142+
controller?.toggleBaseMap(baseMap: widget.basemap!);
143143
}
144144
if (widget.isAttributionTextVisible != null &&
145145
widget.isAttributionTextVisible != oldWidget.isAttributionTextVisible) {
146-
controller.updateIsAttributionTextVisible(
146+
controller?.updateIsAttributionTextVisible(
147147
widget.isAttributionTextVisible!,
148148
);
149149
}
@@ -185,7 +185,7 @@ class _ArcgisMapState extends State<ArcgisMap> {
185185

186186
@override
187187
void dispose() {
188-
controller.dispose();
188+
controller?.dispose();
189189
super.dispose();
190190
}
191191
}

0 commit comments

Comments
 (0)