From c4e69464dfce172cb82d60ddd801a5e645f6afea Mon Sep 17 00:00:00 2001 From: MaksimilianY Date: Tue, 7 Jun 2022 20:05:26 +0400 Subject: [PATCH 1/3] migrated some code --- lib/data/media_file.dart | 39 ++++++++++++++++----------- lib/media_picker_builder.dart | 15 +++++------ pubspec.lock | 51 +++++++++++++++++------------------ pubspec.yaml | 5 ++-- 4 files changed, 57 insertions(+), 53 deletions(-) diff --git a/lib/data/media_file.dart b/lib/data/media_file.dart index 1143168..a915460 100755 --- a/lib/data/media_file.dart +++ b/lib/data/media_file.dart @@ -1,12 +1,15 @@ +import 'package:meta/meta.dart'; + +@immutable class MediaFile { /// Unique identifier for the file - String id; + final String id; /// Date added in seconds (unix timestamp) - int dateAdded; + final int? dateAdded; /// Original file path - String path; + final String? path; /// Thumbnails from android (NOT iOS) need to have their orientation fixed /// based on the returned [orientation] @@ -19,29 +22,33 @@ class MediaFile { /// fit: BoxFit.cover, /// ) /// Note: If thumbnail returned is null you will have to call [MediaPickerBuilder.getThumbnail] - String thumbnailPath; + final String? thumbnailPath; /// Orientation in degrees (i.e. 0, 90, 180, 270) - int orientation; + final int orientation; /// Video duration in milliseconds - int duration; + final int? duration; /// Supported on Android only - String mimeType; + final String? mimeType; /// On iOS, original file name is retrieved only if [loadIOSPath] is true - String fileName; + final String? fileName; - MediaType type; + final MediaType type; - MediaFile( - {this.id, - this.dateAdded, - this.path, - this.thumbnailPath, - this.orientation, - this.type}); + MediaFile({ + required this.id, + required this.orientation, + required this.type, + this.dateAdded, + this.path, + this.thumbnailPath, + this.duration, + this.fileName, + this.mimeType, + }); MediaFile.fromJson(Map json) : id = json['id'], diff --git a/lib/media_picker_builder.dart b/lib/media_picker_builder.dart index 7582039..a7113fd 100644 --- a/lib/media_picker_builder.dart +++ b/lib/media_picker_builder.dart @@ -8,8 +8,7 @@ import 'package:media_picker_builder/data/album.dart'; import 'package:media_picker_builder/data/media_file.dart'; class MediaPickerBuilder { - static const MethodChannel _channel = - const MethodChannel('media_picker_builder'); + static const MethodChannel _channel = const MethodChannel('media_picker_builder'); /// Gets list of albums and its content based on the required flags. /// This method will also return the thumbnails IF it was already generated. @@ -18,8 +17,8 @@ class MediaPickerBuilder { /// [loadIOSPaths] For iOS only, to optimize the speed of querying the files you can set this to false, /// but if you do that you will have to get the path & video duration after selection is done static Future> getAlbums({ - @required bool withImages, - @required bool withVideos, + required bool withImages, + required bool withVideos, bool loadIOSPaths = true, }) async { final String json = await _channel.invokeMethod( @@ -47,8 +46,8 @@ class MediaPickerBuilder { /// fit: BoxFit.cover, /// ) static Future getThumbnail({ - @required String fileId, - @required MediaType type, + required String fileId, + required MediaType type, }) async { final String path = await _channel.invokeMethod( 'getThumbnail', @@ -65,8 +64,8 @@ class MediaPickerBuilder { /// Android always returns the path & duration /// [loadThumbnail] Whether or not to generate a thumbnail static Future getMediaFile({ - @required String fileId, - @required MediaType type, + required String fileId, + required MediaType type, bool loadIOSPath = true, bool loadThumbnail = false, }) async { diff --git a/pubspec.lock b/pubspec.lock index 28884b6..f4c1e9c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,49 +7,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.8.2" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.3.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.16.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.3.0" flutter: dependency: "direct main" description: flutter @@ -66,21 +66,28 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" meta: dependency: "direct main" description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.7.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.1" sky_engine: dependency: transitive description: flutter @@ -92,56 +99,48 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" + version: "0.4.9" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.2" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" - flutter: ">=1.10.0 <2.0.0" + dart: ">=2.17.0-0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 91af9bb..3984b67 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,13 +4,12 @@ version: 1.3.2 homepage: https://github.com/KasemJaffer/media_picker_builder environment: - sdk: ">=2.1.0 <3.0.0" - flutter: ">=1.10.0 <2.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: sdk: flutter - meta: ^1.1.8 + meta: ^1.7.0 dev_dependencies: flutter_test: From 9104732b04d5158fe0eacccf8e7ae9b656f1fea4 Mon Sep 17 00:00:00 2001 From: MaksimilianY Date: Tue, 7 Jun 2022 20:53:18 +0400 Subject: [PATCH 2/3] migrated example --- example/.flutter-plugins-dependencies | 1 + example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Flutter/Flutter.podspec | 18 ++++ .../ios/Flutter/flutter_export_environment.sh | 14 +++ example/ios/Podfile | 64 +++-------- example/ios/Podfile.lock | 20 ++-- example/ios/Runner.xcodeproj/project.pbxproj | 27 +++-- .../contents.xcworkspacedata | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- example/ios/Runner/Info.plist | 2 + example/lib/main.dart | 17 ++- example/lib/picker/gallery_widget.dart | 2 +- example/lib/picker/gallery_widget_item.dart | 12 +-- example/lib/picker/picker_widget.dart | 42 ++++---- example/pubspec.lock | 102 ++++++++++++------ example/pubspec.yaml | 8 +- lib/data/album.dart | 10 +- lib/data/media_file.dart | 5 +- lib/media_picker_builder.dart | 1 - test/media_picker_builder_test.dart | 1 - 20 files changed, 197 insertions(+), 155 deletions(-) create mode 100644 example/.flutter-plugins-dependencies create mode 100644 example/ios/Flutter/Flutter.podspec create mode 100755 example/ios/Flutter/flutter_export_environment.sh diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies new file mode 100644 index 0000000..5ffecb8 --- /dev/null +++ b/example/.flutter-plugins-dependencies @@ -0,0 +1 @@ +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"media_picker_builder","path":"/Users/maksimilianyakovlev/work/media_picker_builder/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/Users/maksimilianyakovlev/Development/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler_apple-9.0.4/","native_build":true,"dependencies":[]}],"android":[{"name":"media_picker_builder","path":"/Users/maksimilianyakovlev/work/media_picker_builder/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/Users/maksimilianyakovlev/Development/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler_android-9.0.2+1/","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[{"name":"permission_handler_windows","path":"/Users/maksimilianyakovlev/Development/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler_windows-0.1.0/","native_build":true,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"media_picker_builder","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]}],"date_created":"2022-06-07 20:50:48.517134","version":"3.0.1"} \ No newline at end of file diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 9367d48..8d4492f 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 9.0 diff --git a/example/ios/Flutter/Flutter.podspec b/example/ios/Flutter/Flutter.podspec new file mode 100644 index 0000000..663d5b2 --- /dev/null +++ b/example/ios/Flutter/Flutter.podspec @@ -0,0 +1,18 @@ +# +# NOTE: This podspec is NOT to be published. It is only used as a local source! +# This is a generated file; do not edit or check into version control. +# + +Pod::Spec.new do |s| + s.name = 'Flutter' + s.version = '1.0.0' + s.summary = 'High-performance, high-fidelity mobile apps.' + s.homepage = 'https://flutter.io' + s.license = { :type => 'MIT' } + s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } + s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s } + s.ios.deployment_target = '9.0' + # Framework linking is handled by Flutter tooling, not CocoaPods. + # Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs. + s.vendored_frameworks = 'path/to/nothing' +end diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh new file mode 100755 index 0000000..524348d --- /dev/null +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=/Users/maksimilianyakovlev/Development/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/maksimilianyakovlev/work/media_picker_builder/example" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_TARGET=/Users/maksimilianyakovlev/work/media_picker_builder/example/lib/main.dart" +export "FLUTTER_BUILD_DIR=build" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=true" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=/Users/maksimilianyakovlev/work/media_picker_builder/example/.dart_tool/package_config.json" diff --git a/example/ios/Podfile b/example/ios/Podfile index 64eddc6..1e8c3c9 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -10,62 +10,32 @@ project 'Runner', { 'Release' => :release, } -def parse_KV_file(file, separator='=') - file_abs_path = File.expand_path(file) - if !File.exists? file_abs_path - return []; +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" end - pods_ary = [] - skip_line_start_symbols = ["#", "/"] - File.foreach(file_abs_path) { |line| - next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } - plugin = line.split(pattern=separator) - if plugin.length == 2 - podname = plugin[0].strip() - path = plugin[1].strip() - podpath = File.expand_path("#{path}", file_abs_path) - pods_ary.push({:name => podname, :path => podpath}); - else - puts "Invalid plugin specification: #{line}" - end - } - return pods_ary + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" end -target 'Runner' do - use_frameworks! +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock - # referring to absolute paths on developers' machines. - system('rm -rf .symlinks') - system('mkdir -p .symlinks/plugins') +flutter_ios_podfile_setup - # Flutter Pods - generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') - if generated_xcode_build_settings.empty? - puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." - end - generated_xcode_build_settings.map { |p| - if p[:name] == 'FLUTTER_FRAMEWORK_DIR' - symlink = File.join('.symlinks', 'flutter') - File.symlink(File.dirname(p[:path]), symlink) - pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) - end - } +target 'Runner' do + use_frameworks! + use_modular_headers! - # Plugin Pods - plugin_pods = parse_KV_file('../.flutter-plugins') - plugin_pods.map { |p| - symlink = File.join('.symlinks', 'plugins', p[:name]) - File.symlink(p[:path], symlink) - pod p[:name], :path => File.join(symlink, 'ios') - } + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) end post_install do |installer| installer.pods_project.targets.each do |target| - target.build_configurations.each do |config| - config.build_settings['ENABLE_BITCODE'] = 'NO' - end + flutter_additional_ios_build_settings(target) end end diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index c095f47..23f4532 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -2,27 +2,27 @@ PODS: - Flutter (1.0.0) - media_picker_builder (0.0.1): - Flutter - - permission_handler (3.1.0): + - permission_handler_apple (9.0.4): - Flutter DEPENDENCIES: - - Flutter (from `.symlinks/flutter/ios`) + - Flutter (from `Flutter`) - media_picker_builder (from `.symlinks/plugins/media_picker_builder/ios`) - - permission_handler (from `.symlinks/plugins/permission_handler/ios`) + - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) EXTERNAL SOURCES: Flutter: - :path: ".symlinks/flutter/ios" + :path: Flutter media_picker_builder: :path: ".symlinks/plugins/media_picker_builder/ios" - permission_handler: - :path: ".symlinks/plugins/permission_handler/ios" + permission_handler_apple: + :path: ".symlinks/plugins/permission_handler_apple/ios" SPEC CHECKSUMS: - Flutter: 0e3d915762c693b495b44d77113d4970485de6ec + Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a media_picker_builder: fac2646d747c8058a4f049190f1b349f2c74dc41 - permission_handler: fa6b0d784b1a43cb96b468a5b8365cb130b1956a + permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce -PODFILE CHECKSUM: ebd43b443038e611b86ede96e613bd6033c49497 +PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c -COCOAPODS: 1.9.1 +COCOAPODS: 1.11.3 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 90afb02..c07fb0d 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 = 50; objects = { /* Begin PBXBuildFile section */ @@ -164,7 +164,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0910; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -228,12 +228,10 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", "${BUILT_PRODUCTS_DIR}/media_picker_builder/media_picker_builder.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/media_picker_builder.framework", ); runOnlyForDeploymentPostprocessing = 0; @@ -350,7 +348,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -371,7 +369,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -428,7 +429,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -475,7 +476,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; @@ -497,7 +498,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -525,7 +529,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", 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 786d6aa..f156018 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 + diff --git a/example/lib/main.dart b/example/lib/main.dart index d818437..f049363 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:media_picker_builder/data/media_file.dart'; -import 'package:media_picker_builder/media_picker_builder.dart'; import 'package:media_picker_builder_example/picker/picker_widget.dart'; import 'package:permission_handler/permission_handler.dart'; @@ -25,11 +24,11 @@ class _MyAppState extends State { title: const Text('Picker Demo'), ), body: Center( - child: RaisedButton( + child: ElevatedButton( child: const Text("Albums"), onPressed: () { _checkPermission().then((granted) { - if (!granted) return; + //if (!granted) return; // To build your own custom picker use this api // MediaPickerBuilder.getAlbums( @@ -49,9 +48,9 @@ class _MyAppState extends State { ); } - _buildPicker() { + Future _buildPicker() async { showModalBottomSheet>( - context: navigatorKey.currentState.overlay.context, + context: navigatorKey.currentState!.overlay!.context, builder: (BuildContext context) { return PickerWidget( withImages: true, @@ -70,12 +69,10 @@ class _MyAppState extends State { } Future _checkPermission() async { - final permissionStorageGroup = - Platform.isIOS ? PermissionGroup.photos : PermissionGroup.storage; - Map res = - await PermissionHandler().requestPermissions([ + final permissionStorageGroup = Platform.isIOS ? Permission.photos : Permission.storage; + Map res = await [ permissionStorageGroup, - ]); + ].request(); return res[permissionStorageGroup] == PermissionStatus.granted; } } diff --git a/example/lib/picker/gallery_widget.dart b/example/lib/picker/gallery_widget.dart index 28bd044..cdb605f 100644 --- a/example/lib/picker/gallery_widget.dart +++ b/example/lib/picker/gallery_widget.dart @@ -6,7 +6,7 @@ import 'gallery_widget_item.dart'; class GalleryWidget extends StatefulWidget { final List mediaFiles; - GalleryWidget({@required this.mediaFiles}); + GalleryWidget({required this.mediaFiles}); @override State createState() => GalleryWidgetState(); diff --git a/example/lib/picker/gallery_widget_item.dart b/example/lib/picker/gallery_widget_item.dart index 50c0015..c4b2f55 100644 --- a/example/lib/picker/gallery_widget_item.dart +++ b/example/lib/picker/gallery_widget_item.dart @@ -10,7 +10,7 @@ import 'multi_selector_model.dart'; class GalleryWidgetItem extends StatefulWidget { final MediaFile mediaFile; - GalleryWidgetItem({this.mediaFile}); + GalleryWidgetItem({required this.mediaFile}); @override State createState() => GalleryWidgetItemState(); @@ -63,10 +63,9 @@ class GalleryWidgetItemState extends State { ? RotatedBox( quarterTurns: Platform.isIOS ? 0 - : MediaPickerBuilder.orientationToQuarterTurns( - widget.mediaFile.orientation), + : MediaPickerBuilder.orientationToQuarterTurns(widget.mediaFile.orientation), child: Image.file( - File(widget.mediaFile.thumbnailPath), + File(widget.mediaFile.thumbnailPath!), fit: BoxFit.cover, ), ) @@ -75,8 +74,7 @@ class GalleryWidgetItemState extends State { fileId: widget.mediaFile.id, type: widget.mediaFile.type, ), - builder: - (BuildContext context, AsyncSnapshot snapshot) { + builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData) { var thumbnail = snapshot.data; widget.mediaFile.thumbnailPath = thumbnail; @@ -86,7 +84,7 @@ class GalleryWidgetItemState extends State { : MediaPickerBuilder.orientationToQuarterTurns( widget.mediaFile.orientation), child: Image.file( - File(thumbnail), + File(thumbnail!), fit: BoxFit.cover, ), ); diff --git a/example/lib/picker/picker_widget.dart b/example/lib/picker/picker_widget.dart index 3ed7cc6..b001e56 100644 --- a/example/lib/picker/picker_widget.dart +++ b/example/lib/picker/picker_widget.dart @@ -10,22 +10,23 @@ import 'multi_selector_model.dart'; class PickerWidget extends StatefulWidget { final bool withImages; final bool withVideos; - final Function(Set selectedFiles) onDone; - final Function() onCancel; + final void Function(Set selectedFiles) onDone; + final void Function() onCancel; - PickerWidget( - {@required this.withImages, - @required this.withVideos, - @required this.onDone, - @required this.onCancel}); + PickerWidget({ + required this.withImages, + required this.withVideos, + required this.onDone, + required this.onCancel, + }); @override State createState() => PickerWidgetState(); } class PickerWidgetState extends State { - List _albums; - Album _selectedAlbum; + late List _albums; + late Album _selectedAlbum; bool _loading = true; MultiSelectorModel _selector = MultiSelectorModel(); @@ -49,20 +50,19 @@ class PickerWidgetState extends State { @override Widget build(BuildContext context) { - return _loading - ? Center(child: CircularProgressIndicator()) - : _buildWidget(); + return _loading ? Center(child: CircularProgressIndicator()) : _buildWidget(); } _buildWidget() { - if (_albums.isEmpty) - return Center(child: Text("You have no folders to select from")); + if (_albums.isEmpty) return Center(child: Text("You have no folders to select from")); final dropDownAlbumsWidget = DropdownButton( value: _selectedAlbum, - onChanged: (Album newValue) { + onChanged: (Album? newValue) { setState(() { - _selectedAlbum = newValue; + if (newValue != null) { + _selectedAlbum = newValue; + } }); }, items: _albums.map>((Album album) { @@ -80,7 +80,7 @@ class PickerWidgetState extends State { ); return ChangeNotifierProvider( - builder: (context) => _selector, + create: (context) => _selector, child: Container( height: double.infinity, color: Colors.white, @@ -92,9 +92,7 @@ class PickerWidgetState extends State { children: [ SizedBox( width: 50, - child: FlatButton( - padding: EdgeInsets.all(0), - textColor: Colors.blue, + child: TextButton( onPressed: () => widget.onCancel(), child: Text("Cancel"), ), @@ -104,9 +102,7 @@ class PickerWidgetState extends State { builder: (context, selector, child) { return ConstrainedBox( constraints: BoxConstraints(maxWidth: 60), - child: FlatButton( - padding: EdgeInsets.all(0), - textColor: Colors.blue, + child: TextButton( onPressed: () => widget.onDone(_selector.selectedItems), child: Text( "Done (${selector.selectedItems.length})", diff --git a/example/pubspec.lock b/example/pubspec.lock index 0b44f37..ee078ef 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,56 +7,56 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.8.2" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.3.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "1.0.5" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.3.0" flutter: dependency: "direct main" description: flutter @@ -73,42 +73,91 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" media_picker_builder: dependency: "direct dev" description: path: ".." relative: true source: path - version: "1.2.5" + version: "1.3.2" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.7.0" + nested: + dependency: transitive + description: + name: nested + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.1" permission_handler: dependency: "direct main" description: name: permission_handler url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "9.2.0" + permission_handler_android: + dependency: transitive + description: + name: permission_handler_android + url: "https://pub.dartlang.org" + source: hosted + version: "9.0.2+1" + permission_handler_apple: + dependency: transitive + description: + name: permission_handler_apple + url: "https://pub.dartlang.org" + source: hosted + version: "9.0.4" + permission_handler_platform_interface: + dependency: transitive + description: + name: permission_handler_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "3.7.0" + permission_handler_windows: + dependency: transitive + description: + name: permission_handler_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "3.0.0+1" + version: "6.0.3" sky_engine: dependency: transitive description: flutter @@ -120,56 +169,49 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" + version: "0.4.9" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.2" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" - flutter: ">=1.10.0 <2.0.0" + dart: ">=2.17.0-0 <3.0.0" + flutter: ">=2.8.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index f171f6d..d1e21b9 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: 'none' version: 1.0.0+1 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: @@ -13,9 +13,9 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.2 - permission_handler: 3.1.0 - provider: 3.0.0+1 + cupertino_icons: ^1.0.5 + permission_handler: ^9.2.0 + provider: ^6.0.3 dev_dependencies: flutter_test: diff --git a/lib/data/album.dart b/lib/data/album.dart index 4fb82b5..efe7514 100755 --- a/lib/data/album.dart +++ b/lib/data/album.dart @@ -6,14 +6,16 @@ class Album { final String name; final List files; - Album({this.id, this.name, this.files}); + Album({ + required this.id, + required this.name, + required this.files, + }); Album.fromJson(Map json) : id = json['id'], name = json['name'], - files = json['files'] - .map((json) => MediaFile.fromJson(json)) - .toList(); + files = json['files'].map((json) => MediaFile.fromJson(json)).toList(); @override bool operator ==(Object other) => diff --git a/lib/data/media_file.dart b/lib/data/media_file.dart index a915460..aec56b3 100755 --- a/lib/data/media_file.dart +++ b/lib/data/media_file.dart @@ -1,6 +1,3 @@ -import 'package:meta/meta.dart'; - -@immutable class MediaFile { /// Unique identifier for the file final String id; @@ -22,7 +19,7 @@ class MediaFile { /// fit: BoxFit.cover, /// ) /// Note: If thumbnail returned is null you will have to call [MediaPickerBuilder.getThumbnail] - final String? thumbnailPath; + String? thumbnailPath; /// Orientation in degrees (i.e. 0, 90, 180, 270) final int orientation; diff --git a/lib/media_picker_builder.dart b/lib/media_picker_builder.dart index a7113fd..08afd51 100644 --- a/lib/media_picker_builder.dart +++ b/lib/media_picker_builder.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:convert'; import 'package:flutter/services.dart'; -import 'package:meta/meta.dart'; import 'package:media_picker_builder/data/album.dart'; import 'package:media_picker_builder/data/media_file.dart'; diff --git a/test/media_picker_builder_test.dart b/test/media_picker_builder_test.dart index 1a425ab..5a2ad6d 100644 --- a/test/media_picker_builder_test.dart +++ b/test/media_picker_builder_test.dart @@ -1,6 +1,5 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:media_picker_builder/media_picker_builder.dart'; void main() { const MethodChannel channel = MethodChannel('media_picker_builder'); From b6aabc85494a40b81f670d250fb70e9fee969be1 Mon Sep 17 00:00:00 2001 From: MaksimilianY Date: Tue, 7 Jun 2022 21:59:06 +0400 Subject: [PATCH 3/3] updated to new android --- .metadata | 27 +++- android/.gitignore | 1 + android/.idea/codeStyles/Project.xml | 116 ------------------ android/.idea/encodings.xml | 4 - android/.idea/gradle.xml | 11 -- android/.idea/misc.xml | 14 --- android/.idea/modules.xml | 8 -- android/.idea/runConfigurations.xml | 12 -- android/.idea/vcs.xml | 6 - android/build.gradle | 24 ++-- android/gradle.properties | 1 - .../com/kasem/media_picker_builder/Album.kt | 0 .../kasem/media_picker_builder/FileFetcher.kt | 0 .../kasem/media_picker_builder/MediaFile.kt | 0 example/.flutter-plugins-dependencies | 2 +- example/android/.gitignore | 13 ++ example/android/app/build.gradle | 26 ++-- .../android/app/src/debug/AndroidManifest.xml | 3 +- .../android/app/src/main/AndroidManifest.xml | 34 ++--- .../MainActivity.kt | 9 +- .../res/drawable-v21/launch_background.xml | 12 ++ .../app/src/main/res/values-night/styles.xml | 18 +++ .../app/src/main/res/values/styles.xml | 14 ++- .../app/src/profile/AndroidManifest.xml | 3 +- example/android/build.gradle | 8 +- example/android/gradle.properties | 2 + .../gradle/wrapper/gradle-wrapper.properties | 4 +- example/android/settings.gradle | 18 ++- example/ios/.gitignore | 34 +++++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++ .../xcshareddata/WorkspaceSettings.xcsettings | 8 ++ .../xcshareddata/WorkspaceSettings.xcsettings | 8 ++ example/lib/main.dart | 21 +--- example/test/widget_test.dart | 26 ++++ 34 files changed, 237 insertions(+), 258 deletions(-) delete mode 100644 android/.idea/codeStyles/Project.xml delete mode 100644 android/.idea/encodings.xml delete mode 100644 android/.idea/gradle.xml delete mode 100644 android/.idea/misc.xml delete mode 100644 android/.idea/modules.xml delete mode 100644 android/.idea/runConfigurations.xml delete mode 100644 android/.idea/vcs.xml delete mode 100644 android/gradle.properties mode change 100755 => 100644 android/src/main/kotlin/com/kasem/media_picker_builder/Album.kt mode change 100755 => 100644 android/src/main/kotlin/com/kasem/media_picker_builder/FileFetcher.kt mode change 100755 => 100644 android/src/main/kotlin/com/kasem/media_picker_builder/MediaFile.kt create mode 100644 example/android/.gitignore create mode 100644 example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 example/android/app/src/main/res/values-night/styles.xml create mode 100644 example/ios/.gitignore create mode 100644 example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 example/test/widget_test.dart diff --git a/.metadata b/.metadata index faf287a..621c10a 100644 --- a/.metadata +++ b/.metadata @@ -1,10 +1,33 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled and should not be manually edited. +# This file should be version controlled. version: - revision: 7a4c33425ddd78c54aba07d86f3f9a4a0051769b + revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 channel: stable project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + - platform: android + create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + - platform: ios + create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/android/.gitignore b/android/.gitignore index c6cbe56..161bdcd 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -6,3 +6,4 @@ .DS_Store /build /captures +.cxx diff --git a/android/.idea/codeStyles/Project.xml b/android/.idea/codeStyles/Project.xml deleted file mode 100644 index 681f41a..0000000 --- a/android/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - -
- - - - xmlns:android - - ^$ - - - -
-
- - - - xmlns:.* - - ^$ - - - BY_NAME - -
-
- - - - .*:id - - http://schemas.android.com/apk/res/android - - - -
-
- - - - .*:name - - http://schemas.android.com/apk/res/android - - - -
-
- - - - name - - ^$ - - - -
-
- - - - style - - ^$ - - - -
-
- - - - .* - - ^$ - - - BY_NAME - -
-
- - - - .* - - http://schemas.android.com/apk/res/android - - - ANDROID_ATTRIBUTE_ORDER - -
-
- - - - .* - - .* - - - BY_NAME - -
-
-
-
-
-
\ No newline at end of file diff --git a/android/.idea/encodings.xml b/android/.idea/encodings.xml deleted file mode 100644 index 15a15b2..0000000 --- a/android/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/android/.idea/gradle.xml b/android/.idea/gradle.xml deleted file mode 100644 index cc04d0a..0000000 --- a/android/.idea/gradle.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/android/.idea/misc.xml b/android/.idea/misc.xml deleted file mode 100644 index c72ad17..0000000 --- a/android/.idea/misc.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/android/.idea/modules.xml b/android/.idea/modules.xml deleted file mode 100644 index e54e28e..0000000 --- a/android/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/android/.idea/runConfigurations.xml b/android/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/android/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/android/.idea/vcs.xml b/android/.idea/vcs.xml deleted file mode 100644 index 6c0b863..0000000 --- a/android/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 49082db..02095b2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,14 +2,14 @@ group 'com.kasem.media_picker_builder' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.3.41' + ext.kotlin_version = '1.6.10' repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.4.2' + classpath 'com.android.tools.build:gradle:7.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -17,7 +17,7 @@ buildscript { rootProject.allprojects { repositories { google() - jcenter() + mavenCentral() } } @@ -25,17 +25,23 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 29 + compileSdkVersion 31 + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } sourceSets { main.java.srcDirs += 'src/main/kotlin' } + defaultConfig { minSdkVersion 16 - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } - lintOptions { - disable 'InvalidPackage' } } diff --git a/android/gradle.properties b/android/gradle.properties deleted file mode 100644 index 8bd86f6..0000000 --- a/android/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -org.gradle.jvmargs=-Xmx1536M diff --git a/android/src/main/kotlin/com/kasem/media_picker_builder/Album.kt b/android/src/main/kotlin/com/kasem/media_picker_builder/Album.kt old mode 100755 new mode 100644 diff --git a/android/src/main/kotlin/com/kasem/media_picker_builder/FileFetcher.kt b/android/src/main/kotlin/com/kasem/media_picker_builder/FileFetcher.kt old mode 100755 new mode 100644 diff --git a/android/src/main/kotlin/com/kasem/media_picker_builder/MediaFile.kt b/android/src/main/kotlin/com/kasem/media_picker_builder/MediaFile.kt old mode 100755 new mode 100644 diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index 5ffecb8..8151107 100644 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"media_picker_builder","path":"/Users/maksimilianyakovlev/work/media_picker_builder/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/Users/maksimilianyakovlev/Development/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler_apple-9.0.4/","native_build":true,"dependencies":[]}],"android":[{"name":"media_picker_builder","path":"/Users/maksimilianyakovlev/work/media_picker_builder/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/Users/maksimilianyakovlev/Development/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler_android-9.0.2+1/","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[{"name":"permission_handler_windows","path":"/Users/maksimilianyakovlev/Development/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler_windows-0.1.0/","native_build":true,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"media_picker_builder","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]}],"date_created":"2022-06-07 20:50:48.517134","version":"3.0.1"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"media_picker_builder","path":"/Users/maksimilianyakovlev/work/media_picker_builder/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/Users/maksimilianyakovlev/Development/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler_apple-9.0.4/","native_build":true,"dependencies":[]}],"android":[{"name":"media_picker_builder","path":"/Users/maksimilianyakovlev/work/media_picker_builder/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/Users/maksimilianyakovlev/Development/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler_android-9.0.2+1/","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[{"name":"permission_handler_windows","path":"/Users/maksimilianyakovlev/Development/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler_windows-0.1.0/","native_build":true,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"media_picker_builder","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]}],"date_created":"2022-06-07 21:57:59.186265","version":"3.0.1"} \ No newline at end of file diff --git a/example/android/.gitignore b/example/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 4ce6c63..9d3470e 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,24 +26,31 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' } - lintOptions { - disable 'InvalidPackage' + sourceSets { + main.java.srcDirs += 'src/main/kotlin' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.kasem.media_picker_builder_example" - minSdkVersion 16 - targetSdkVersion 28 + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { @@ -61,7 +68,4 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' } diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml index ef2a1b0..25029d1 100644 --- a/example/android/app/src/debug/AndroidManifest.xml +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -1,6 +1,7 @@ - diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index ef443ae..b223969 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,35 +1,37 @@ + - - - - + - + + android:name="io.flutter.embedding.android.NormalTheme" + android:resource="@style/NormalTheme" + /> + + diff --git a/example/android/app/src/main/kotlin/com/kasem/media_picker_builder_example/MainActivity.kt b/example/android/app/src/main/kotlin/com/kasem/media_picker_builder_example/MainActivity.kt index 4253bf6..bf06c18 100644 --- a/example/android/app/src/main/kotlin/com/kasem/media_picker_builder_example/MainActivity.kt +++ b/example/android/app/src/main/kotlin/com/kasem/media_picker_builder_example/MainActivity.kt @@ -1,13 +1,6 @@ package com.kasem.media_picker_builder_example -import android.os.Bundle - -import io.flutter.app.FlutterActivity -import io.flutter.plugins.GeneratedPluginRegistrant +import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - GeneratedPluginRegistrant.registerWith(this) - } } diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml index 00fa441..cb1ef88 100644 --- a/example/android/app/src/main/res/values/styles.xml +++ b/example/android/app/src/main/res/values/styles.xml @@ -1,8 +1,18 @@ - + + diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml index ef2a1b0..25029d1 100644 --- a/example/android/app/src/profile/AndroidManifest.xml +++ b/example/android/app/src/profile/AndroidManifest.xml @@ -1,6 +1,7 @@ - diff --git a/example/android/build.gradle b/example/android/build.gradle index ed49c23..83ae220 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.3.40' + ext.kotlin_version = '1.6.10' repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.4.2' + classpath 'com.android.tools.build:gradle:7.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -14,7 +14,7 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 8bd86f6..94adc3a 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1 +1,3 @@ org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index c6ba17f..cc5527d 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Jul 02 12:00:37 PDT 2019 +#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 5a2f14f..44e62bc 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,15 +1,11 @@ include ':app' -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } -} +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory -} +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/example/ios/.gitignore b/example/ios/.gitignore new file mode 100644 index 0000000..7a7f987 --- /dev/null +++ b/example/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/example/lib/main.dart b/example/lib/main.dart index f049363..8cbf5a8 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,9 +1,6 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:media_picker_builder/data/media_file.dart'; import 'package:media_picker_builder_example/picker/picker_widget.dart'; -import 'package:permission_handler/permission_handler.dart'; void main() => runApp(MyApp()); @@ -27,10 +24,7 @@ class _MyAppState extends State { child: ElevatedButton( child: const Text("Albums"), onPressed: () { - _checkPermission().then((granted) { - //if (!granted) return; - - // To build your own custom picker use this api + // To build your own custom picker use this api // MediaPickerBuilder.getAlbums( // withImages: true, // withVideos: true, @@ -38,9 +32,8 @@ class _MyAppState extends State { // print(albums); // }); - // If you are happy with the example picker then you use this! - _buildPicker(); - }); + // If you are happy with the example picker then you use this! + _buildPicker(); }, ), ), @@ -67,12 +60,4 @@ class _MyAppState extends State { }, ); } - - Future _checkPermission() async { - final permissionStorageGroup = Platform.isIOS ? Permission.photos : Permission.storage; - Map res = await [ - permissionStorageGroup, - ].request(); - return res[permissionStorageGroup] == PermissionStatus.granted; - } } diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart new file mode 100644 index 0000000..2fe433d --- /dev/null +++ b/example/test/widget_test.dart @@ -0,0 +1,26 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:media_picker_builder_example/main.dart'; + +void main() { + testWidgets('Verify Platform version', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(MyApp()); + + // Verify that platform version is retrieved. + expect( + find.byWidgetPredicate( + (Widget widget) => widget is Text && widget.data!.startsWith('Running on:'), + ), + findsOneWidget, + ); + }); +}