From 793b4f0996df29716fa00ec27a635fb3c2d3b289 Mon Sep 17 00:00:00 2001 From: Kenneth Gulbrandsoy Date: Wed, 19 May 2021 22:27:59 +0200 Subject: [PATCH] Reformatted files to standard settings --- example/lib/pages/marker_rotate.dart | 10 ++++-- example/lib/pages/scalebar_utils.dart | 35 ++++++++++++++----- lib/src/gestures/gestures.dart | 10 +++--- lib/src/layer/polyline_layer.dart | 48 +++++++++++++++++---------- 4 files changed, 70 insertions(+), 33 deletions(-) diff --git a/example/lib/pages/marker_rotate.dart b/example/lib/pages/marker_rotate.dart index b976a32a7..a63ba2bef 100644 --- a/example/lib/pages/marker_rotate.dart +++ b/example/lib/pages/marker_rotate.dart @@ -108,7 +108,8 @@ class MarkerRotatePageState extends State { 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), @@ -116,7 +117,8 @@ class MarkerRotatePageState extends State { children: [ MaterialButton( onPressed: _setRotateMarkerLayerOptions, - child: Text('Set by LayerOptions: $rotateMarkerLayerOptions'), + child: + Text('Set by LayerOptions: $rotateMarkerLayerOptions'), ), MaterialButton( onPressed: _setRotateMarkerLondon, @@ -141,7 +143,9 @@ class MarkerRotatePageState extends State { ), 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, diff --git a/example/lib/pages/scalebar_utils.dart b/example/lib/pages/scalebar_utils.dart index 826574876..f888e2e8d 100644 --- a/example/lib/pages/scalebar_utils.dart +++ b/example/lib/pages/scalebar_utils.dart @@ -11,7 +11,8 @@ double toRadians(double degrees) { return degrees * piOver180; } -LatLng calculateEndingGlobalCoordinates(LatLng start, double startBearing, double distance) { +LatLng calculateEndingGlobalCoordinates( + LatLng start, double startBearing, double distance) { var mSemiMajorAxis = 6378137.0; //WGS84 major axis var mSemiMinorAxis = (1.0 - 1.0 / 298.257223563) * 6378137.0; var mFlattening = 1.0 / 298.257223563; @@ -42,10 +43,13 @@ LatLng calculateEndingGlobalCoordinates(LatLng start, double startBearing, doubl var uSquared = cos2Alpha * (aSquared - bSquared) / bSquared; // eq. 3 - var A = 1 + (uSquared / 16384) * (4096 + uSquared * (-768 + uSquared * (320 - 175 * uSquared))); + var A = 1 + + (uSquared / 16384) * + (4096 + uSquared * (-768 + uSquared * (320 - 175 * uSquared))); // eq. 4 - var B = (uSquared / 1024) * (256 + uSquared * (-128 + uSquared * (74 - 47 * uSquared))); + var B = (uSquared / 1024) * + (256 + uSquared * (-128 + uSquared * (74 - 47 * uSquared))); // iterate until there is a negligible change in sigma double deltaSigma; @@ -71,7 +75,10 @@ LatLng calculateEndingGlobalCoordinates(LatLng start, double startBearing, doubl (cosSigmaM2 + (B / 4.0) * (cosSignma * (-1 + 2 * cos2SigmaM2) - - (B / 6.0) * cosSigmaM2 * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM2))); + (B / 6.0) * + cosSigmaM2 * + (-3 + 4 * sinSigma * sinSigma) * + (-3 + 4 * cos2SigmaM2))); // eq. 7 sigma = sOverbA + deltaSigma; @@ -90,8 +97,11 @@ LatLng calculateEndingGlobalCoordinates(LatLng start, double startBearing, doubl sinSigma = sin(sigma); // eq. 8 - var phi2 = atan2(sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1, - (1.0 - f) * sqrt(sin2Alpha + pow(sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1, 2.0))); + var phi2 = atan2( + sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1, + (1.0 - f) * + sqrt(sin2Alpha + + pow(sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1, 2.0))); // eq. 9 // This fixes the pole crossing defect spotted by Matt Feemster. When a @@ -103,14 +113,21 @@ LatLng calculateEndingGlobalCoordinates(LatLng start, double startBearing, doubl // double tanLambda = sinSigma * sinAlpha1 / (cosU1 * cosSigma - sinU1 * // sinSigma * cosAlpha1); // double lambda = Math.atan(tanLambda); - var lambda = atan2(sinSigma * sinAlpha1, (cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1)); + var lambda = atan2( + sinSigma * sinAlpha1, (cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1)); // eq. 10 var C = (f / 16) * cos2Alpha * (4 + f * (4 - 3 * cos2Alpha)); // eq. 11 - var L = - lambda - (1 - C) * f * sinAlpha * (sigma + C * sinSigma * (cosSigmaM2 + C * cosSigma * (-1 + 2 * cos2SigmaM2))); + var L = lambda - + (1 - C) * + f * + sinAlpha * + (sigma + + C * + sinSigma * + (cosSigmaM2 + C * cosSigma * (-1 + 2 * cos2SigmaM2))); // eq. 12 // double alpha2 = Math.atan2(sinAlpha, -sinU1 * sinSigma + cosU1 * diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index 46dcc9d77..08b19d4cb 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -162,7 +162,8 @@ abstract class MapGestureMixin extends State } } - int _getMultiFingerGestureFlags({int? gestureWinner, MapOptions? mapOptions}) { + int _getMultiFingerGestureFlags( + {int? gestureWinner, MapOptions? mapOptions}) { gestureWinner ??= _gestureWinner; mapOptions ??= options; @@ -480,9 +481,10 @@ abstract class MapGestureMixin extends State } var direction = details.velocity.pixelsPerSecond / magnitude; - var distance = - (Offset.zero & Size(mapState.originalSize!.x as double, mapState.originalSize!.y as double)) - .shortestSide; + var distance = (Offset.zero & + Size(mapState.originalSize!.x as double, + mapState.originalSize!.y as double)) + .shortestSide; var _flingOffset = _focalStartLocal - _lastFocalLocal; _flingAnimation = Tween( diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index 981060aa2..b114748bb 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -64,7 +64,8 @@ class PolylineLayer extends StatelessWidget { final MapState map; final Stream? stream; - PolylineLayer(this.polylineOpts, this.map, this.stream) : super(key: polylineOpts.key); + PolylineLayer(this.polylineOpts, this.map, this.stream) + : super(key: polylineOpts.key); @override Widget build(BuildContext context) { @@ -85,7 +86,8 @@ class PolylineLayer extends StatelessWidget { for (var polylineOpt in polylineOpts.polylines) { polylineOpt.offsets.clear(); - if (polylineOpts.polylineCulling && !polylineOpt.boundingBox.isOverlapping(map.bounds)) { + if (polylineOpts.polylineCulling && + !polylineOpt.boundingBox.isOverlapping(map.bounds)) { // skip this polyline as it's offscreen continue; } @@ -112,7 +114,8 @@ class PolylineLayer extends StatelessWidget { var point = points[i]; var pos = map.project(point); - pos = pos.multiplyBy(map.getZoomScale(map.zoom, map.zoom)) - map.getPixelOrigin(); + pos = pos.multiplyBy(map.getZoomScale(map.zoom, map.zoom)) - + map.getPixelOrigin(); offsets.add(Offset(pos.x.toDouble(), pos.y.toDouble())); if (i > 0) { offsets.add(Offset(pos.x.toDouble(), pos.y.toDouble())); @@ -142,7 +145,9 @@ class PolylinePainter extends CustomPainter { if (polylineOpt.gradientColors == null) { paint.color = polylineOpt.color; } else { - polylineOpt.gradientColors!.isNotEmpty ? paint.shader = _paintGradient() : paint.color = polylineOpt.color; + polylineOpt.gradientColors!.isNotEmpty + ? paint.shader = _paintGradient() + : paint.color = polylineOpt.color; } Paint? filterPaint; @@ -158,7 +163,8 @@ class PolylinePainter extends CustomPainter { final borderPaint = polylineOpt.borderStrokeWidth > 0.0 ? (Paint() ..color = polylineOpt.borderColor ?? Color(0x00000000) - ..strokeWidth = polylineOpt.strokeWidth + polylineOpt.borderStrokeWidth + ..strokeWidth = + polylineOpt.strokeWidth + polylineOpt.borderStrokeWidth ..strokeCap = StrokeCap.round ..strokeJoin = StrokeJoin.round ..blendMode = BlendMode.srcOver) @@ -169,8 +175,10 @@ class PolylinePainter extends CustomPainter { var spacing = polylineOpt.strokeWidth * 1.5; canvas.saveLayer(rect, Paint()); if (borderPaint != null && filterPaint != null) { - _paintDottedLine(canvas, polylineOpt.offsets, borderRadius, spacing, borderPaint); - _paintDottedLine(canvas, polylineOpt.offsets, radius, spacing, filterPaint); + _paintDottedLine( + canvas, polylineOpt.offsets, borderRadius, spacing, borderPaint); + _paintDottedLine( + canvas, polylineOpt.offsets, radius, spacing, filterPaint); } _paintDottedLine(canvas, polylineOpt.offsets, radius, spacing, paint); canvas.restore(); @@ -188,7 +196,8 @@ class PolylinePainter extends CustomPainter { } } - void _paintDottedLine(Canvas canvas, List offsets, double radius, double stepLength, Paint paint) { + void _paintDottedLine(Canvas canvas, List offsets, double radius, + double stepLength, Paint paint) { final path = ui.Path(); var startDistance = 0.0; for (var i = 0; i < offsets.length - 1; i++) { @@ -203,9 +212,12 @@ class PolylinePainter extends CustomPainter { path.addOval(Rect.fromCircle(center: offset, radius: radius)); distance += stepLength; } - startDistance = distance < totalDistance ? stepLength - (totalDistance - distance) : distance - totalDistance; + startDistance = distance < totalDistance + ? stepLength - (totalDistance - distance) + : distance - totalDistance; } - path.addOval(Rect.fromCircle(center: polylineOpt.offsets.last, radius: radius)); + path.addOval( + Rect.fromCircle(center: polylineOpt.offsets.last, radius: radius)); canvas.drawPath(path, paint); } @@ -219,18 +231,20 @@ class PolylinePainter extends CustomPainter { } } - ui.Gradient _paintGradient() => ui.Gradient.linear( - polylineOpt.offsets.first, polylineOpt.offsets.last, polylineOpt.gradientColors!, _getColorsStop()); + ui.Gradient _paintGradient() => ui.Gradient.linear(polylineOpt.offsets.first, + polylineOpt.offsets.last, polylineOpt.gradientColors!, _getColorsStop()); - List? _getColorsStop() => - (polylineOpt.colorsStop != null && polylineOpt.colorsStop!.length == polylineOpt.gradientColors!.length) - ? polylineOpt.colorsStop - : _calculateColorsStop(); + List? _getColorsStop() => (polylineOpt.colorsStop != null && + polylineOpt.colorsStop!.length == polylineOpt.gradientColors!.length) + ? polylineOpt.colorsStop + : _calculateColorsStop(); List _calculateColorsStop() { final colorsStopInterval = 1.0 / polylineOpt.gradientColors!.length; return polylineOpt.gradientColors! - .map((gradientColor) => polylineOpt.gradientColors!.indexOf(gradientColor) * colorsStopInterval) + .map((gradientColor) => + polylineOpt.gradientColors!.indexOf(gradientColor) * + colorsStopInterval) .toList(); }