diff --git a/flutter_map/lib/src/core/bounds.dart b/flutter_map/lib/src/core/bounds.dart index e6ffc587c..082fa4d1e 100644 --- a/flutter_map/lib/src/core/bounds.dart +++ b/flutter_map/lib/src/core/bounds.dart @@ -13,7 +13,7 @@ class Bounds { const Bounds._(this.min, this.max); - Bounds extend(Point point) { + Bounds extend(Point point) { Point newMin; Point newMax; if (this.min == null && this.max == null) { @@ -30,8 +30,8 @@ class Bounds { return new Bounds._(newMin, newMax); } - Point getCenter() { - return new Point( + Point getCenter() { + return new Point( (min.x + max.x) / 2, (min.y + max.y) / 2, ); diff --git a/flutter_map/lib/src/core/point.dart b/flutter_map/lib/src/core/point.dart index d2fb9a900..3959d7844 100644 --- a/flutter_map/lib/src/core/point.dart +++ b/flutter_map/lib/src/core/point.dart @@ -12,11 +12,11 @@ class Point extends math.Point { } Point floor() { - return new Point(x.floor(), y.floor()); + return new Point(x.floor(), y.floor()); } - Point unscaleBy(Point point) { - return new Point(x / point.x, y / point.y); + Point unscaleBy(Point point) { + return new Point(x / point.x, y / point.y); } Point operator +(math.Point other) { diff --git a/flutter_map/lib/src/geo/crs/crs.dart b/flutter_map/lib/src/geo/crs/crs.dart index a75d5d615..8306cf5fd 100644 --- a/flutter_map/lib/src/geo/crs/crs.dart +++ b/flutter_map/lib/src/geo/crs/crs.dart @@ -17,7 +17,7 @@ abstract class Crs { try { var projectedPoint = this.projection.project(latlng); var scale = this.scale(zoom); - return transformation.transform(projectedPoint, scale); + return transformation.transform(projectedPoint, scale.toDouble()); } catch (e) { return new Point(0.0, 0.0); } @@ -25,7 +25,7 @@ abstract class Crs { LatLng pointToLatLng(Point point, double zoom) { var scale = this.scale(zoom); - var untransformedPoint = this.transformation.untransform(point, scale); + var untransformedPoint = this.transformation.untransform(point, scale.toDouble()); try { return projection.unproject(untransformedPoint); } catch (e) { @@ -33,7 +33,7 @@ abstract class Crs { } } - double scale(double zoom) { + num scale(double zoom) { return 256 * math.pow(2, zoom); } @@ -42,8 +42,8 @@ abstract class Crs { var b = projection.bounds; var s = this.scale(zoom); - var min = this.transformation.transform(b.min, s); - var max = this.transformation.transform(b.max, s); + var min = this.transformation.transform(b.min, s.toDouble()); + var max = this.transformation.transform(b.max, s.toDouble()); return new Bounds(min, max); } @@ -117,7 +117,7 @@ class Transformation { final num d; const Transformation(this.a, this.b, this.c, this.d); - Point transform(Point point, double scale) { + Point transform(Point point, double scale) { if (scale == null) { scale = 1.0; } diff --git a/flutter_map/lib/src/gestures/gestures.dart b/flutter_map/lib/src/gestures/gestures.dart index 07c216e28..bf4970e90 100644 --- a/flutter_map/lib/src/gestures/gestures.dart +++ b/flutter_map/lib/src/gestures/gestures.dart @@ -125,6 +125,6 @@ abstract class MapGestureMixin extends State } Offset _pointToOffset(Point point) { - return new Offset(point.x, point.y); + return new Offset(point.x.toDouble(), point.y.toDouble()); } } diff --git a/flutter_map/lib/src/layer/marker_layer.dart b/flutter_map/lib/src/layer/marker_layer.dart index c81b2a253..2855c4be8 100644 --- a/flutter_map/lib/src/layer/marker_layer.dart +++ b/flutter_map/lib/src/layer/marker_layer.dart @@ -39,8 +39,8 @@ class MarkerLayer extends StatelessWidget { new Positioned( width: markerOpt.width, height: markerOpt.height, - left: pos.x - markerOpt.width / 2, - top: pos.y - markerOpt.height / 2, + left: (pos.x - markerOpt.width / 2).toDouble(), + top: (pos.y - markerOpt.height / 2).toDouble(), child: markerOpt.builder(context), ), ); diff --git a/flutter_map/lib/src/layer/polyline_layer.dart b/flutter_map/lib/src/layer/polyline_layer.dart index e9a544ea2..c1473da98 100644 --- a/flutter_map/lib/src/layer/polyline_layer.dart +++ b/flutter_map/lib/src/layer/polyline_layer.dart @@ -36,9 +36,9 @@ class PolylineLayer extends StatelessWidget { var pos = map.project(point); pos = pos.multiplyBy(map.getZoomScale(map.zoom, map.zoom)) - map.getPixelOrigin(); - polylineOpt.offsets.add(new Offset(pos.x, pos.y)); + polylineOpt.offsets.add(new Offset(pos.x.toDouble(), pos.y.toDouble())); if (i > 0 && i < polylineOpt.points.length) { - polylineOpt.offsets.add(new Offset(pos.x, pos.y)); + polylineOpt.offsets.add(new Offset(pos.x.toDouble(), pos.y.toDouble())); } i++; } diff --git a/flutter_map/lib/src/layer/tile_layer.dart b/flutter_map/lib/src/layer/tile_layer.dart index 87214f779..fec802729 100644 --- a/flutter_map/lib/src/layer/tile_layer.dart +++ b/flutter_map/lib/src/layer/tile_layer.dart @@ -69,7 +69,7 @@ class _TileLayerState extends State { 'z': coords.z.round().toString(), 's': _getSubdomain(coords) }; - var allOpts = new Map.from(data)..addAll(this.options.additionalOptions); + Map allOpts = new Map.from(data)..addAll(this.options.additionalOptions); return util.template(this.options.urlTemplate, allOpts); } @@ -164,7 +164,7 @@ class _TileLayerState extends State { _tiles[key].current = false; } - _resetGrid() { + void _resetGrid() { var map = this.map; var crs = map.options.crs; var tileSize = this.getTileSize(); @@ -217,7 +217,7 @@ class _TileLayerState extends State { Widget build(BuildContext context) { var pixelBounds = _getTiledPixelBounds(map.center); var tileRange = _pxBoundsToTileRange(pixelBounds); - var tileCenter = tileRange.getCenter(); + Point tileCenter = tileRange.getCenter(); var queue = []; // mark tiles as out of view... @@ -259,8 +259,8 @@ class _TileLayerState extends State { tilesToRender.add(tile); } tilesToRender.sort((aTile, bTile) { - var a = aTile.coords; - var b = bTile.coords; + Coords a = aTile.coords; + Coords b = bTile.coords; // a = 13, b = 12, b is less than a, the result should be positive. if (a.z != b.z) { return (b.z - a.z).toInt(); @@ -285,7 +285,7 @@ class _TileLayerState extends State { var mapZoom = map.zoom; var scale = map.getZoomScale(mapZoom, this._tileZoom); var pixelCenter = map.project(center, this._tileZoom).floor(); - var halfSize = map.size / (scale * 2); + Point halfSize = map.size / (scale * 2); return new Bounds(pixelCenter - halfSize, pixelCenter + halfSize); } @@ -325,10 +325,10 @@ class _TileLayerState extends State { var blankImageBytes = new Uint8List(0); return new Positioned( - left: pos.x, - top: pos.y, - width: width, - height: height, + left: pos.x.toDouble(), + top: pos.y.toDouble(), + width: width.toDouble(), + height: height.toDouble(), child: new Container( child: new FadeInImage( fadeInDuration: const Duration(milliseconds: 100), @@ -342,7 +342,7 @@ class _TileLayerState extends State { ); } - _wrapCoords(Coords coords) { + Coords _wrapCoords(Coords coords) { var newCoords = new Coords( _wrapX != null ? util.wrapNum(coords.x.toDouble(), _wrapX) @@ -351,7 +351,7 @@ class _TileLayerState extends State { ? util.wrapNum(coords.y.toDouble(), _wrapY) : coords.y.toDouble(), ); - newCoords.z = coords.z; + newCoords.z = coords.z.toDouble(); return newCoords; } @@ -388,7 +388,7 @@ class Coords extends Point { T z; Coords(T x, T y) : super(x, y); String toString() => 'Coords($x, $y, $z)'; - bool operator ==(other) { + bool operator ==(dynamic other) { if (other is Coords) { return this.x == other.x && this.y == other.y && this.z == other.z; } diff --git a/flutter_map/lib/src/map/map.dart b/flutter_map/lib/src/map/map.dart index 5b1482f11..2997caff6 100644 --- a/flutter_map/lib/src/map/map.dart +++ b/flutter_map/lib/src/map/map.dart @@ -66,7 +66,7 @@ class MapState { move(options.center, zoom); } - void move(LatLng center, double zoom, [data]) { + void move(LatLng center, double zoom, [dynamic data]) { if (zoom == null) { zoom = this.zoom; } @@ -121,7 +121,7 @@ class MapState { } Point getNewPixelOrigin(LatLng center, [double zoom]) { - var viewHalf = this.size / 2; + var viewHalf = this.size / 2.0; return (this.project(center, zoom) - viewHalf).round(); } }