From c0d3d0ae074057310e563888f8e122c954bcf069 Mon Sep 17 00:00:00 2001 From: Vladyslav Khomenko Date: Fri, 21 Feb 2025 11:40:55 +0200 Subject: [PATCH 1/5] feat: add elevation style support for maps --- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Podfile | 2 +- example/ios/Podfile.lock | 6 +- example/ios/Runner.xcodeproj/project.pbxproj | 13 +-- .../xcshareddata/xcschemes/Runner.xcscheme | 3 +- example/ios/Runner/AppDelegate.swift | 2 +- example/ios/Runner/Info.plist | 2 + ios/Classes/MapView/AppleMapController.swift | 82 ++++++++++++++++++- ios/Classes/MapView/FlutterMapView.swift | 18 +++- lib/src/apple_map.dart | 9 +- lib/src/controller.dart | 14 ++++ lib/src/ui.dart | 5 ++ 12 files changed, 143 insertions(+), 15 deletions(-) diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 8d4492f..7c56964 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 12.0 diff --git a/example/ios/Podfile b/example/ios/Podfile index 1e8c3c9..279576f 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +# platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index eff7602..9e8df74 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -15,8 +15,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: apple_maps_flutter: c59725efea39e13e703cde52a1d2b14866ad68a8 - Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 -PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c +PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011 -COCOAPODS: 1.11.3 +COCOAPODS: 1.16.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index b74440f..065368c 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -156,7 +156,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -200,10 +200,12 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -236,6 +238,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -340,7 +343,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -414,7 +417,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -463,7 +466,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 3db53b6..4f74653 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift index 70693e4..b636303 100644 --- a/example/ios/Runner/AppDelegate.swift +++ b/example/ios/Runner/AppDelegate.swift @@ -1,7 +1,7 @@ import UIKit import Flutter -@UIApplicationMain +@main @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 6f300aa..5cf7c0a 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -45,5 +45,7 @@ CADisableMinimumFrameDurationOnPhone + UIApplicationSupportsIndirectInputEvents + diff --git a/ios/Classes/MapView/AppleMapController.swift b/ios/Classes/MapView/AppleMapController.swift index 85e7a98..c919762 100644 --- a/ios/Classes/MapView/AppleMapController.swift +++ b/ios/Classes/MapView/AppleMapController.swift @@ -37,7 +37,6 @@ public class AppleMapController: NSObject, FlutterPlatformView { self.mapView.delegate = self - self.mapView.setCenterCoordinate(initialCameraPosition, animated: false) self.setMethodCallHandlers() if let annotationsToAdd: NSArray = args["annotationsToAdd"] as? NSArray { @@ -52,6 +51,10 @@ public class AppleMapController: NSObject, FlutterPlatformView { if let circlesToAdd: NSArray = args["circlesToAdd"] as? NSArray { self.addCircles(circleData: circlesToAdd) } + + DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + self.mapView.setCenterCoordinate(self.initialCameraPosition, animated: false) + } } public func view() -> UIView { @@ -105,6 +108,23 @@ public class AppleMapController: NSObject, FlutterPlatformView { self.takeSnapshot(options: SnapshotOptions.init(options: args), onCompletion: { (snapshot: FlutterStandardTypedData?, error: Error?) -> Void in result(snapshot ?? error) }) + break + case "map#lookAround": + var selectedCoordinate: CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: args["latitude"] as! CLLocationDegrees, longitude: args["longitude"] as! CLLocationDegrees) + if #available(iOS 16.0, *) { + lookAround(selectedCoordinate: selectedCoordinate) + } + break + case "map#isLookAroundAvailable": + var selectedCoordinate: CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: args["latitude"] as! CLLocationDegrees, longitude: args["longitude"] as! CLLocationDegrees) + if #available(iOS 16.0, *) { + self.isLookAroundAvailable(selectedCoordinate: selectedCoordinate) { available in + result(available) + } + } else { + result(false) + } + break default: result(FlutterMethodNotImplemented) break @@ -150,6 +170,66 @@ public class AppleMapController: NSObject, FlutterPlatformView { }) } + @available(iOS 16.0, *) + func lookAround(selectedCoordinate: CLLocationCoordinate2D) { + // Create a look around scene request + let sceneRequest = MKLookAroundSceneRequest(coordinate: selectedCoordinate) + + // Fetch the look around scene + sceneRequest.getSceneWithCompletionHandler { [weak self] (scene: MKLookAroundScene?, error: Error?) in + guard let self = self else { return } + + if let error = error { + print("Error fetching look around scene: \(error)") + return + } + + guard let scene = scene else { + print("No look around scene available at this location") + return + } + + // Store the fetched scene + let lookAroundScene = scene + + // Create and present a look around view controller + let lookAroundVC = MKLookAroundViewController(scene: scene) + + // Make sure to present the look around view controller on the main thread + DispatchQueue.main.async { + if let topVC = self.getTopViewController() { + topVC.present(lookAroundVC, animated: true, completion: nil) + } + } + } + } + + @available(iOS 16.0, *) + func isLookAroundAvailable(selectedCoordinate: CLLocationCoordinate2D, completion: @escaping (Bool) -> Void) { + let sceneRequest = MKLookAroundSceneRequest(coordinate: selectedCoordinate) + sceneRequest.getSceneWithCompletionHandler { (scene: MKLookAroundScene?, error: Error?) in + if let _ = scene { + completion(true) + } else { + completion(false) + } + } + } + + + private func getTopViewController() -> UIViewController? { + var topViewController: UIViewController? = nil + if #available(iOS 13.0, *) { + if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene { + topViewController = windowScene.windows.first { $0.isKeyWindow }?.rootViewController + while let presentedVC = topViewController?.presentedViewController { + topViewController = presentedVC + } + } + } + return topViewController + } + private func annotationUpdate(args: Dictionary) -> Void { if let annotationsToAdd = args["annotationsToAdd"] as? NSArray { if annotationsToAdd.count > 0 { diff --git a/ios/Classes/MapView/FlutterMapView.swift b/ios/Classes/MapView/FlutterMapView.swift index 1e733ed..547e481 100644 --- a/ios/Classes/MapView/FlutterMapView.swift +++ b/ios/Classes/MapView/FlutterMapView.swift @@ -142,7 +142,23 @@ class FlutterMapView: MKMapView, UIGestureRecognizerDelegate { } if let mapType: Int = options["mapType"] as? Int { - self.mapType = self.mapTypes[mapType] + if #available(iOS 16.0, *) { + let elevationStyle: MKMapConfiguration.ElevationStyle = (options["elevationStyle"] as? Int) == 0 ? MKMapConfiguration.ElevationStyle.flat : MKMapConfiguration.ElevationStyle.realistic + + switch(mapType) { + case 0: + self.preferredConfiguration = MKStandardMapConfiguration(elevationStyle: elevationStyle) + break + case 1: + self.preferredConfiguration = MKImageryMapConfiguration(elevationStyle: elevationStyle) + break + default: + self.preferredConfiguration = MKHybridMapConfiguration(elevationStyle: elevationStyle); + break + } + } else { + self.mapType = self.mapTypes[mapType] + } } if let trafficEnabled: Bool = options["trafficEnabled"] as? Bool { diff --git a/lib/src/apple_map.dart b/lib/src/apple_map.dart index 793a269..4cbc7e4 100644 --- a/lib/src/apple_map.dart +++ b/lib/src/apple_map.dart @@ -43,6 +43,7 @@ class AppleMap extends StatefulWidget { this.onLongPress, this.snapshotOptions, this.insetsLayoutMarginsFromSafeArea = true, + this.elevationStyle = ElevationStyle.flat }) : super(key: key); final MapCreatedCallback? onMapCreated; @@ -169,7 +170,8 @@ class AppleMap extends StatefulWidget { /// A Boolean value indicating whether the view's layout margins are updated /// automatically to reflect the safe area. final bool insetsLayoutMarginsFromSafeArea; - + /// The style of the elevation effect on the map. + final ElevationStyle elevationStyle; @override State createState() => _AppleMapState(); } @@ -342,6 +344,7 @@ class _AppleMapOptions { this.myLocationButtonEnabled, this.padding, this.insetsLayoutMarginsFromSafeArea, + this.elevationStyle }); static _AppleMapOptions fromWidget(AppleMap map) { @@ -359,6 +362,7 @@ class _AppleMapOptions { myLocationButtonEnabled: map.myLocationButtonEnabled, padding: map.padding, insetsLayoutMarginsFromSafeArea: map.insetsLayoutMarginsFromSafeArea, + elevationStyle: map.elevationStyle ); } @@ -388,6 +392,8 @@ class _AppleMapOptions { final bool? insetsLayoutMarginsFromSafeArea; + final ElevationStyle? elevationStyle; + Map toMap() { final Map optionsMap = {}; @@ -411,6 +417,7 @@ class _AppleMapOptions { addIfNonNull('padding', _serializePadding(padding)); addIfNonNull( 'insetsLayoutMarginsFromSafeArea', insetsLayoutMarginsFromSafeArea); + addIfNonNull('elevationStyle', elevationStyle?.index); return optionsMap; } diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 72fd6e1..168eec9 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -244,4 +244,18 @@ class AppleMapController { return channel.invokeMethod( 'map#takeSnapshot', snapshotOptions._toMap()); } + + Future lookAround(LatLng latLng) async { + await channel.invokeMethod('map#lookAround', { + 'latitude': latLng.latitude, + 'longitude': latLng.longitude + }); + } + + Future isLookAroundAvailable(LatLng latLng) async { + return channel.invokeMethod('map#isLookAroundAvailable', { + 'latitude': latLng.latitude, + 'longitude': latLng.longitude + }); + } } diff --git a/lib/src/ui.dart b/lib/src/ui.dart index 71c00a5..944b66c 100644 --- a/lib/src/ui.dart +++ b/lib/src/ui.dart @@ -27,6 +27,11 @@ enum TrackingMode { followWithHeading, } +enum ElevationStyle { + flat, + realistic, +} + /// Bounds for the map camera target. // Used with [AppleMapOptions] to wrap a [LatLngBounds] value. This allows // distinguishing between specifying an unbounded target (null `LatLngBounds`) From 3f0cd36ea07e7e8b66ab3f10b47876e69aa03110 Mon Sep 17 00:00:00 2001 From: Vladyslav Khomenko Date: Fri, 21 Feb 2025 11:42:12 +0200 Subject: [PATCH 2/5] feat: exclude all points of interest in look around view controller --- ios/Classes/MapView/AppleMapController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/ios/Classes/MapView/AppleMapController.swift b/ios/Classes/MapView/AppleMapController.swift index c919762..ef4160e 100644 --- a/ios/Classes/MapView/AppleMapController.swift +++ b/ios/Classes/MapView/AppleMapController.swift @@ -194,6 +194,7 @@ public class AppleMapController: NSObject, FlutterPlatformView { // Create and present a look around view controller let lookAroundVC = MKLookAroundViewController(scene: scene) + lookAroundVC.pointOfInterestFilter = MKPointOfInterestFilter.excludingAll // Make sure to present the look around view controller on the main thread DispatchQueue.main.async { From fa26e0a32bf36d05ef62e9cbee32d4267ee28beb Mon Sep 17 00:00:00 2001 From: Vladyslav Khomenko Date: Fri, 21 Feb 2025 11:50:45 +0200 Subject: [PATCH 3/5] feat: add point of interest filtering for look around feature --- ios/Classes/MapView/AppleMapController.swift | 139 ++++++++++++++++++- lib/src/controller.dart | 48 ++++++- pubspec.yaml | 2 +- 3 files changed, 183 insertions(+), 6 deletions(-) diff --git a/ios/Classes/MapView/AppleMapController.swift b/ios/Classes/MapView/AppleMapController.swift index ef4160e..159dbf3 100644 --- a/ios/Classes/MapView/AppleMapController.swift +++ b/ios/Classes/MapView/AppleMapController.swift @@ -112,7 +112,138 @@ public class AppleMapController: NSObject, FlutterPlatformView { case "map#lookAround": var selectedCoordinate: CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: args["latitude"] as! CLLocationDegrees, longitude: args["longitude"] as! CLLocationDegrees) if #available(iOS 16.0, *) { - lookAround(selectedCoordinate: selectedCoordinate) + var categoryNames: Array = args["poi_filter"] as? Array ?? [] + + var categories: [MKPointOfInterestCategory] = categoryNames.map { name in + var category: MKPointOfInterestCategory; + switch(name) { + case "airport": + category = .airport + break + case "amusementPark": + category = .amusementPark + break + case "aquarium": + category = .aquarium + break + case "atm": + category = .atm + break + case "bakery": + category = .bakery + break + case "bank": + category = .bank + break + case "beach": + category = .beach + break + case "brewery": + category = .brewery + break + case "cafe": + category = .cafe + break + case "campground": + category = .campground + break + case "carRental": + category = .carRental + break + case "evCharger": + category = .evCharger + break + case "fireStation": + category = .fireStation + break + case "fitnessCenter": + category = .fitnessCenter + break + case "foodMarket": + category = .foodMarket + break + case "gasStation": + category = .gasStation + break + case "hospital": + category = .hospital + break + case "hotel": + category = .hotel + break + case "laundry": + category = .laundry + break + case "library": + category = .library + break + case "marina": + category = .marina + break + case "movieTheater": + category = .movieTheater + break + case "museum": + category = .museum + break + case "nationalPark": + category = .nationalPark + break + case "nightlife": + category = .nightlife + break + case "park": + category = .park + break + case "parking": + category = .parking + break + case "pharmacy": + category = .pharmacy + break + case "police": + category = .police + break + case "postOffice": + category = .postOffice + break + case "publicTransport": + category = .publicTransport + break + case "restaurant": + category = .restaurant + break + case "restroom": + category = .restroom + break + case "school": + category = .school + break + case "stadium": + category = .stadium + break + case "store": + category = .store + break + case "theater": + category = .theater + break + case "university": + category = .university + break + case "winery": + category = .winery + break + case "zoo": + category = .zoo + break + default: + category = MKPointOfInterestCategory(rawValue: name) + } + return category + } + + lookAround(selectedCoordinate: selectedCoordinate, categories: categories) } break case "map#isLookAroundAvailable": @@ -171,7 +302,7 @@ public class AppleMapController: NSObject, FlutterPlatformView { } @available(iOS 16.0, *) - func lookAround(selectedCoordinate: CLLocationCoordinate2D) { + func lookAround(selectedCoordinate: CLLocationCoordinate2D, categories: [MKPointOfInterestCategory]) { // Create a look around scene request let sceneRequest = MKLookAroundSceneRequest(coordinate: selectedCoordinate) @@ -194,7 +325,9 @@ public class AppleMapController: NSObject, FlutterPlatformView { // Create and present a look around view controller let lookAroundVC = MKLookAroundViewController(scene: scene) - lookAroundVC.pointOfInterestFilter = MKPointOfInterestFilter.excludingAll + if(categories.isEmpty == false) { + lookAroundVC.pointOfInterestFilter = MKPointOfInterestFilter(including: categories) + } // Make sure to present the look around view controller on the main thread DispatchQueue.main.async { diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 168eec9..7c3c97a 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -4,6 +4,49 @@ part of apple_maps_flutter; +enum PointOfInterestCategory { + airport, + amusementPark, + aquarium, + atm, + bakery, + bank, + beach, + brewery, + cafe, + campground, + carRental, + evCharger, + fireStation, + fitnessCenter, + foodMarket, + gasStation, + hospital, + hotel, + laundry, + library, + marina, + movieTheater, + museum, + nationalPark, + nightlife, + park, + parking, + pharmacy, + police, + postOffice, + publicTransport, + restaurant, + restroom, + school, + stadium, + store, + theater, + university, + winery, + zoo +} + /// Controller for a single AppleMap instance running on the host platform. class AppleMapController { AppleMapController._( @@ -245,10 +288,11 @@ class AppleMapController { 'map#takeSnapshot', snapshotOptions._toMap()); } - Future lookAround(LatLng latLng) async { + Future lookAround(LatLng latLng, List poiFilter) async { await channel.invokeMethod('map#lookAround', { 'latitude': latLng.latitude, - 'longitude': latLng.longitude + 'longitude': latLng.longitude, + 'poi_filter': poiFilter.map((e) => e.name,).toList() }); } diff --git a/pubspec.yaml b/pubspec.yaml index 8fb876c..cd196b2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ repository: https://github.com/LuisThein/apple_maps_flutter issue_tracker: https://github.com/LuisThein/apple_maps_flutter/issues environment: - sdk: ">=2.14.0 <3.0.0" + sdk: ">=2.15.0 <3.0.0" flutter: ">=1.17.0" dependencies: From 6487a1b9187caf58d503c3901eb3ea8b59f03b35 Mon Sep 17 00:00:00 2001 From: Vladyslav Khomenko Date: Fri, 21 Feb 2025 12:27:09 +0200 Subject: [PATCH 4/5] refactor: remove unused imports and improve type safety in equality operators --- example/lib/map_click.dart | 1 - example/lib/map_coordinates.dart | 1 - example/lib/place_annotation.dart | 2 -- example/lib/scrolling_map.dart | 1 - example/test_driver/test_widgets.dart | 2 +- lib/apple_maps_flutter.dart | 3 --- lib/src/annotation.dart | 2 +- lib/src/camera.dart | 4 ++-- lib/src/snapshot_options.dart | 4 ++-- lib/src/ui.dart | 8 ++++---- test/annotation_updates_test.dart | 5 +++-- test/apple_map_test.dart | 5 +++-- test/circle_updates_test.dart | 5 +++-- test/fake_maps_controllers.dart | 2 +- test/polygon_update_test.dart | 5 +++-- test/polyline_updates_test.dart | 5 +++-- 16 files changed, 26 insertions(+), 29 deletions(-) diff --git a/example/lib/map_click.dart b/example/lib/map_click.dart index 49510d4..11ff0ab 100644 --- a/example/lib/map_click.dart +++ b/example/lib/map_click.dart @@ -4,7 +4,6 @@ import 'package:apple_maps_flutter/apple_maps_flutter.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'page.dart'; diff --git a/example/lib/map_coordinates.dart b/example/lib/map_coordinates.dart index de28d54..40fe480 100644 --- a/example/lib/map_coordinates.dart +++ b/example/lib/map_coordinates.dart @@ -4,7 +4,6 @@ import 'package:apple_maps_flutter/apple_maps_flutter.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'page.dart'; diff --git a/example/lib/place_annotation.dart b/example/lib/place_annotation.dart index 3a3e28b..6669584 100644 --- a/example/lib/place_annotation.dart +++ b/example/lib/place_annotation.dart @@ -4,8 +4,6 @@ import 'dart:async'; import 'dart:math'; -import 'dart:typed_data'; -import 'dart:ui'; import 'dart:ui' as ui; import 'package:apple_maps_flutter/apple_maps_flutter.dart'; diff --git a/example/lib/scrolling_map.dart b/example/lib/scrolling_map.dart index 4b6143a..2f7e461 100644 --- a/example/lib/scrolling_map.dart +++ b/example/lib/scrolling_map.dart @@ -8,7 +8,6 @@ import 'package:apple_maps_flutter/apple_maps_flutter.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; import 'page.dart'; diff --git a/example/test_driver/test_widgets.dart b/example/test_driver/test_widgets.dart index d2c27fd..5656c9f 100644 --- a/example/test_driver/test_widgets.dart +++ b/example/test_driver/test_widgets.dart @@ -8,5 +8,5 @@ import 'package:flutter/widgets.dart'; Future pumpWidget(Widget widget) { runApp(widget); - return WidgetsBinding.instance!.endOfFrame; + return WidgetsBinding.instance.endOfFrame; } diff --git a/lib/apple_maps_flutter.dart b/lib/apple_maps_flutter.dart index dccdfc8..670d7e6 100644 --- a/lib/apple_maps_flutter.dart +++ b/lib/apple_maps_flutter.dart @@ -5,13 +5,10 @@ library apple_maps_flutter; import 'dart:async'; -import 'dart:typed_data'; -import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; part 'src/annotation.dart'; diff --git a/lib/src/annotation.dart b/lib/src/annotation.dart index 71b6b12..eeda85b 100644 --- a/lib/src/annotation.dart +++ b/lib/src/annotation.dart @@ -129,7 +129,7 @@ class AnnotationId { /// A annotation icon is drawn oriented against the device's screen rather than /// the map's surface; that is, it will not necessarily change orientation /// due to map rotations, tilting, or zooming. -@immutable + class Annotation { /// Creates a set of annotation configuration options. /// diff --git a/lib/src/camera.dart b/lib/src/camera.dart index fb842af..768e225 100644 --- a/lib/src/camera.dart +++ b/lib/src/camera.dart @@ -62,10 +62,10 @@ class CameraPosition { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { if (identical(this, other)) return true; if (runtimeType != other.runtimeType) return false; - final CameraPosition typedOther = other; + final CameraPosition typedOther = other as CameraPosition; return heading == typedOther.heading && target == typedOther.target && pitch == typedOther.pitch && diff --git a/lib/src/snapshot_options.dart b/lib/src/snapshot_options.dart index dbfa854..df3db18 100644 --- a/lib/src/snapshot_options.dart +++ b/lib/src/snapshot_options.dart @@ -34,10 +34,10 @@ class SnapshotOptions { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { if (identical(this, other)) return true; if (runtimeType != other.runtimeType) return false; - final SnapshotOptions typedOther = other; + final SnapshotOptions typedOther = other as SnapshotOptions; return showBuildings == typedOther.showBuildings && showPointsOfInterest == typedOther.showPointsOfInterest && showAnnotations == typedOther.showAnnotations && diff --git a/lib/src/ui.dart b/lib/src/ui.dart index 944b66c..9685cec 100644 --- a/lib/src/ui.dart +++ b/lib/src/ui.dart @@ -50,10 +50,10 @@ class CameraTargetBounds { static const CameraTargetBounds unbounded = CameraTargetBounds(null); @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { if (identical(this, other)) return true; if (runtimeType != other.runtimeType) return false; - final CameraTargetBounds typedOther = other; + final CameraTargetBounds typedOther = other as CameraTargetBounds; return bounds == typedOther.bounds; } @@ -83,10 +83,10 @@ class MinMaxZoomPreference { dynamic _toJson() => [minZoom, maxZoom]; @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { if (identical(this, other)) return true; if (runtimeType != other.runtimeType) return false; - final MinMaxZoomPreference typedOther = other; + final MinMaxZoomPreference typedOther = other as MinMaxZoomPreference; return minZoom == typedOther.minZoom && maxZoom == typedOther.maxZoom; } diff --git a/test/annotation_updates_test.dart b/test/annotation_updates_test.dart index fb80e12..da26129 100644 --- a/test/annotation_updates_test.dart +++ b/test/annotation_updates_test.dart @@ -41,8 +41,9 @@ void main() { FakePlatformViewsController(); setUpAll(() { - SystemChannels.platform_views.setMockMethodCallHandler( - fakePlatformViewsController.fakePlatformViewsMethodHandler); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(SystemChannels.platform_views, + fakePlatformViewsController.fakePlatformViewsMethodHandler); }); setUp(() { diff --git a/test/apple_map_test.dart b/test/apple_map_test.dart index 9e7222a..8109413 100644 --- a/test/apple_map_test.dart +++ b/test/apple_map_test.dart @@ -16,8 +16,9 @@ void main() { FakePlatformViewsController(); setUpAll(() { - SystemChannels.platform_views.setMockMethodCallHandler( - fakePlatformViewsController.fakePlatformViewsMethodHandler); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(SystemChannels.platform_views, + fakePlatformViewsController.fakePlatformViewsMethodHandler); }); setUp(() { diff --git a/test/circle_updates_test.dart b/test/circle_updates_test.dart index a134661..961e561 100644 --- a/test/circle_updates_test.dart +++ b/test/circle_updates_test.dart @@ -41,8 +41,9 @@ void main() { FakePlatformViewsController(); setUpAll(() { - SystemChannels.platform_views.setMockMethodCallHandler( - fakePlatformViewsController.fakePlatformViewsMethodHandler); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(SystemChannels.platform_views, + fakePlatformViewsController.fakePlatformViewsMethodHandler); }); setUp(() { diff --git a/test/fake_maps_controllers.dart b/test/fake_maps_controllers.dart index fa992ac..6a76f13 100644 --- a/test/fake_maps_controllers.dart +++ b/test/fake_maps_controllers.dart @@ -13,7 +13,7 @@ class FakePlatformAppleMap { cameraPosition = CameraPosition.fromMap(params['initialCameraPosition']); channel = MethodChannel('apple_maps_plugin.luisthein.de/apple_maps_$id', const StandardMethodCodec()); - channel.setMockMethodCallHandler(onMethodCall); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(channel, onMethodCall); updateOptions(params['options']); updatePolylines(params); updateAnnotations(params); diff --git a/test/polygon_update_test.dart b/test/polygon_update_test.dart index 221c71d..a7ecd62 100644 --- a/test/polygon_update_test.dart +++ b/test/polygon_update_test.dart @@ -41,8 +41,9 @@ void main() { FakePlatformViewsController(); setUpAll(() { - SystemChannels.platform_views.setMockMethodCallHandler( - fakePlatformViewsController.fakePlatformViewsMethodHandler); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(SystemChannels.platform_views, + fakePlatformViewsController.fakePlatformViewsMethodHandler); }); setUp(() { diff --git a/test/polyline_updates_test.dart b/test/polyline_updates_test.dart index 1532e85..a29bd8f 100644 --- a/test/polyline_updates_test.dart +++ b/test/polyline_updates_test.dart @@ -40,8 +40,9 @@ void main() { FakePlatformViewsController(); setUpAll(() { - SystemChannels.platform_views.setMockMethodCallHandler( - fakePlatformViewsController.fakePlatformViewsMethodHandler); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(SystemChannels.platform_views, + fakePlatformViewsController.fakePlatformViewsMethodHandler); }); setUp(() { From cdc02eafa0f2356d507505d26b16cb8a78189240 Mon Sep 17 00:00:00 2001 From: Vladyslav Khomenko Date: Fri, 21 Feb 2025 12:33:10 +0200 Subject: [PATCH 5/5] chore: update changelog for version 1.4.1 and bump version to 1.4.1 --- CHANGELOG.md | 6 ++++++ pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f793020..7a30499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.4.1 + +* Added elevation style support for maps +* Added the LookAround feature support +* Remove unused imports and improved type safety in equality operators + ## 1.4.0 * Flutter 3.27.1 compatibility, replace `ui.hash*` with `Object.hash* diff --git a/pubspec.yaml b/pubspec.yaml index cd196b2..d452ede 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: apple_maps_flutter description: This plugin uses the Flutter platform view to display an Apple Maps widget. -version: 1.4.0 +version: 1.4.1 homepage: https://luisthein.de repository: https://github.com/LuisThein/apple_maps_flutter issue_tracker: https://github.com/LuisThein/apple_maps_flutter/issues