Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to sound null-safety #870

Merged
merged 62 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
911ca0d
Add actions/stale@v3 GitHub Action
johnpryan Mar 19, 2021
dfb91ef
updated to latest master version
escamoteur Jan 6, 2021
49119d1
updated dependcies to compile again
escamoteur Mar 22, 2021
f084f2a
updated latlong import
escamoteur Mar 22, 2021
98ebcff
migrated to unsound null safety
escamoteur Mar 22, 2021
d210359
removed .packages from repository
escamoteur Mar 23, 2021
5633366
small fixes
escamoteur Mar 23, 2021
0bf64bf
Update lib/src/core/point.dart
escamoteur Mar 25, 2021
c7d523a
Update pubspec.yaml
escamoteur Mar 25, 2021
48f361e
Update lib/src/gestures/latlng_tween.dart
escamoteur Mar 25, 2021
d1be78e
type '_ControllerStream<LatLng?>' is not a subtype of type 'Stream<La…
tazik561 Mar 25, 2021
f2aaf92
changes according to review
escamoteur Mar 25, 2021
2affa2c
made key nullable
escamoteur Apr 2, 2021
34bf621
made rebuild nullable again
escamoteur Apr 2, 2021
cd6ec35
Fix polyline border drawing
Ahmed-gubara Apr 6, 2021
53be3ce
corrected typo in dependency_overrides
escamoteur Apr 8, 2021
8bb439c
Removed unnecessary null-checks
kengu Apr 8, 2021
2b509ad
Limit number of purges in TileLayer and cancel pending on dispose
kengu Apr 14, 2021
235dea9
Fix error messages in mocked classes
kengu Apr 14, 2021
2ff083d
Set ready to true always (state is never null)
kengu Apr 14, 2021
0145354
Merge improved fling physics into sound null-safety branch
kengu Apr 25, 2021
2a71f18
Merge Added new plugin to README
kengu Apr 27, 2021
622d7e8
make bounds, getBounds and getCenter null safe
kengu Apr 27, 2021
daf1dbb
Merge Optimize markers calculations as null safe
kengu Apr 28, 2021
37e8f07
Merge Added onMapCreated callback
kengu Apr 30, 2021
09b306a
Merge Add a fastReplace option to TileLayerOptions
kengu Apr 30, 2021
72786e6
use http.RetryClient instead of flutter_image
josxha May 10, 2021
a1496c5
formatting
josxha May 10, 2021
0c7462f
add change notes
josxha May 10, 2021
45c94ea
Added example page for NetworkTileProvider
kengu May 15, 2021
d9dd158
Added dependency on null safe version 0.17.0 of package intl (would n…
kengu May 15, 2021
e72a6f0
Changed to master branch of flutter_image that is now null-safe
kengu May 15, 2021
f132c35
Change override of package flutter_image to new location in flutter p…
kengu May 15, 2021
85146e2
Merge Add a key for markers to preserve state
kengu May 15, 2021
de5d4da
Merge remote-tracking branch 'fleaflet/issues/829-nullsafety' into is…
ThexXTURBOXx May 19, 2021
910f701
Update git repo link
ThexXTURBOXx May 19, 2021
079daaf
Fix typos
ThexXTURBOXx May 19, 2021
918d65b
Sort dependencies
ThexXTURBOXx May 19, 2021
8c36591
Reformat and improve pub score
ThexXTURBOXx May 19, 2021
c7da0c9
Upgraded to flutter_image ^4.0.1
kengu May 19, 2021
932d6d8
Merge remote-tracking branch 'fleaflet/issues/829-nullsafety' into is…
ThexXTURBOXx May 19, 2021
793b4f0
Reformatted files to standard settings
kengu May 19, 2021
00fa7fb
Merge remote-tracking branch 'fleaflet/issues/829-nullsafety' into is…
ThexXTURBOXx May 19, 2021
6023f61
Reformatted crs.dart that wasn't changed using command line
kengu May 19, 2021
a4e1b5d
Merge remote-tracking branch 'fleaflet/issues/829-nullsafety' into is…
ThexXTURBOXx May 19, 2021
1882f32
Random Fixes Everywhere (#910)
ThexXTURBOXx May 20, 2021
8899a7b
Merge remote-tracking branch 'fleaflet/issues/829-nullsafety' into is…
ThexXTURBOXx May 20, 2021
252bbc4
Merge pull request #1 from ThexXTURBOXx/issues/829-nullsafety
josxha May 20, 2021
d9674b5
Merge pull request #894 from josxha/issues/829-nullsafety
kengu May 22, 2021
8378acb
remove TODO
johnpryan Jun 4, 2021
705e32c
Clarification of all options available for offline mapping (#913)
JaffaKetchup Jun 4, 2021
a249d23
Merge branch 'master' of github.com:fleaflet/flutter_map into issues/…
johnpryan Jun 4, 2021
618bc12
Merge branch 'issues/829-nullsafety' of github.com:fleaflet/flutter_m…
johnpryan Jun 4, 2021
b870970
fix Group Layer Options constructor wrong nullability (#921)
tlserver Jun 4, 2021
36154f4
null check regex in template()
johnpryan Jun 4, 2021
863c797
Merge remote-tracking branch 'origin/issues/829-nullsafety' into issu…
johnpryan Jun 4, 2021
9e6dd84
re-apply #913 into null safety branch
johnpryan Jun 4, 2021
c3659d9
Review comments from issues/829-nullsafety (#919)
andreandersson Jun 4, 2021
a86caca
dart format
johnpryan Jun 4, 2021
40d3a59
make urlTemplate required, make throttleSTreamTransformerWithTrailing…
johnpryan Jun 4, 2021
3ea0500
use late final where possible
johnpryan Jun 4, 2021
2765f26
revert making urlTemplate non-nullable
johnpryan Jun 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions example/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
2 changes: 1 addition & 1 deletion example/lib/pages/animated_map_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AnimatedMapControllerPageState extends State<AnimatedMapControllerPage>
static LatLng paris = LatLng(48.8566, 2.3522);
static LatLng dublin = LatLng(53.3498, -6.2603);

MapController mapController;
late MapController mapController;

@override
void initState() {
Expand Down
13 changes: 7 additions & 6 deletions example/lib/pages/custom_crs/custom_crs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,31 @@ class CustomCrsPage extends StatefulWidget {
}

class _CustomCrsPageState extends State<CustomCrsPage> {
Proj4Crs epsg3413CRS;
late Proj4Crs epsg3413CRS;

double maxZoom;
double? maxZoom;

// Define start center
proj4.Point point = proj4.Point(x: 65.05166470332148, y: -19.171744826394896);

String initText = 'Map centered to';

proj4.Projection epsg4326;
late proj4.Projection epsg4326;

proj4.Projection epsg3413;
late proj4.Projection epsg3413;

@override
void initState() {
super.initState();

// EPSG:4326 is a predefined projection ships with proj4dart
epsg4326 = proj4.Projection('EPSG:4326');
epsg4326 = proj4.Projection.get('EPSG:4326')!;

// EPSG:3413 is a user-defined projection from a valid Proj4 definition string
// From: http://epsg.io/3413, proj definition: http://epsg.io/3413.proj4
// Find Projection by name or define it if not exists
epsg3413 = proj4.Projection('EPSG:3413') ??
// TODO the warning here will go away as soon as proj4 is migrated to null safety
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO could certainly get removed now

epsg3413 = proj4.Projection.get('EPSG:3413') ??
proj4.Projection.add('EPSG:3413',
'+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');

Expand Down
6 changes: 3 additions & 3 deletions example/lib/pages/interactive_test_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class InteractiveTestPage extends StatefulWidget {
}

class _InteractiveTestPageState extends State<InteractiveTestPage> {
MapController mapController;
late MapController mapController;

// Enable pinchZoom and doubleTapZoomBy by default
int flags = InteractiveFlag.pinchZoom | InteractiveFlag.doubleTapZoom;

StreamSubscription<MapEvent> subscription;
late StreamSubscription<MapEvent> subscription;

@override
void initState() {
Expand Down Expand Up @@ -159,7 +159,7 @@ class _InteractiveTestPageState extends State<InteractiveTestPage> {
}

return Text(
'Current event: ${snapshot.data.runtimeType}\nSource: ${snapshot.data.source}',
'Current event: ${snapshot.data.runtimeType}\nSource: ${snapshot.data!.source}',
textAlign: TextAlign.center,
);
},
Expand Down
23 changes: 11 additions & 12 deletions example/lib/pages/live_location.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class LiveLocationPage extends StatefulWidget {
}

class _LiveLocationPageState extends State<LiveLocationPage> {
LocationData _currentLocation;
MapController _mapController;
LocationData? _currentLocation;
late MapController _mapController;

bool _liveUpdate = false;
bool _permission = false;

String _serviceError = '';
String? _serviceError = '';

var interActiveFlags = InteractiveFlag.all;

Expand All @@ -35,11 +35,11 @@ class _LiveLocationPageState extends State<LiveLocationPage> {

void initLocationService() async {
await _locationService.changeSettings(
accuracy: LocationAccuracy.HIGH,
accuracy: LocationAccuracy.high,
interval: 1000,
);

LocationData location;
LocationData? location;
bool serviceEnabled;
bool serviceRequestResult;

Expand All @@ -48,13 +48,12 @@ class _LiveLocationPageState extends State<LiveLocationPage> {

if (serviceEnabled) {
var permission = await _locationService.requestPermission();
_permission = permission == PermissionStatus.GRANTED;
_permission = permission == PermissionStatus.granted;

if (_permission) {
location = await _locationService.getLocation();
_currentLocation = location;
_locationService
.onLocationChanged()
_locationService.onLocationChanged
.listen((LocationData result) async {
if (mounted) {
setState(() {
Expand All @@ -63,8 +62,8 @@ class _LiveLocationPageState extends State<LiveLocationPage> {
// If Live Update is enabled, move map center
if (_liveUpdate) {
_mapController.move(
LatLng(_currentLocation.latitude,
_currentLocation.longitude),
LatLng(_currentLocation!.latitude!,
_currentLocation!.longitude!),
_mapController.zoom);
}
});
Expand Down Expand Up @@ -97,7 +96,7 @@ class _LiveLocationPageState extends State<LiveLocationPage> {
// by default or store previous location value to show.
if (_currentLocation != null) {
currentLatLng =
LatLng(_currentLocation.latitude, _currentLocation.longitude);
LatLng(_currentLocation!.latitude!, _currentLocation!.longitude!);
} else {
currentLatLng = LatLng(0, 0);
}
Expand Down Expand Up @@ -125,7 +124,7 @@ class _LiveLocationPageState extends State<LiveLocationPage> {
children: [
Padding(
padding: EdgeInsets.only(top: 8.0, bottom: 8.0),
child: _serviceError.isEmpty
child: _serviceError!.isEmpty
? Text('This is a map that is showing '
'(${currentLatLng.latitude}, ${currentLatLng.longitude}).')
: Text(
Expand Down
12 changes: 6 additions & 6 deletions example/lib/pages/map_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MapControllerPageState extends State<MapControllerPage> {
static LatLng paris = LatLng(48.8566, 2.3522);
static LatLng dublin = LatLng(53.3498, -6.2603);

MapController mapController;
late MapController mapController;
double rotation = 0.0;

@override
Expand Down Expand Up @@ -119,7 +119,7 @@ class MapControllerPageState extends State<MapControllerPage> {
Builder(builder: (BuildContext context) {
return MaterialButton(
onPressed: () {
final bounds = mapController.bounds;
final bounds = mapController.bounds!;

ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
Expand Down Expand Up @@ -178,8 +178,8 @@ class MapControllerPageState extends State<MapControllerPage> {

class CurrentLocation extends StatefulWidget {
const CurrentLocation({
Key key,
@required this.mapController,
Key? key,
required this.mapController,
}) : super(key: key);

final MapController mapController;
Expand All @@ -192,7 +192,7 @@ class _CurrentLocationState extends State<CurrentLocation> {
int _eventKey = 0;

var icon = Icons.gps_not_fixed;
StreamSubscription<MapEvent> mapEventSubscription;
late StreamSubscription<MapEvent> mapEventSubscription;

@override
void initState() {
Expand Down Expand Up @@ -229,7 +229,7 @@ class _CurrentLocationState extends State<CurrentLocation> {
try {
var currentLocation = await location.getLocation();
var moved = widget.mapController.move(
LatLng(currentLocation.latitude, currentLocation.longitude),
LatLng(currentLocation.latitude!, currentLocation.longitude!),
18,
id: _eventKey.toString(),
);
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/marker_anchor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MarkerAnchorPage extends StatefulWidget {
}

class MarkerAnchorPageState extends State<MarkerAnchorPage> {
AnchorPos anchorPos;
late AnchorPos anchorPos;

@override
void initState() {
Expand Down
22 changes: 9 additions & 13 deletions example/lib/pages/marker_rotate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class MarkerRotatePage extends StatefulWidget {
}

class MarkerRotatePageState extends State<MarkerRotatePage> {
bool rotateMarkerLondon;
bool rotateMarkerDublin;
bool rotateMarkerParis;
bool? rotateMarkerLondon;
bool? rotateMarkerDublin;
bool? rotateMarkerParis;
bool rotateMarkerLayerOptions = false;

@override
Expand All @@ -33,7 +33,7 @@ class MarkerRotatePageState extends State<MarkerRotatePage> {
setState(() {
if (rotateMarkerLondon == null) {
rotateMarkerLondon = true;
} else if (rotateMarkerLondon) {
} else if (rotateMarkerLondon != null) {
rotateMarkerLondon = false;
} else {
rotateMarkerLondon = null;
Expand All @@ -45,7 +45,7 @@ class MarkerRotatePageState extends State<MarkerRotatePage> {
setState(() {
if (rotateMarkerDublin == null) {
rotateMarkerDublin = true;
} else if (rotateMarkerDublin) {
} else if (rotateMarkerDublin != null) {
rotateMarkerDublin = false;
} else {
rotateMarkerDublin = null;
Expand All @@ -57,7 +57,7 @@ class MarkerRotatePageState extends State<MarkerRotatePage> {
setState(() {
if (rotateMarkerParis == null) {
rotateMarkerParis = true;
} else if (rotateMarkerParis) {
} else if (rotateMarkerParis != null) {
rotateMarkerParis = false;
} else {
rotateMarkerParis = null;
Expand Down Expand Up @@ -108,17 +108,15 @@ class MarkerRotatePageState extends State<MarkerRotatePage> {
children: [
Padding(
padding: EdgeInsets.only(top: 8.0, bottom: 8.0),
child:
Text('Markers can be counter rotated to the map rotation.'),
child: Text('Markers can be counter rotated to the map rotation.'),
),
Padding(
padding: EdgeInsets.only(top: 8.0, bottom: 8.0),
child: Wrap(
children: <Widget>[
MaterialButton(
onPressed: _setRotateMarkerLayerOptions,
child:
Text('Set by LayerOptions: $rotateMarkerLayerOptions'),
child: Text('Set by LayerOptions: $rotateMarkerLayerOptions'),
),
MaterialButton(
onPressed: _setRotateMarkerLondon,
Expand All @@ -143,9 +141,7 @@ class MarkerRotatePageState extends State<MarkerRotatePage> {
),
layers: [
TileLayerOptions(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c']),
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', subdomains: ['a', 'b', 'c']),
MarkerLayerOptions(
rotate: rotateMarkerLayerOptions,
markers: markers,
Expand Down
6 changes: 3 additions & 3 deletions example/lib/pages/moving_markers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class MovingMarkersPage extends StatefulWidget {
}

class _MovingMarkersPageState extends State<MovingMarkersPage> {
Marker _marker;
Timer _timer;
Marker? _marker;
late Timer _timer;
int _markerIndex = 0;

@override
Expand Down Expand Up @@ -62,7 +62,7 @@ class _MovingMarkersPageState extends State<MovingMarkersPage> {
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c']),
MarkerLayerOptions(markers: <Marker>[_marker])
MarkerLayerOptions(markers: [_marker!])
],
),
),
Expand Down
4 changes: 2 additions & 2 deletions example/lib/pages/plugin_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class PluginPage extends StatelessWidget {
class MyCustomPluginOptions extends LayerOptions {
final String text;
MyCustomPluginOptions({
Key key,
Key? key,
this.text = '',
Stream<Null> rebuild,
Stream<Null>? rebuild,
}) : super(key: key, rebuild: rebuild);
}

Expand Down
36 changes: 19 additions & 17 deletions example/lib/pages/scale_layer_plugin_option.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import 'package:flutter_map/plugin_api.dart';
import './scalebar_utils.dart' as util;

class ScaleLayerPluginOption extends LayerOptions {
TextStyle textStyle;
TextStyle? textStyle;
Color lineColor;
double lineWidth;
final EdgeInsets padding;
final EdgeInsets? padding;

ScaleLayerPluginOption({
Key key,
Key? key,
this.textStyle,
this.lineColor = Colors.white,
this.lineWidth = 2,
this.padding,
Stream<Null> rebuild,
Stream<Null>? rebuild,
}) : super(key: key, rebuild: rebuild);
}

Expand Down Expand Up @@ -84,7 +84,7 @@ class ScaleLayer extends StatelessWidget {
var displayDistance = distance > 999
? '${(distance / 1000).toStringAsFixed(0)} km'
: '${distance.toStringAsFixed(0)} m';
double width = (end.x - start.x);
var width = (end.x - (start.x as double));

return CustomPaint(
painter: ScalePainter(
Expand All @@ -103,36 +103,38 @@ class ScalePainter extends CustomPainter {
ScalePainter(this.width, this.text,
{this.padding, this.textStyle, this.lineWidth, this.lineColor});
final double width;
final EdgeInsets padding;
final EdgeInsets? padding;
final String text;
TextStyle textStyle;
double lineWidth;
Color lineColor;
TextStyle? textStyle;
double? lineWidth;
Color? lineColor;

@override
void paint(ui.Canvas canvas, ui.Size size) {
final paint = Paint()
..color = lineColor
..color = lineColor!
..strokeCap = StrokeCap.square
..strokeWidth = lineWidth;
..strokeWidth = lineWidth!;

var sizeForStartEnd = 4;
var paddingLeft = padding == null ? 0 : padding.left + sizeForStartEnd / 2;
var paddingTop = padding == null ? 0 : padding.top;
var paddingLeft = padding == null ? 0 : padding!.left + sizeForStartEnd / 2;
var paddingTop = padding == null ? 0 : padding!.top;

var textSpan = TextSpan(style: textStyle, text: text);
var textPainter =
TextPainter(text: textSpan, textDirection: TextDirection.ltr)..layout();
textPainter.paint(canvas,
Offset(width / 2 - textPainter.width / 2 + paddingLeft, paddingTop));
textPainter.paint(
canvas,
Offset(width / 2 - textPainter.width / 2 + paddingLeft,
paddingTop as double));
paddingTop += textPainter.height;
var p1 = Offset(paddingLeft, sizeForStartEnd + paddingTop);
var p1 = Offset(paddingLeft as double, sizeForStartEnd + paddingTop);
var p2 = Offset(paddingLeft + width, sizeForStartEnd + paddingTop);
// draw start line
canvas.drawLine(Offset(paddingLeft, paddingTop),
Offset(paddingLeft, sizeForStartEnd + paddingTop), paint);
// draw middle line
var middleX = width / 2 + paddingLeft - lineWidth / 2;
var middleX = width / 2 + paddingLeft - lineWidth! / 2;
canvas.drawLine(Offset(middleX, paddingTop + sizeForStartEnd / 2),
Offset(middleX, sizeForStartEnd + paddingTop), paint);
// draw end line
Expand Down
Loading