Skip to content

Commit

Permalink
migrate to null-safety (#607)
Browse files Browse the repository at this point in the history
* migrate to null-safety

* address comments

* fixed parameter type of _fromJson
  • Loading branch information
morvagergely authored Apr 26, 2021
1 parent 3399fc4 commit 6a907cd
Show file tree
Hide file tree
Showing 50 changed files with 671 additions and 777 deletions.
3 changes: 2 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
minSdkVersion 20
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
lintOptions {
disable 'InvalidPackage'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.geometry.LatLngQuad;
Expand Down Expand Up @@ -1235,13 +1236,8 @@ public void setTiltGesturesEnabled(boolean tiltGesturesEnabled) {

@Override
public void setMinMaxZoomPreference(Float min, Float max) {
//mapboxMap.resetMinMaxZoomPreference();
if (min != null) {
mapboxMap.setMinZoomPreference(min);
}
if (max != null) {
mapboxMap.setMaxZoomPreference(max);
}
mapboxMap.setMinZoomPreference(min != null ? min : MapboxConstants.MINIMUM_ZOOM);
mapboxMap.setMaxZoomPreference(max != null ? max : MapboxConstants.MAXIMUM_ZOOM);
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 29

lintOptions {
disable 'InvalidPackage'
Expand All @@ -39,6 +39,7 @@ android {
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}

buildTypes {
Expand Down
14 changes: 2 additions & 12 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -247,31 +247,21 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../Flutter/Flutter.framework",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework.dSYM",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/4794199C-B164-3A2D-A3B4-553B7D49EDD5.bcsymbolmap",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/097AD13C-9FDA-310F-8B76-64CB67B06A27.bcsymbolmap",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/491A77E9-7DBC-3309-A93C-BADAE0DDBC6E.bcsymbolmap",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/3F114CA8-302D-327F-87C3-670E0EC63C9A.bcsymbolmap",
"${BUILT_PRODUCTS_DIR}/MapboxAnnotationExtension/MapboxAnnotationExtension.framework",
"${BUILT_PRODUCTS_DIR}/MapboxMobileEvents/MapboxMobileEvents.framework",
"${BUILT_PRODUCTS_DIR}/location/location.framework",
"${BUILT_PRODUCTS_DIR}/mapbox_gl/mapbox_gl.framework",
"${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mapbox.framework",
"${DWARF_DSYM_FOLDER_PATH}/Mapbox.framework.dSYM",
"${BUILT_PRODUCTS_DIR}/4794199C-B164-3A2D-A3B4-553B7D49EDD5.bcsymbolmap",
"${BUILT_PRODUCTS_DIR}/097AD13C-9FDA-310F-8B76-64CB67B06A27.bcsymbolmap",
"${BUILT_PRODUCTS_DIR}/491A77E9-7DBC-3309-A93C-BADAE0DDBC6E.bcsymbolmap",
"${BUILT_PRODUCTS_DIR}/3F114CA8-302D-327F-87C3-670E0EC63C9A.bcsymbolmap",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxAnnotationExtension.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMobileEvents.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/location.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/mapbox_gl.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/lib/animate_camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AnimateCamera extends StatefulWidget {
}

class AnimateCameraState extends State<AnimateCamera> {
MapboxMapController mapController;
late MapboxMapController mapController;

void _onMapCreated(MapboxMapController controller) {
mapController = controller;
Expand Down
4 changes: 2 additions & 2 deletions example/lib/annotation_order_maps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class AnnotationOrderBody extends StatefulWidget {
}

class _AnnotationOrderBodyState extends State<AnnotationOrderBody> {
MapboxMapController controllerOne;
MapboxMapController controllerTwo;
late MapboxMapController controllerOne;
late MapboxMapController controllerTwo;

final LatLng center = const LatLng(36.580664, 32.5563837);

Expand Down
14 changes: 7 additions & 7 deletions example/lib/custom_marker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CustomMarker extends StatefulWidget {
class CustomMarkerState extends State<CustomMarker> {
final Random _rnd = new Random();

MapboxMapController _mapController;
late MapboxMapController _mapController;
List<Marker> _markers = [];
List<_MarkerState> _markerStates = [];

Expand Down Expand Up @@ -116,7 +116,7 @@ class CustomMarkerState extends State<CustomMarker> {

_mapController.toScreenLocationBatch(param).then((value) {
for (var i = 0; i < randomMarkerNum; i++) {
var point = Point<double>(value[i].x, value[i].y);
var point = Point<double>(value[i].x as double, value[i].y as double);
_addMarker(point, param[i]);
}
});
Expand Down Expand Up @@ -151,7 +151,7 @@ class CustomMarkerState extends State<CustomMarker> {
}
Future.wait(list);
sw.stop();
results[batch][0] += sw.elapsedMilliseconds;
results[batch]![0] += sw.elapsedMilliseconds;
sw.reset();
}

Expand All @@ -166,11 +166,11 @@ class CustomMarkerState extends State<CustomMarker> {
}
Future.wait([_mapController.toScreenLocationBatch(param)]);
sw.stop();
results[batch][1] += sw.elapsedMilliseconds;
results[batch]![1] += sw.elapsedMilliseconds;
sw.reset();
}

print('batch=$batch,primitive=${results[batch][0] / trial}ms, batch=${results[batch][1] / trial}ms');
print('batch=$batch,primitive=${results[batch]![0] / trial}ms, batch=${results[batch]![1] / trial}ms');
}

}
Expand All @@ -196,8 +196,8 @@ class _MarkerState extends State with TickerProviderStateMixin {

Point _position;

AnimationController _controller;
Animation<double> _animation;
late AnimationController _controller;
late Animation<double> _animation;

_MarkerState(this._position);

Expand Down
2 changes: 1 addition & 1 deletion example/lib/full_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FullMap extends StatefulWidget {
}

class FullMapState extends State<FullMap> {
MapboxMapController mapController;
MapboxMapController? mapController;

void _onMapCreated(MapboxMapController controller) {
mapController = controller;
Expand Down
2 changes: 2 additions & 0 deletions example/lib/generated_plugin_registrant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

// ignore_for_file: lines_longer_than_80_chars

import 'package:location_web/location_web.dart';
import 'package:mapbox_gl_web/mapbox_gl_web.dart';

import 'package:flutter_web_plugins/flutter_web_plugins.dart';

// ignore: public_member_api_docs
void registerPlugins(Registrar registrar) {
LocationWebPlugin.registerWith(registrar);
MapboxMapPlugin.registerWith(registrar);
registrar.registerMessageHandler();
}
22 changes: 11 additions & 11 deletions example/lib/line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class LineBodyState extends State<LineBody> {

static final LatLng center = const LatLng(-33.86711, 151.1947171);

MapboxMapController controller;
MapboxMapController? controller;
int _lineCount = 0;
Line _selectedLine;
Line? _selectedLine;

void _onMapCreated(MapboxMapController controller) {
this.controller = controller;
Expand All @@ -42,7 +42,7 @@ class LineBodyState extends State<LineBody> {

@override
void dispose() {
controller?.onLineTapped?.remove(_onLineTapped);
controller?.onLineTapped.remove(_onLineTapped);
super.dispose();
}

Expand All @@ -65,11 +65,11 @@ class LineBodyState extends State<LineBody> {
}

void _updateSelectedLine(LineOptions changes) {
controller.updateLine(_selectedLine, changes);
controller!.updateLine(_selectedLine!, changes);
}

void _add() {
controller.addLine(
controller!.addLine(
LineOptions(
geometry: [
LatLng(-33.86711, 151.1947171),
Expand All @@ -88,15 +88,15 @@ class LineBodyState extends State<LineBody> {
}

void _remove() {
controller.removeLine(_selectedLine);
controller!.removeLine(_selectedLine!);
setState(() {
_selectedLine = null;
_lineCount -= 1;
});
}

Future<void> _changeAlpha() async {
double current = _selectedLine.options.lineOpacity;
double? current = _selectedLine!.options.lineOpacity;
if (current == null) {
// default value
current = 1.0;
Expand All @@ -108,7 +108,7 @@ class LineBodyState extends State<LineBody> {
}

Future<void> _toggleVisible() async {
double current = _selectedLine.options.lineOpacity;
double? current = _selectedLine!.options.lineOpacity;
if (current == null) {
// default value
current = 1.0;
Expand All @@ -119,7 +119,7 @@ class LineBodyState extends State<LineBody> {
}

void onStyleLoadedCallback() {
controller.addLine(
controller!.addLine(
LineOptions(
geometry: [LatLng(37.4220, -122.0841), LatLng(37.4240, -122.0941)],
lineColor: "#ff0000",
Expand Down Expand Up @@ -186,8 +186,8 @@ class LineBodyState extends State<LineBody> {
onPressed: (_selectedLine == null)
? null
: () async {
var latLngs = await controller
.getLineLatLngs(_selectedLine);
var latLngs = await controller!
.getLineLatLngs(_selectedLine!);
for (var latLng in latLngs) {
print(latLng.toString());
}
Expand Down
4 changes: 2 additions & 2 deletions example/lib/local_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class LocalStyle extends StatefulWidget {
}

class LocalStyleState extends State<LocalStyle> {
MapboxMapController mapController;
String styleAbsoluteFilePath;
MapboxMapController? mapController;
String? styleAbsoluteFilePath;

@override
initState() {
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class MapsDemo extends StatelessWidget {
if (!kIsWeb) {
final location = Location();
final hasPermissions = await location.hasPermission();
if (hasPermissions != PermissionStatus.GRANTED) {
if (hasPermissions != PermissionStatus.granted) {
await location.requestPermission();
}
}
Expand Down
Loading

0 comments on commit 6a907cd

Please sign in to comment.