Commit c339e7be authored by zhouteng's avatar zhouteng

update image_picker and sample code

parent 16d152b9
...@@ -74,3 +74,6 @@ pubspec.lock ...@@ -74,3 +74,6 @@ pubspec.lock
.atom/ .atom/
.idea/ .idea/
.vscode/ .vscode/
.flutter-plugins-dependencies
.dart_tool
flutter_export_environment.sh
\ No newline at end of file
android.enableJetifier=true android.enableJetifier=true
android.useAndroidX=true android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
#
# NOTE: This podspec is NOT to be published. It is only used as a local source!
#
Pod::Spec.new do |s|
s.name = 'Flutter'
s.version = '1.0.0'
s.summary = 'High-performance, high-fidelity mobile apps.'
s.description = <<-DESC
Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS.
DESC
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 = '8.0'
s.vendored_frameworks = 'Flutter.framework'
end
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/zhouteng/Android/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/zhouteng/flutter-demos/ShareExtend/example"
export "FLUTTER_TARGET=/Users/zhouteng/flutter-demos/ShareExtend/example/lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_FRAMEWORK_DIR=/Users/zhouteng/Android/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "TRACK_WIDGET_CREATION=true"
# Uncomment this line to define a global platform for your project # Uncomment this line to define a global platform for your project
platform :ios, '9.0' # platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency. # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true' ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def parse_KV_file(file, separator='=') def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file) file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path if !File.exists? file_abs_path
return []; return [];
end end
pods_ary = [] generated_key_values = {}
skip_line_start_symbols = ["#", "/"] skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |line| File.foreach(file_abs_path) do |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator) plugin = line.split(pattern=separator)
if plugin.length == 2 if plugin.length == 2
podname = plugin[0].strip() podname = plugin[0].strip()
path = plugin[1].strip() path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path) podpath = File.expand_path("#{path}", file_abs_path)
pods_ary.push({:name => podname, :path => podpath}); generated_key_values[podname] = podpath
else else
puts "Invalid plugin specification: #{line}" puts "Invalid plugin specification: #{line}"
end end
} end
return pods_ary generated_key_values
end end
target 'Runner' do target 'Runner' do
use_frameworks! use_frameworks!
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock use_modular_headers!
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks') # Flutter Pod
system('mkdir -p .symlinks/plugins')
# Flutter Pods copied_flutter_dir = File.join(__dir__, 'Flutter')
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
if generated_xcode_build_settings.empty? copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
end # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
generated_xcode_build_settings.map { |p| # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
if p[:name] == 'FLUTTER_FRAMEWORK_DIR' # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
symlink = File.join('.symlinks', 'flutter')
File.symlink(File.dirname(p[:path]), symlink) generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end end
} generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'
# Plugin Pods # Plugin Pods
# 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')
plugin_pods = parse_KV_file('../.flutter-plugins') plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p| plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', p[:name]) symlink = File.join('.symlinks', 'plugins', name)
File.symlink(p[:path], symlink) File.symlink(path, symlink)
pod p[:name], :path => File.join(symlink, 'ios') pod name, :path => File.join(symlink, 'ios')
} end
end end
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true
post_install do |installer| post_install do |installer|
installer.pods_project.targets.each do |target| installer.pods_project.targets.each do |target|
target.build_configurations.each do |config| target.build_configurations.each do |config|
......
...@@ -273,26 +273,9 @@ ...@@ -273,26 +273,9 @@
files = ( files = (
); );
inputPaths = ( inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/BSGridCollectionViewLayout/BSGridCollectionViewLayout.framework",
"${BUILT_PRODUCTS_DIR}/BSImagePicker/BSImagePicker.framework",
"${BUILT_PRODUCTS_DIR}/BSImageView/BSImageView.framework",
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
"${BUILT_PRODUCTS_DIR}/image_picker/image_picker.framework",
"${BUILT_PRODUCTS_DIR}/multi_image_picker/multi_image_picker.framework",
"${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework",
"${BUILT_PRODUCTS_DIR}/share_extend/share_extend.framework",
); );
name = "[CP] Embed Pods Frameworks"; name = "[CP] Embed Pods Frameworks";
outputPaths = ( outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BSGridCollectionViewLayout.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BSImagePicker.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BSImageView.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/multi_image_picker.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/share_extend.framework",
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
......
import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:multi_image_picker/multi_image_picker.dart'; import 'package:multi_image_picker/multi_image_picker.dart';
import 'package:share_extend/share_extend.dart'; import 'package:share_extend/share_extend.dart';
...@@ -82,11 +84,22 @@ class _MyAppState extends State<MyApp> { ...@@ -82,11 +84,22 @@ class _MyAppState extends State<MyApp> {
List<Asset> assetList = await MultiImagePicker.pickImages(maxImages: 5); List<Asset> assetList = await MultiImagePicker.pickImages(maxImages: 5);
var imageList = List<String>(); var imageList = List<String>();
for (var asset in assetList) { for (var asset in assetList) {
imageList.add(await asset.filePath); String path =
await _writeByteToImageFile(await asset.getByteData(quality: 30));
imageList.add(path);
} }
ShareExtend.shareMultiple(imageList, "image"); ShareExtend.shareMultiple(imageList, "image");
} }
Future<String> _writeByteToImageFile(ByteData byteData) async {
Directory dir = await getApplicationDocumentsDirectory();
File imageFile = new File(
"${dir.path}/flutter/${DateTime.now().millisecondsSinceEpoch}.png");
imageFile.createSync(recursive: true);
imageFile.writeAsBytesSync(byteData.buffer.asUint8List(0));
return imageFile.path;
}
///share the documents file ///share the documents file
_shareApplicationDocumentsFile() async { _shareApplicationDocumentsFile() async {
Directory dir = await getApplicationDocumentsDirectory(); Directory dir = await getApplicationDocumentsDirectory();
......
...@@ -20,13 +20,13 @@ dependencies: ...@@ -20,13 +20,13 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2 cupertino_icons: ^0.1.2
path_provider: ^1.4.0 path_provider: ^1.4.0
multi_image_picker: ^4.5.9 multi_image_picker: ^4.6.1
# image_picker: ^0.6.1+10 image_picker: ^0.6.3
image_picker: # image_picker:
git: # git:
url: git@github.com:miguelpruivo/plugins.git # url: git@github.com:miguelpruivo/plugins.git
path: packages/image_picker # path: packages/image_picker
ref: image_picker-Fix-#41046 # ref: image_picker-Fix-#41046
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment