From cc9e4869f067a0bf2a3d8847febc0503cfdfb865 Mon Sep 17 00:00:00 2001 From: James Morton Date: Wed, 21 Feb 2024 07:16:54 -0500 Subject: [PATCH 1/2] override loadImage instead of load in MapKitSnapshotterImage --- lib/src/mapkit_snapshotter_image.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/mapkit_snapshotter_image.dart b/lib/src/mapkit_snapshotter_image.dart index d1a74bb..10b8a88 100644 --- a/lib/src/mapkit_snapshotter_image.dart +++ b/lib/src/mapkit_snapshotter_image.dart @@ -40,7 +40,10 @@ class MapKitSnapshotterImage MapKitSnapshotterImage(this.options); @override - ImageStreamCompleter load(MapKitSnapshotterImageProviderKey key, decode) { + ImageStreamCompleter loadImage( + MapKitSnapshotterImageProviderKey key, + decode, + ) { return OneFrameImageStreamCompleter(Future(() async { // Capture the screenshot on the iOS native side. final captureResponse = await _channel.invokeMethod( From 9f8e368574e1d45a5cbf94925cce4046e5d98d94 Mon Sep 17 00:00:00 2001 From: James Morton Date: Wed, 21 Feb 2024 07:17:30 -0500 Subject: [PATCH 2/2] upgrade packages and fix lint errors --- analysis_options.yaml | 38 +++++--- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Podfile | 2 +- example/ios/Podfile.lock | 6 +- example/ios/Runner.xcodeproj/project.pbxproj | 13 ++- .../contents.xcworkspacedata | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- example/ios/Runner/Info.plist | 4 + example/lib/demo.dart | 1 - lib/src/mapkit_snapshotter_types.dart | 6 +- lib/src/mapkit_snapshotter_types.g.dart | 92 ++++++------------- pubspec.yaml | 10 +- test/mapkit_snapshotter_flutter_test.dart | 16 +++- 13 files changed, 91 insertions(+), 103 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index a686c1b..5a368c3 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,14 +1,28 @@ -# Defines a default set of lint rules enforced for -# projects at Google. For details and rationale, -# see https://github.com/dart-lang/pedantic#enabled-lints. -include: package:pedantic/analysis_options.yaml +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. -# For lint rules and documentation, see http://dart-lang.github.io/linter/lints. -# Uncomment to specify additional rules. -# linter: -# rules: -# - camel_case_types +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml -analyzer: -# exclude: -# - path/to/excluded/files/** +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options \ No newline at end of file diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 6b4c0f7..8c6e561 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.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 57bc9ee..7aac545 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -14,9 +14,9 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/mapkit_snapshotter_flutter/ios" SPEC CHECKSUMS: - Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 mapkit_snapshotter_flutter: e0e409e148be7f41e414b9ffce0101618d8806f7 -PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c +PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011 -COCOAPODS: 1.10.1 +COCOAPODS: 1.15.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 5ae1638..3668c07 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -156,7 +156,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -222,10 +222,12 @@ }; 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; @@ -422,7 +425,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; @@ -471,7 +474,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/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a1..919434a 100644 --- a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..e67b280 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + diff --git a/example/lib/demo.dart b/example/lib/demo.dart index ea47d6c..0546fcc 100644 --- a/example/lib/demo.dart +++ b/example/lib/demo.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mapkit_snapshotter_flutter/mapkit_snapshotter_flutter.dart'; diff --git a/lib/src/mapkit_snapshotter_types.dart b/lib/src/mapkit_snapshotter_types.dart index edef3df..26bad34 100644 --- a/lib/src/mapkit_snapshotter_types.dart +++ b/lib/src/mapkit_snapshotter_types.dart @@ -27,7 +27,7 @@ class MapKitSnapshotterOptions { /// If POIs shall be shown on the capture. final bool? showsPointsOfInterest; - MapKitSnapshotterOptions({ + const MapKitSnapshotterOptions({ required this.region, this.mapType, this.brightness, @@ -116,7 +116,7 @@ class MapKitSnapshotterRegion { final double latitudeMeters; final double longitudeMeters; - MapKitSnapshotterRegion({ + const MapKitSnapshotterRegion({ required this.centerLatitude, required this.centerLongitude, required this.latitudeMeters, @@ -163,7 +163,7 @@ class MapKitSnapshotterImageProviderKey { final double devicePixelRatio; final MapKitSnapshotterOptions options; - MapKitSnapshotterImageProviderKey({ + const MapKitSnapshotterImageProviderKey({ required this.sizeHeight, required this.sizeWidth, required this.options, diff --git a/lib/src/mapkit_snapshotter_types.g.dart b/lib/src/mapkit_snapshotter_types.g.dart index 8cd48bb..f3f2b0a 100644 --- a/lib/src/mapkit_snapshotter_types.g.dart +++ b/lib/src/mapkit_snapshotter_types.g.dart @@ -7,18 +7,17 @@ part of 'mapkit_snapshotter_types.dart'; // ************************************************************************** MapKitSnapshotterOptions _$MapKitSnapshotterOptionsFromJson( - Map json) { - return MapKitSnapshotterOptions( - region: MapKitSnapshotterRegion.fromJson( - json['region'] as Map), - mapType: _$enumDecodeNullable( - _$MapKitSnapshotterMapTypeEnumMap, json['mapType']), - brightness: _$enumDecodeNullable( - _$MapKitSnapshotterBrightnessEnumMap, json['brightness']), - showsBuildings: json['showsBuildings'] as bool?, - showsPointsOfInterest: json['showsPointsOfInterest'] as bool?, - ); -} + Map json) => + MapKitSnapshotterOptions( + region: MapKitSnapshotterRegion.fromJson( + json['region'] as Map), + mapType: $enumDecodeNullable( + _$MapKitSnapshotterMapTypeEnumMap, json['mapType']), + brightness: $enumDecodeNullable( + _$MapKitSnapshotterBrightnessEnumMap, json['brightness']), + showsBuildings: json['showsBuildings'] as bool?, + showsPointsOfInterest: json['showsPointsOfInterest'] as bool?, + ); Map _$MapKitSnapshotterOptionsToJson( MapKitSnapshotterOptions instance) { @@ -41,43 +40,6 @@ Map _$MapKitSnapshotterOptionsToJson( return val; } -K _$enumDecode( - Map enumValues, - Object? source, { - K? unknownValue, -}) { - if (source == null) { - throw ArgumentError( - 'A value must be provided. Supported values: ' - '${enumValues.values.join(', ')}', - ); - } - - return enumValues.entries.singleWhere( - (e) => e.value == source, - orElse: () { - if (unknownValue == null) { - throw ArgumentError( - '`$source` is not one of the supported values: ' - '${enumValues.values.join(', ')}', - ); - } - return MapEntry(unknownValue, enumValues.values.first); - }, - ).key; -} - -K? _$enumDecodeNullable( - Map enumValues, - dynamic source, { - K? unknownValue, -}) { - if (source == null) { - return null; - } - return _$enumDecode(enumValues, source, unknownValue: unknownValue); -} - const _$MapKitSnapshotterMapTypeEnumMap = { MapKitSnapshotterMapType.standard: 'standard', MapKitSnapshotterMapType.satellite: 'satellite', @@ -93,14 +55,13 @@ const _$MapKitSnapshotterBrightnessEnumMap = { }; MapKitSnapshotterRegion _$MapKitSnapshotterRegionFromJson( - Map json) { - return MapKitSnapshotterRegion( - centerLatitude: (json['centerLatitude'] as num).toDouble(), - centerLongitude: (json['centerLongitude'] as num).toDouble(), - latitudeMeters: (json['latitudeMeters'] as num).toDouble(), - longitudeMeters: (json['longitudeMeters'] as num).toDouble(), - ); -} + Map json) => + MapKitSnapshotterRegion( + centerLatitude: (json['centerLatitude'] as num).toDouble(), + centerLongitude: (json['centerLongitude'] as num).toDouble(), + latitudeMeters: (json['latitudeMeters'] as num).toDouble(), + longitudeMeters: (json['longitudeMeters'] as num).toDouble(), + ); Map _$MapKitSnapshotterRegionToJson( MapKitSnapshotterRegion instance) => @@ -112,15 +73,14 @@ Map _$MapKitSnapshotterRegionToJson( }; MapKitSnapshotterImageProviderKey _$MapKitSnapshotterImageProviderKeyFromJson( - Map json) { - return MapKitSnapshotterImageProviderKey( - sizeHeight: (json['sizeHeight'] as num).toDouble(), - sizeWidth: (json['sizeWidth'] as num).toDouble(), - options: MapKitSnapshotterOptions.fromJson( - json['options'] as Map), - devicePixelRatio: (json['devicePixelRatio'] as num).toDouble(), - ); -} + Map json) => + MapKitSnapshotterImageProviderKey( + sizeHeight: (json['sizeHeight'] as num).toDouble(), + sizeWidth: (json['sizeWidth'] as num).toDouble(), + options: MapKitSnapshotterOptions.fromJson( + json['options'] as Map), + devicePixelRatio: (json['devicePixelRatio'] as num).toDouble(), + ); Map _$MapKitSnapshotterImageProviderKeyToJson( MapKitSnapshotterImageProviderKey instance) => diff --git a/pubspec.yaml b/pubspec.yaml index e681f4e..e41a499 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,20 +5,20 @@ homepage: https://github.com/AurityLab/mapkit_snapshotter_flutter issue_tracker: https://github.com/AurityLab/mapkit_snapshotter_flutter/issues environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=3.1.3 <4.0.0' flutter: ">=1.20.0" dependencies: flutter: sdk: flutter - json_annotation: ^4.0.0 + json_annotation: ^4.8.1 dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.11.0 - build_runner: ^1.11.5 - json_serializable: ^4.0.2 + build_runner: ^2.4.8 + json_serializable: ^6.7.1 + flutter_lints: ^3.0.1 flutter: plugin: diff --git a/test/mapkit_snapshotter_flutter_test.dart b/test/mapkit_snapshotter_flutter_test.dart index 8cc96b6..893799d 100644 --- a/test/mapkit_snapshotter_flutter_test.dart +++ b/test/mapkit_snapshotter_flutter_test.dart @@ -7,13 +7,21 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); setUp(() { - channel.setMockMethodCallHandler((MethodCall methodCall) async { - return '42'; - }); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler( + channel, + (message) async { + return 42; + }, + ); }); tearDown(() { - channel.setMockMethodCallHandler(null); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler( + channel, + null, + ); }); test('getPlatformVersion', () async {});