AgeOfMobile / flutter_mapbox

MapBox for Flutter
Other
7 stars 0 forks source link

Fix hot-reload issue #3

Open seddonm1 opened 6 years ago

seddonm1 commented 6 years ago

Currently a hot-reload will cause a Java exception to be thrown on any event as the theoretically stateless class MapView is holding the state of which _textureId to interact with.

E/MethodChannel#com.mapbox/flutter_mapbox(18191): Failed to handle method call E/MethodChannel#com.mapbox/flutter_mapbox(18191): java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Number.longValue()' on a null object reference E/MethodChannel#com.mapbox/flutter_mapbox(18191): at com.mapbox.flutter.FlutterMapboxPlugin.textureIdOfCall(FlutterMapboxPlugin.java:224)

This change pulls the _textureId state up to the StatefulWidget component which will preserve _textureId state over hot-reload.