Repository: lykhonis/image_crop
Branch: master
Commit: 5809167dd7fa
Files: 61
Total size: 128.0 KB
Directory structure:
gitextract_s2uz68ra/
├── .github/
│ └── FUNDING.yml
├── .gitignore
├── .vscode/
│ └── launch.json
├── CHANGELOG.md
├── LICENSE
├── README.md
├── RELEASE.md
├── android/
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle/
│ │ └── wrapper/
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradle.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── settings.gradle
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ └── java/
│ └── com/
│ └── lykhonis/
│ └── imagecrop/
│ └── ImageCropPlugin.java
├── example/
│ ├── .gitignore
│ ├── README.md
│ ├── android/
│ │ ├── app/
│ │ │ ├── build.gradle
│ │ │ └── src/
│ │ │ └── main/
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── lykhonis/
│ │ │ │ └── imagecropexample/
│ │ │ │ └── MainActivity.java
│ │ │ └── res/
│ │ │ ├── drawable/
│ │ │ │ └── launch_background.xml
│ │ │ └── values/
│ │ │ └── styles.xml
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ └── settings.gradle
│ ├── ios/
│ │ ├── Flutter/
│ │ │ ├── .last_build_id
│ │ │ ├── AppFrameworkInfo.plist
│ │ │ ├── Debug.xcconfig
│ │ │ ├── Flutter.podspec
│ │ │ └── Release.xcconfig
│ │ ├── Podfile
│ │ ├── Runner/
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── LaunchImage.imageset/
│ │ │ │ ├── Contents.json
│ │ │ │ └── README.md
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Info.plist
│ │ │ └── main.m
│ │ ├── Runner.xcodeproj/
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace/
│ │ │ │ └── contents.xcworkspacedata.xml
│ │ │ └── xcshareddata/
│ │ │ └── xcschemes/
│ │ │ └── Runner.xcscheme.xml
│ │ └── Runner.xcworkspace/
│ │ ├── contents.xcworkspacedata
│ │ ├── contents.xcworkspacedata.xml
│ │ └── xcshareddata/
│ │ ├── IDEWorkspaceChecks.plist
│ │ └── WorkspaceSettings.xcsettings.xml
│ ├── lib/
│ │ └── main.dart
│ └── pubspec.yaml
├── ios/
│ ├── .gitignore
│ ├── Assets/
│ │ └── .gitkeep
│ ├── Classes/
│ │ ├── ImageCropPlugin.h
│ │ └── ImageCropPlugin.m
│ └── image_crop.podspec
├── lib/
│ ├── image_crop.dart
│ └── src/
│ ├── crop.dart
│ └── image_crop.dart
└── pubspec.yaml
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms
github: VolodymyrLykhonis
================================================
FILE: .gitignore
================================================
.DS_Store
.dart_tool/
.packages
.pub/
pubspec.lock
.idea/
*.iml
build/
example/.flutter-plugins-dependencies
example/ios/Flutter/flutter_export_environment.sh
================================================
FILE: .vscode/launch.json
================================================
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Example",
"request": "launch",
"type": "dart",
"program": "${workspaceFolder}/example/lib/main.dart"
}
]
}
================================================
FILE: CHANGELOG.md
================================================
## 0.4.1
Community Contributions. Thank you!
* Dart 2.17 #89 (#91)
* Fixed a few typos (#87)
* Resolve #40 (#81)
## 0.4.0
* adds null safety
## 0.3.4
* fixes several issues related to scaling and multi-touch support
## 0.3.3
* migrate to the new Android APIs based on FlutterPlugin
## 0.3.2
* Fixes #33. Image rotation bug after cropping on iOS
* Flutter upgrade v1.13.5
## 0.3.1
* Fixes #19. Painting of the image is independent of top/left handles
* Visual correction of a grid. It was tilted by 1 point
## 0.3.0
* Android gradle upgrade to 3.4.1. Gradle 5.1.1
* Flutter upgrade 1.6.6
* Android target SDK 28
## 0.2.1
* Read exif information to provide proper width/height according to the orientation
* Rotate image prior cropping as needed per exif information
## 0.2.0
* Fit sampled images to specified maximum width/height on both iOS and Android
* Preserve exif information on Android when crop/sample image
* Updated example to illustrate higher quality cropped image production
## 0.1.3
* New widget options: Maximum scale, always show grid
* Adjusted scale to reflect original image size. If image scaled and fits in cropped area, scale is 1x
* Calculate sample size against large side of image to match smaller to preferred width/height
* Bug: ensure to display image on first frame
* Optimization: do not resample if image is smaller than preferred width/height
## 0.1.2
* Limit image to a crop area instead of view boundaries
* Don't adjust a size during scale to avoid misalignment
* After editing snap image back to a crop area. Auto scale if needed
## 0.1.1
* Fixed an exception when aspect ratio is not supplied
* Updated README with more information and screenshots
## 0.1.0
* Tools to resample by a factor, crop, and get options of images
* Display image provider
* Scale and crop image via widget
* Optional aspect ratio of crop area
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2018 Volodymyr Lykhonis
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
# Image Cropping plugin for Flutter
A flutter plugin to crop image on iOS and Android.

The plugin comes with a `Crop` widget. The widget renders only image, overlay, and handles to crop an image. Thus it can be composed with other widgets to build custom image cropping experience.
The plugin is working with files to avoid passing large amount of data through method channels. Files are stored in cache folders of iOS and Android. Thus if there is a need to save actual cropped image, ensure to copy the file to other location.
All of the computation intensive work is done off a main thread via dispatch queues on iOS and cache thread pool on Android.
*Note*: This plugin is still under development, some features are not available yet and testing has been limited.
## Installation
Add `image_crop` [](https://pub.dartlang.org/packages/image_crop) as [a dependency in `pubspec.yaml`](https://flutter.io/using-packages/#managing-package-dependencies--versions).
## Using
Create a widget to load and edit an image:
```dart
final cropKey = GlobalKey<CropState>();
Widget _buildCropImage() {
return Container(
color: Colors.black,
padding: const EdgeInsets.all(20.0),
child: Crop(
key: cropKey,
image: Image.file(imageFile),
aspectRatio: 4.0 / 3.0,
),
);
}
```
Access cropping values:
- scale is a factor to proportionally scale image's width and height when cropped. `1.0` is no scale needed.
- area is a rectangle indicating fractional positions on the image to crop from.
```dart
final crop = cropKey.currentState;
// or
// final crop = Crop.of(context);
final scale = crop.scale;
final area = crop.area;
if (area == null) {
// cannot crop, widget is not setup
// ...
}
```
Accessing and working with images. As a convenience function to request permissions to access photos.
```dart
final permissionsGranted = await ImageCrop.requestPermissions();
```
Read image options, such as: width and height. This is efficient implementation that does not decode nor load actual image into a memory.
```dart
final options = await getImageOptions(file: file);
debugPrint('image width: ${options.width}, height: ${options.height}');
```
If a large image is to be loaded into the memory, there is a sampling function that relies on a native platform to proportionally scale down the image before loading it to the memory. e.g. resample image to get down to `1024x4096` dimension as close as possible. If it is a square `preferredSize` can be used to specify both width and height. Prefer to leverage this functionality when displaying images in UI.
```dart
final sampleFile = await ImageCrop.sampleImage(
file: originalFile,
preferredWidth: 1024,
preferredHeight: 4096,
);
```
Once `Crop` widget is ready, there is a native support of cropping and scaling an image. In order to produce higher quality cropped image, rely on sampling image with preferred maximum width and height. Scale up a resolution of the sampled image. When cropped, the image is in higher resolution. Example is illustrated below:
```dart
final sampledFile = await ImageCrop.sampleImage(
file: originalFile,
preferredWidth: (1024 / crop.scale).round(),
preferredHeight: (4096 / crop.scale).round(),
);
final croppedFile = await ImageCrop.cropImage(
file: sampledFile,
area: crop.area,
);
```
================================================
FILE: RELEASE.md
================================================
## Prepare for Release
Version format is `v{major}.{minor}.{patch}`. e.g. `v0.1.1`.
1. Do `flutter analyze`. Ensure no issues found!
2. Do `flutter format lib/`. Format all dart code.
3. Update `pubsec.yaml` with new version.
4. Update `CHANGELOG.md` with new version and add details describing what's new and/or changed.
5. Do `flutter packages pub publish --dry-run`. Check to ensure there are no warnings!
6. Do `git commit -am "{version}"`.
7. Do `git tag {version}`.
8. Do `flutter packages pub publish` to publish new version.
9. Push changes `git push && git push --tags`
================================================
FILE: android/.gitignore
================================================
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
================================================
FILE: android/build.gradle
================================================
group 'com.lykhonis.imagecrop'
version '1.0-SNAPSHOT'
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
}
rootProject.allprojects {
repositories {
google()
jcenter()
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
}
dependencies {
implementation 'androidx.exifinterface:exifinterface:1.0.0'
}
================================================
FILE: android/gradle/wrapper/gradle-wrapper.properties
================================================
#Sat Jun 01 05:18:58 PDT 2019
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
================================================
FILE: android/gradle.properties
================================================
org.gradle.jvmargs=-Xmx1536M
================================================
FILE: android/gradlew
================================================
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
================================================
FILE: android/gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: android/settings.gradle
================================================
rootProject.name = 'image_crop'
================================================
FILE: android/src/main/AndroidManifest.xml
================================================
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lykhonis.imagecrop">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>
================================================
FILE: android/src/main/java/com/lykhonis/imagecrop/ImageCropPlugin.java
================================================
package com.lykhonis.imagecrop;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import androidx.annotation.NonNull;
import androidx.exifinterface.media.ExifInterface;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.Registrar;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
public final class ImageCropPlugin implements FlutterPlugin , ActivityAware, MethodCallHandler, PluginRegistry.RequestPermissionsResultListener {
private static final int PERMISSION_REQUEST_CODE = 13094;
private MethodChannel channel;
private ActivityPluginBinding binding;
private Activity activity;
private Result permissionRequestResult;
private ExecutorService executor;
private ImageCropPlugin(Activity activity) {
this.activity = activity;
}
public ImageCropPlugin(){ }
/**
* legacy APIs
*/
public static void registerWith(Registrar registrar) {
ImageCropPlugin instance = new ImageCropPlugin(registrar.activity());
instance.setup(registrar.messenger());
registrar.addRequestPermissionsResultListener(instance);
}
@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
this.setup(binding.getBinaryMessenger());
}
@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
channel.setMethodCallHandler(null);
channel = null;
}
@Override
public void onAttachedToActivity(ActivityPluginBinding activityPluginBinding) {
binding = activityPluginBinding;
activity = activityPluginBinding.getActivity();
activityPluginBinding.addRequestPermissionsResultListener(this);
}
@Override
public void onDetachedFromActivity() {
activity = null;
if(binding != null){
binding.removeRequestPermissionsResultListener(this);
}
}
@Override
public void onReattachedToActivityForConfigChanges(ActivityPluginBinding activityPluginBinding) {
this.onAttachedToActivity(activityPluginBinding);
}
@Override
public void onDetachedFromActivityForConfigChanges() {
this.onDetachedFromActivity();
}
private void setup(BinaryMessenger messenger) {
channel = new MethodChannel(messenger, "plugins.lykhonis.com/image_crop");
channel.setMethodCallHandler(this);
}
@SuppressWarnings("ConstantConditions")
@Override
public void onMethodCall(MethodCall call, Result result) {
if ("cropImage".equals(call.method)) {
String path = call.argument("path");
double scale = call.argument("scale");
double left = call.argument("left");
double top = call.argument("top");
double right = call.argument("right");
double bottom = call.argument("bottom");
RectF area = new RectF((float) left, (float) top, (float) right, (float) bottom);
cropImage(path, area, (float) scale, result);
} else if ("sampleImage".equals(call.method)) {
String path = call.argument("path");
int maximumWidth = call.argument("maximumWidth");
int maximumHeight = call.argument("maximumHeight");
sampleImage(path, maximumWidth, maximumHeight, result);
} else if ("getImageOptions".equals(call.method)) {
String path = call.argument("path");
getImageOptions(path, result);
} else if ("requestPermissions".equals(call.method)) {
requestPermissions(result);
} else {
result.notImplemented();
}
}
private synchronized void io(@NonNull Runnable runnable) {
if (executor == null) {
executor = Executors.newCachedThreadPool();
}
executor.execute(runnable);
}
private void ui(@NonNull Runnable runnable) {
activity.runOnUiThread(runnable);
}
private void cropImage(final String path, final RectF area, final float scale, final Result result) {
io(new Runnable() {
@Override
public void run() {
File srcFile = new File(path);
if (!srcFile.exists()) {
ui(new Runnable() {
@Override
public void run() {
result.error("INVALID", "Image source cannot be opened", null);
}
});
return;
}
Bitmap srcBitmap = BitmapFactory.decodeFile(path, null);
if (srcBitmap == null) {
ui(new Runnable() {
@Override
public void run() {
result.error("INVALID", "Image source cannot be decoded", null);
}
});
return;
}
ImageOptions options = decodeImageOptions(path);
if (options.isFlippedDimensions()) {
Matrix transformations = new Matrix();
transformations.postRotate(options.getDegrees());
Bitmap oldBitmap = srcBitmap;
srcBitmap = Bitmap.createBitmap(oldBitmap,
0, 0,
oldBitmap.getWidth(), oldBitmap.getHeight(),
transformations, true);
oldBitmap.recycle();
}
int width = (int) (options.getWidth() * area.width() * scale);
int height = (int) (options.getHeight() * area.height() * scale);
Bitmap dstBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(dstBitmap);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
paint.setDither(true);
Rect srcRect = new Rect((int) (srcBitmap.getWidth() * area.left),
(int) (srcBitmap.getHeight() * area.top),
(int) (srcBitmap.getWidth() * area.right),
(int) (srcBitmap.getHeight() * area.bottom));
Rect dstRect = new Rect(0, 0, width, height);
canvas.drawBitmap(srcBitmap, srcRect, dstRect, paint);
// TODO: Research a way to optimize rendering via matrix to reduce memory print.
// Matrix transformations = new Matrix();
// transformations.mapRect(new RectF(0, 0,
// options.getWidth(), options.getHeight()));
// transformations.postTranslate(-options.getWidth() / 2f * area.left,
// -options.getHeight() / 2f * area.top);
// transformations.postRotate(options.getDegrees(),
// options.getWidth() / 2f * area.width(),
// options.getHeight() / 2f * area.height());
// canvas.drawBitmap(srcBitmap, transformations, paint);
try {
final File dstFile = createTemporaryImageFile();
compressBitmap(dstBitmap, dstFile);
ui(new Runnable() {
@Override
public void run() {
result.success(dstFile.getAbsolutePath());
}
});
} catch (final IOException e) {
ui(new Runnable() {
@Override
public void run() {
result.error("INVALID", "Image could not be saved", e);
}
});
} finally {
canvas.setBitmap(null);
dstBitmap.recycle();
srcBitmap.recycle();
}
}
});
}
private void sampleImage(final String path, final int maximumWidth, final int maximumHeight, final Result result) {
io(new Runnable() {
@Override
public void run() {
File srcFile = new File(path);
if (!srcFile.exists()) {
ui(new Runnable() {
@Override
public void run() {
result.error("INVALID", "Image source cannot be opened", null);
}
});
return;
}
ImageOptions options = decodeImageOptions(path);
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
bitmapOptions.inSampleSize = calculateInSampleSize(options.getWidth(), options.getHeight(),
maximumWidth, maximumHeight);
Bitmap bitmap = BitmapFactory.decodeFile(path, bitmapOptions);
if (bitmap == null) {
ui(new Runnable() {
@Override
public void run() {
result.error("INVALID", "Image source cannot be decoded", null);
}
});
return;
}
if (options.getWidth() > maximumWidth && options.getHeight() > maximumHeight) {
float ratio = Math.max(maximumWidth / (float) options.getWidth(), maximumHeight / (float) options.getHeight());
Bitmap sample = bitmap;
bitmap = Bitmap.createScaledBitmap(sample, Math.round(bitmap.getWidth() * ratio), Math.round(bitmap.getHeight() * ratio), true);
sample.recycle();
}
try {
final File dstFile = createTemporaryImageFile();
compressBitmap(bitmap, dstFile);
copyExif(srcFile, dstFile);
ui(new Runnable() {
@Override
public void run() {
result.success(dstFile.getAbsolutePath());
}
});
} catch (final IOException e) {
ui(new Runnable() {
@Override
public void run() {
result.error("INVALID", "Image could not be saved", e);
}
});
} finally {
bitmap.recycle();
}
}
});
}
@SuppressWarnings("TryFinallyCanBeTryWithResources")
private void compressBitmap(Bitmap bitmap, File file) throws IOException {
OutputStream outputStream = new FileOutputStream(file);
try {
boolean compressed = bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
if (!compressed) {
throw new IOException("Failed to compress bitmap into JPEG");
}
} finally {
try {
outputStream.close();
} catch (IOException ignore) {
}
}
}
private int calculateInSampleSize(int width, int height, int maximumWidth, int maximumHeight) {
int inSampleSize = 1;
if (height > maximumHeight || width > maximumWidth) {
int halfHeight = height / 2;
int halfWidth = width / 2;
while ((halfHeight / inSampleSize) >= maximumHeight && (halfWidth / inSampleSize) >= maximumWidth) {
inSampleSize *= 2;
}
}
return inSampleSize;
}
private void getImageOptions(final String path, final Result result) {
io(new Runnable() {
@Override
public void run() {
File file = new File(path);
if (!file.exists()) {
result.error("INVALID", "Image source cannot be opened", null);
return;
}
ImageOptions options = decodeImageOptions(path);
final Map<String, Object> properties = new HashMap<>();
properties.put("width", options.getWidth());
properties.put("height", options.getHeight());
ui(new Runnable() {
@Override
public void run() {
result.success(properties);
}
});
}
});
}
private void requestPermissions(Result result) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (activity.checkSelfPermission(READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED &&
activity.checkSelfPermission(WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
result.success(true);
} else {
permissionRequestResult = result;
activity.requestPermissions(new String[]{READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
}
} else {
result.success(true);
}
}
@Override
public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == PERMISSION_REQUEST_CODE && permissionRequestResult != null) {
int readExternalStorage = getPermissionGrantResult(READ_EXTERNAL_STORAGE, permissions, grantResults);
int writeExternalStorage = getPermissionGrantResult(WRITE_EXTERNAL_STORAGE, permissions, grantResults);
permissionRequestResult.success(readExternalStorage == PackageManager.PERMISSION_GRANTED &&
writeExternalStorage == PackageManager.PERMISSION_GRANTED);
permissionRequestResult = null;
}
return false;
}
private int getPermissionGrantResult(String permission, String[] permissions, int[] grantResults) {
for (int i = 0; i < permission.length(); i++) {
if (permission.equals(permissions[i])) {
return grantResults[i];
}
}
return PackageManager.PERMISSION_DENIED;
}
private File createTemporaryImageFile() throws IOException {
File directory = activity.getCacheDir();
String name = "image_crop_" + UUID.randomUUID().toString();
return File.createTempFile(name, ".jpg", directory);
}
private ImageOptions decodeImageOptions(String path) {
int rotationDegrees = 0;
try {
ExifInterface exif = new ExifInterface(path);
rotationDegrees = exif.getRotationDegrees();
} catch (IOException e) {
Log.e("ImageCrop", "Failed to read a file " + path, e);
}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options);
return new ImageOptions(options.outWidth, options.outHeight, rotationDegrees);
}
private void copyExif(File source, File destination) {
try {
ExifInterface sourceExif = new ExifInterface(source.getAbsolutePath());
ExifInterface destinationExif = new ExifInterface(destination.getAbsolutePath());
List<String> tags =
Arrays.asList(
ExifInterface.TAG_F_NUMBER,
ExifInterface.TAG_EXPOSURE_TIME,
ExifInterface.TAG_PHOTOGRAPHIC_SENSITIVITY,
ExifInterface.TAG_GPS_ALTITUDE,
ExifInterface.TAG_GPS_ALTITUDE_REF,
ExifInterface.TAG_FOCAL_LENGTH,
ExifInterface.TAG_GPS_DATESTAMP,
ExifInterface.TAG_WHITE_BALANCE,
ExifInterface.TAG_GPS_PROCESSING_METHOD,
ExifInterface.TAG_GPS_TIMESTAMP,
ExifInterface.TAG_DATETIME,
ExifInterface.TAG_FLASH,
ExifInterface.TAG_GPS_LATITUDE,
ExifInterface.TAG_GPS_LATITUDE_REF,
ExifInterface.TAG_GPS_LONGITUDE,
ExifInterface.TAG_GPS_LONGITUDE_REF,
ExifInterface.TAG_MAKE,
ExifInterface.TAG_MODEL,
ExifInterface.TAG_ORIENTATION);
for (String tag : tags) {
String attribute = sourceExif.getAttribute(tag);
if (attribute != null) {
destinationExif.setAttribute(tag, attribute);
}
}
destinationExif.saveAttributes();
} catch (IOException e) {
Log.e("ImageCrop", "Failed to preserve Exif information", e);
}
}
private static final class ImageOptions {
private final int width;
private final int height;
private final int degrees;
ImageOptions(int width, int height, int degrees) {
this.width = width;
this.height = height;
this.degrees = degrees;
}
int getHeight() {
return (isFlippedDimensions() && degrees != 180) ? width : height;
}
int getWidth() {
return (isFlippedDimensions() && degrees != 180) ? height : width;
}
int getDegrees() {
return degrees;
}
boolean isFlippedDimensions() {
return degrees == 90 || degrees == 270 || degrees == 180;
}
public boolean isRotated() {
return degrees != 0;
}
}
}
================================================
FILE: example/.gitignore
================================================
# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# Visual Studio Code related
.vscode/
# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.packages
.pub-cache/
.pub/
build/
# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
================================================
FILE: example/README.md
================================================
# image_crop_example
Demonstrates how to use the image_crop plugin.
## Getting Started
For help getting started with Flutter, view our online
[documentation](https://flutter.io/).
================================================
FILE: example/android/app/build.gradle
================================================
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.lykhonis.imagecropexample"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
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'
}
================================================
FILE: example/android/app/src/main/AndroidManifest.xml
================================================
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lykhonis.imagecropexample">
<!-- The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:icon="@mipmap/ic_launcher"
android:label="image_crop_example">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:screenOrientation="userPortrait"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: example/android/app/src/main/java/com/lykhonis/imagecropexample/MainActivity.java
================================================
package com.lykhonis.imagecropexample;
import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
================================================
FILE: example/android/app/src/main/res/drawable/launch_background.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
================================================
FILE: example/android/app/src/main/res/values/styles.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
</resources>
================================================
FILE: example/android/build.gradle
================================================
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: example/android/gradle/wrapper/gradle-wrapper.properties
================================================
#Sat Jun 01 05:20:09 PDT 2019
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
================================================
FILE: example/android/gradle.properties
================================================
org.gradle.jvmargs=-Xmx1536M
================================================
FILE: example/android/settings.gradle
================================================
include ':app'
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
================================================
FILE: example/ios/Flutter/.last_build_id
================================================
96b858413dd1e970b76641c6cef4bcad
================================================
FILE: example/ios/Flutter/AppFrameworkInfo.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>App</string>
<key>CFBundleIdentifier</key>
<string>io.flutter.flutter.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>App</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
</dict>
</plist>
================================================
FILE: example/ios/Flutter/Debug.xcconfig
================================================
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
================================================
FILE: example/ios/Flutter/Flutter.podspec
================================================
#
# 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
================================================
FILE: example/ios/Flutter/Release.xcconfig
================================================
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
================================================
FILE: example/ios/Podfile
================================================
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
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
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
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
================================================
FILE: example/ios/Runner/AppDelegate.h
================================================
#import <Flutter/Flutter.h>
#import <UIKit/UIKit.h>
@interface AppDelegate : FlutterAppDelegate
@end
================================================
FILE: example/ios/Runner/AppDelegate.m
================================================
#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end
================================================
FILE: example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@1x.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@1x.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@1x.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-App-83.5x83.5@2x.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Icon-App-1024x1024@1x.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"filename" : "LaunchImage.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "LaunchImage@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "LaunchImage@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md
================================================
# Launch Screen Assets
You can customize the launch screen with your own desired assets by replacing the image files in this directory.
You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
================================================
FILE: example/ios/Runner/Base.lproj/LaunchScreen.storyboard
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Ydg-fD-yQy"/>
<viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4">
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="1a2-6s-vTC"/>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="4X2-HB-R7a"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<image name="LaunchImage" width="168" height="185"/>
</resources>
</document>
================================================
FILE: example/ios/Runner/Base.lproj/Main.storyboard
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--Flutter View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
================================================
FILE: example/ios/Runner/Info.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>image_crop_example</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) photo use</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>
================================================
FILE: example/ios/Runner/main.m
================================================
#import <Flutter/Flutter.h>
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char* argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
================================================
FILE: example/ios/Runner.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
45D7AD3E8B938D6F2DCCF45D /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F3FC772E646CA03FC65146EE /* libPods-Runner.a */; };
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
9705A1C41CF9048500538489 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
2596FE007A8D745C0B6E51FF /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
855E57973FA76BEBC79E496E /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
F3FC772E646CA03FC65146EE /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
45D7AD3E8B938D6F2DCCF45D /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
);
name = Flutter;
sourceTree = "<group>";
};
97C146E51CF9000F007C117D = {
isa = PBXGroup;
children = (
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
C8F9B5686C9254534AD5F089 /* Pods */,
F7872D91B426FBF6C372E7EF /* Frameworks */,
);
sourceTree = "<group>";
};
97C146EF1CF9000F007C117D /* Products */ = {
isa = PBXGroup;
children = (
97C146EE1CF9000F007C117D /* Runner.app */,
);
name = Products;
sourceTree = "<group>";
};
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
97C147021CF9000F007C117D /* Info.plist */,
97C146F11CF9000F007C117D /* Supporting Files */,
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
);
path = Runner;
sourceTree = "<group>";
};
97C146F11CF9000F007C117D /* Supporting Files */ = {
isa = PBXGroup;
children = (
97C146F21CF9000F007C117D /* main.m */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
C8F9B5686C9254534AD5F089 /* Pods */ = {
isa = PBXGroup;
children = (
855E57973FA76BEBC79E496E /* Pods-Runner.debug.xcconfig */,
2596FE007A8D745C0B6E51FF /* Pods-Runner.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
F7872D91B426FBF6C372E7EF /* Frameworks */ = {
isa = PBXGroup;
children = (
F3FC772E646CA03FC65146EE /* libPods-Runner.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
97C146ED1CF9000F007C117D /* Runner */ = {
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
263AC01179F27909E5C06BE9 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
);
buildRules = (
);
dependencies = (
);
name = Runner;
productName = Runner;
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = KSK2PM67WL;
};
};
};
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 97C146E51CF9000F007C117D;
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
97C146ED1CF9000F007C117D /* Runner */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
97C146EC1CF9000F007C117D /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
263AC01179F27909E5C06BE9 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Thin Binary";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Run Script";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
97C146EA1CF9000F007C117D /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
97C146F31CF9000F007C117D /* main.m in Sources */,
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
97C146FA1CF9000F007C117D /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
97C146FB1CF9000F007C117D /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
97C147001CF9000F007C117D /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
97C147031CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
97C147041CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
97C147061CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = KSK2PM67WL;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = com.lykhonis.imageCropExample;
PRODUCT_NAME = "$(TARGET_NAME)";
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
};
97C147071CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = KSK2PM67WL;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = com.lykhonis.imageCropExample;
PRODUCT_NAME = "$(TARGET_NAME)";
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
97C147031CF9000F007C117D /* Debug */,
97C147041CF9000F007C117D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
97C147061CF9000F007C117D /* Debug */,
97C147071CF9000F007C117D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
================================================
FILE: example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
</Workspace>
================================================
FILE: example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
================================================
FILE: example/ios/Runner.xcworkspace/contents.xcworkspacedata
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
================================================
FILE: example/ios/Runner.xcworkspace/contents.xcworkspacedata.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
================================================
FILE: example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
================================================
FILE: example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
</dict>
</plist>
================================================
FILE: example/lib/main.dart
================================================
import 'dart:io';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_crop/image_crop.dart';
import 'package:image_picker/image_picker.dart';
void main() {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarBrightness: Brightness.dark,
statusBarIconBrightness: Brightness.light,
systemNavigationBarIconBrightness: Brightness.light,
));
runApp(new MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
final cropKey = GlobalKey<CropState>();
File _file;
File _sample;
File _lastCropped;
@override
void dispose() {
super.dispose();
_file?.delete();
_sample?.delete();
_lastCropped?.delete();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: SafeArea(
child: Container(
color: Colors.black,
padding: const EdgeInsets.symmetric(vertical: 40.0, horizontal: 20.0),
child: _sample == null ? _buildOpeningImage() : _buildCroppingImage(),
),
),
);
}
Widget _buildOpeningImage() {
return Center(child: _buildOpenImage());
}
Widget _buildCroppingImage() {
return Column(
children: <Widget>[
Expanded(
child: Crop.file(_sample, key: cropKey),
),
Container(
padding: const EdgeInsets.only(top: 20.0),
alignment: AlignmentDirectional.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
TextButton(
child: Text(
'Crop Image',
style: Theme.of(context)
.textTheme
.button
.copyWith(color: Colors.white),
),
onPressed: () => _cropImage(),
),
_buildOpenImage(),
],
),
)
],
);
}
Widget _buildOpenImage() {
return TextButton(
child: Text(
'Open Image',
style: Theme.of(context).textTheme.button.copyWith(color: Colors.white),
),
onPressed: () => _openImage(),
);
}
Future<void> _openImage() async {
final pickedFile = await ImagePicker().getImage(source: ImageSource.gallery);
final file = File(pickedFile.path);
final sample = await ImageCrop.sampleImage(
file: file,
preferredSize: context.size.longestSide.ceil(),
);
_sample?.delete();
_file?.delete();
setState(() {
_sample = sample;
_file = file;
});
}
Future<void> _cropImage() async {
final scale = cropKey.currentState.scale;
final area = cropKey.currentState.area;
if (area == null) {
// cannot crop, widget is not setup
return;
}
// scale up to use maximum possible number of pixels
// this will sample image in higher resolution to make cropped image larger
final sample = await ImageCrop.sampleImage(
file: _file,
preferredSize: (2000 / scale).round(),
);
final file = await ImageCrop.cropImage(
file: sample,
area: area,
);
sample.delete();
_lastCropped?.delete();
_lastCropped = file;
debugPrint('$file');
}
}
================================================
FILE: example/pubspec.yaml
================================================
name: image_crop_example
description: Demonstrates how to use the image_crop plugin.
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
image_picker: ^0.7.4
dev_dependencies:
flutter_test:
sdk: flutter
image_crop:
path: ../
flutter:
uses-material-design: true
================================================
FILE: ios/.gitignore
================================================
.idea/
.vagrant/
.sconsign.dblite
.svn/
.DS_Store
*.swp
profile
DerivedData/
build/
GeneratedPluginRegistrant.h
GeneratedPluginRegistrant.m
.generated/
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3
xcuserdata
*.moved-aside
*.pyc
*sync/
Icon?
.tags*
/Flutter/Generated.xcconfig
================================================
FILE: ios/Assets/.gitkeep
================================================
================================================
FILE: ios/Classes/ImageCropPlugin.h
================================================
#import <Flutter/Flutter.h>
@interface ImageCropPlugin : NSObject<FlutterPlugin>
@end
================================================
FILE: ios/Classes/ImageCropPlugin.m
================================================
#import "ImageCropPlugin.h"
#import <Photos/Photos.h>
#import <MobileCoreServices/MobileCoreServices.h>
@implementation ImageCropPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
FlutterMethodChannel* channel = [FlutterMethodChannel
methodChannelWithName:@"plugins.lykhonis.com/image_crop"
binaryMessenger:[registrar messenger]];
ImageCropPlugin* instance = [ImageCropPlugin new];
[registrar addMethodCallDelegate:instance channel:channel];
}
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
if ([@"cropImage" isEqualToString:call.method]) {
NSString* path = (NSString*)call.arguments[@"path"];
NSNumber* left = (NSNumber*)call.arguments[@"left"];
NSNumber* top = (NSNumber*)call.arguments[@"top"];
NSNumber* right = (NSNumber*)call.arguments[@"right"];
NSNumber* bottom = (NSNumber*)call.arguments[@"bottom"];
NSNumber* scale = (NSNumber*)call.arguments[@"scale"];
CGRect area = CGRectMake(left.floatValue, top.floatValue,
right.floatValue - left.floatValue,
bottom.floatValue - top.floatValue);
[self cropImage:path area:area scale:scale result:result];
} else if ([@"sampleImage" isEqualToString:call.method]) {
NSString* path = (NSString*)call.arguments[@"path"];
NSNumber* maximumWidth = (NSNumber*)call.arguments[@"maximumWidth"];
NSNumber* maximumHeight = (NSNumber*)call.arguments[@"maximumHeight"];
[self sampleImage:path
maximumWidth:maximumWidth
maximumHeight:maximumHeight
result:result];
} else if ([@"getImageOptions" isEqualToString:call.method]) {
NSString* path = (NSString*)call.arguments[@"path"];
[self getImageOptions:path result:result];
} else if ([@"requestPermissions" isEqualToString:call.method]){
[self requestPermissionsWithResult:result];
} else {
result(FlutterMethodNotImplemented);
}
}
- (void)cropImage:(NSString*)path
area:(CGRect)area
scale:(NSNumber*)scale
result:(FlutterResult)result {
[self execute:^{
NSURL* url = [NSURL fileURLWithPath:path];
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef) url, NULL);
if (imageSource == NULL) {
result([FlutterError errorWithCode:@"INVALID"
message:@"Image source cannot be opened"
details:nil]);
return;
}
CFDictionaryRef options = (__bridge CFDictionaryRef) @{
(id) kCGImageSourceCreateThumbnailWithTransform: @YES,
(id) kCGImageSourceCreateThumbnailFromImageAlways: @YES
};
CGImageRef image = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, options);
if (image == NULL) {
result([FlutterError errorWithCode:@"INVALID"
message:@"Image cannot be opened"
details:nil]);
CFRelease(imageSource);
return;
}
size_t width = CGImageGetWidth(image);
size_t height = CGImageGetHeight(image);
size_t scaledWidth = (size_t) (width * area.size.width * scale.floatValue);
size_t scaledHeight = (size_t) (height * area.size.height * scale.floatValue);
size_t bitsPerComponent = CGImageGetBitsPerComponent(image);
size_t bytesPerRow = CGImageGetBytesPerRow(image) / width * scaledWidth;
CGImageAlphaInfo bitmapInfo = CGImageGetAlphaInfo(image);
CGColorSpaceRef colorspace = CGImageGetColorSpace(image);
CGImageRef croppedImage = CGImageCreateWithImageInRect(image,
CGRectMake(width * area.origin.x,
height * area.origin.y,
width * area.size.width,
height * area.size.height));
CFRelease(image);
CFRelease(imageSource);
if (scale.floatValue != 1.0) {
CGContextRef context = CGBitmapContextCreate(NULL,
scaledWidth,
scaledHeight,
bitsPerComponent,
bytesPerRow,
colorspace,
bitmapInfo);
if (context == NULL) {
result([FlutterError errorWithCode:@"INVALID"
message:@"Image cannot be scaled"
details:nil]);
CFRelease(croppedImage);
return;
}
CGRect rect = CGContextGetClipBoundingBox(context);
CGContextDrawImage(context, rect, croppedImage);
CGImageRef scaledImage = CGBitmapContextCreateImage(context);
CGContextRelease(context);
CFRelease(croppedImage);
croppedImage = scaledImage;
}
NSURL* croppedUrl = [self createTemporaryImageUrl];
bool saved = [self saveImage:croppedImage url:croppedUrl];
CFRelease(croppedImage);
if (saved) {
result(croppedUrl.path);
} else {
result([FlutterError errorWithCode:@"INVALID"
message:@"Cropped image cannot be saved"
details:nil]);
}
}];
}
- (void)sampleImage:(NSString*)path
maximumWidth:(NSNumber*)maximumWidth
maximumHeight:(NSNumber*)maximumHeight
result:(FlutterResult)result {
[self execute:^{
NSURL* url = [NSURL fileURLWithPath:path];
CGImageSourceRef image = CGImageSourceCreateWithURL((CFURLRef) url, NULL);
if (image == NULL) {
result([FlutterError errorWithCode:@"INVALID"
message:@"Image source cannot be opened"
details:nil]);
return;
}
CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(image, 0, nil);
if (properties == NULL) {
CFRelease(image);
result([FlutterError errorWithCode:@"INVALID"
message:@"Image source properties cannot be copied"
details:nil]);
return;
}
NSNumber* width = (NSNumber*) CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth);
NSNumber* height = (NSNumber*) CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight);
CFRelease(properties);
double widthRatio = MIN(1.0, maximumWidth.doubleValue / width.doubleValue);
double heightRatio = MIN(1.0, maximumHeight.doubleValue / height.doubleValue);
double ratio = MAX(widthRatio, heightRatio);
NSNumber* maximumSize = @(MAX(width.doubleValue * ratio, height.doubleValue * ratio));
CFDictionaryRef options = (__bridge CFDictionaryRef) @{
(id) kCGImageSourceCreateThumbnailWithTransform: @YES,
(id) kCGImageSourceCreateThumbnailFromImageAlways : @YES,
(id) kCGImageSourceThumbnailMaxPixelSize : maximumSize
};
CGImageRef sampleImage = CGImageSourceCreateThumbnailAtIndex(image, 0, options);
CFRelease(image);
if (sampleImage == NULL) {
result([FlutterError errorWithCode:@"INVALID"
message:@"Image sample cannot be created"
details:nil]);
return;
}
NSURL* sampleUrl = [self createTemporaryImageUrl];
bool saved = [self saveImage:sampleImage url:sampleUrl];
CFRelease(sampleImage);
if (saved) {
result(sampleUrl.path);
} else {
result([FlutterError errorWithCode:@"INVALID"
message:@"Image sample cannot be saved"
details:nil]);
}
}];
}
- (void)getImageOptions:(NSString*)path result:(FlutterResult)result {
[self execute:^{
NSURL* url = [NSURL fileURLWithPath:path];
CGImageSourceRef image = CGImageSourceCreateWithURL((CFURLRef) url, NULL);
if (image == NULL) {
result([FlutterError errorWithCode:@"INVALID"
message:@"Image source cannot be opened"
details:nil]);
return;
}
CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(image, 0, nil);
CFRelease(image);
if (properties == NULL) {
result([FlutterError errorWithCode:@"INVALID"
message:@"Image source properties cannot be copied"
details:nil]);
return;
}
NSNumber* width = (NSNumber*) CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth);
NSNumber* height = (NSNumber*) CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight);
CFRelease(properties);
result(@{ @"width": width, @"height": height });
}];
}
- (void)requestPermissionsWithResult:(FlutterResult)result {
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
if (status == PHAuthorizationStatusAuthorized) {
result(@YES);
} else {
result(@NO);
}
}];
}
- (bool)saveImage:(CGImageRef)image url:(NSURL*)url {
CGImageDestinationRef destination = CGImageDestinationCreateWithURL((CFURLRef) url, kUTTypeJPEG, 1, NULL);
CGImageDestinationAddImage(destination, image, NULL);
bool finilized = CGImageDestinationFinalize(destination);
CFRelease(destination);
return finilized;
}
- (NSURL*)createTemporaryImageUrl {
NSString* temproraryDirectory = NSTemporaryDirectory();
NSString* guid = [[NSProcessInfo processInfo] globallyUniqueString];
NSString* sampleName = [[@"image_crop_" stringByAppendingString:guid] stringByAppendingString:@".jpg"];
NSString* samplePath = [temproraryDirectory stringByAppendingPathComponent:sampleName];
return [NSURL fileURLWithPath:samplePath];
}
- (void)execute:(void (^)(void))block {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
}
@end
================================================
FILE: ios/image_crop.podspec
================================================
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'image_crop'
s.version = '0.0.1'
s.summary = 'A flutter plugin to crop image on iOS and Android.'
s.description = <<-DESC
A flutter plugin to crop image on iOS and Android.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.ios.deployment_target = '8.0'
end
================================================
FILE: lib/image_crop.dart
================================================
library image_crop;
import 'dart:async';
import 'dart:io';
import 'dart:math';
import 'dart:ui' as ui;
import 'package:flutter/gestures.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/services.dart';
part 'src/image_crop.dart';
part 'src/crop.dart';
================================================
FILE: lib/src/crop.dart
================================================
part of image_crop;
const _kCropGridColumnCount = 3;
const _kCropGridRowCount = 3;
const _kCropGridColor = Color.fromRGBO(0xd0, 0xd0, 0xd0, 0.9);
const _kCropOverlayActiveOpacity = 0.3;
const _kCropOverlayInactiveOpacity = 0.7;
const _kCropHandleColor = Color.fromRGBO(0xd0, 0xd0, 0xd0, 1.0);
const _kCropHandleSize = 10.0;
const _kCropHandleHitSize = 48.0;
const _kCropMinFraction = 0.1;
enum _CropAction { none, moving, cropping, scaling }
enum _CropHandleSide { none, topLeft, topRight, bottomLeft, bottomRight }
class Crop extends StatefulWidget {
final ImageProvider image;
final double? aspectRatio;
final double maximumScale;
final bool alwaysShowGrid;
final ImageErrorListener? onImageError;
const Crop({
Key? key,
required this.image,
this.aspectRatio,
this.maximumScale = 2.0,
this.alwaysShowGrid = false,
this.onImageError,
}) : super(key: key);
Crop.file(
File file, {
Key? key,
double scale = 1.0,
this.aspectRatio,
this.maximumScale = 2.0,
this.alwaysShowGrid = false,
this.onImageError,
}) : image = FileImage(file, scale: scale),
super(key: key);
Crop.asset(
String assetName, {
Key? key,
AssetBundle? bundle,
String? package,
this.aspectRatio,
this.maximumScale = 2.0,
this.alwaysShowGrid = false,
this.onImageError,
}) : image = AssetImage(assetName, bundle: bundle, package: package),
super(key: key);
@override
State<StatefulWidget> createState() => CropState();
static CropState? of(BuildContext context) =>
context.findAncestorStateOfType<CropState>();
}
class CropState extends State<Crop> with TickerProviderStateMixin, Drag {
final _surfaceKey = GlobalKey();
late final AnimationController _activeController;
late final AnimationController _settleController;
double _scale = 1.0;
double _ratio = 1.0;
Rect _view = Rect.zero;
Rect _area = Rect.zero;
Offset _lastFocalPoint = Offset.zero;
_CropAction _action = _CropAction.none;
_CropHandleSide _handle = _CropHandleSide.none;
late double _startScale;
late Rect _startView;
late Tween<Rect?> _viewTween;
late Tween<double> _scaleTween;
ImageStream? _imageStream;
ui.Image? _image;
ImageStreamListener? _imageListener;
double get scale => _area.shortestSide / _scale;
Rect? get area => _view.isEmpty
? null
: Rect.fromLTWH(
max(_area.left * _view.width / _scale - _view.left, 0),
max(_area.top * _view.height / _scale - _view.top, 0),
_area.width * _view.width / _scale,
_area.height * _view.height / _scale,
);
bool get _isEnabled => _view.isEmpty == false && _image != null;
// Saving the length for the widest area for different aspectRatio's
final Map<double, double> _maxAreaWidthMap = {};
// Counting pointers(number of user fingers on screen)
int pointers = 0;
@override
void initState() {
super.initState();
_activeController = AnimationController(
vsync: this,
value: widget.alwaysShowGrid ? 1.0 : 0.0,
)..addListener(() => setState(() {}));
_settleController = AnimationController(vsync: this)
..addListener(_settleAnimationChanged);
}
@override
void dispose() {
final listener = _imageListener;
if (listener != null) {
_imageStream?.removeListener(listener);
}
_activeController.dispose();
_settleController.dispose();
super.dispose();
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
_getImage();
}
@override
void didUpdateWidget(Crop oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.image != oldWidget.image) {
_getImage();
} else if (widget.aspectRatio != oldWidget.aspectRatio) {
_area = _calculateDefaultArea(
viewWidth: _view.width,
viewHeight: _view.height,
imageWidth: _image?.width,
imageHeight: _image?.height,
);
}
if (widget.alwaysShowGrid != oldWidget.alwaysShowGrid) {
if (widget.alwaysShowGrid) {
_activate();
} else {
_deactivate();
}
}
}
void _getImage({bool force = false}) {
final oldImageStream = _imageStream;
final newImageStream =
widget.image.resolve(createLocalImageConfiguration(context));
_imageStream = newImageStream;
if (newImageStream.key != oldImageStream?.key || force) {
final oldImageListener = _imageListener;
if (oldImageListener != null) {
oldImageStream?.removeListener(oldImageListener);
}
final newImageListener =
ImageStreamListener(_updateImage, onError: widget.onImageError);
_imageListener = newImageListener;
newImageStream.addListener(newImageListener);
}
}
@override
Widget build(BuildContext context) => ConstrainedBox(
constraints: const BoxConstraints.expand(),
child: Listener(
onPointerDown: (event) => pointers++,
onPointerUp: (event) => pointers = 0,
child: GestureDetector(
key: _surfaceKey,
behavior: HitTestBehavior.opaque,
onScaleStart: _isEnabled ? _handleScaleStart : null,
onScaleUpdate: _isEnabled ? _handleScaleUpdate : null,
onScaleEnd: _isEnabled ? _handleScaleEnd : null,
child: CustomPaint(
painter: _CropPainter(
image: _image,
ratio: _ratio,
view: _view,
area: _area,
scale: _scale,
active: _activeController.value,
),
),
),
),
);
void _activate() {
_activeController.animateTo(
1.0,
curve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 250),
);
}
void _deactivate() {
if (widget.alwaysShowGrid == false) {
_activeController.animateTo(
0.0,
curve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 250),
);
}
}
Size? get _boundaries {
final context = _surfaceKey.currentContext;
if (context == null) {
return null;
}
final size = context.size;
if (size == null) {
return null;
}
return size - const Offset(_kCropHandleSize, _kCropHandleSize) as Size;
}
Offset? _getLocalPoint(Offset point) {
final context = _surfaceKey.currentContext;
if (context == null) {
return null;
}
final box = context.findRenderObject() as RenderBox;
return box.globalToLocal(point);
}
void _settleAnimationChanged() {
setState(() {
_scale = _scaleTween.transform(_settleController.value);
final nextView = _viewTween.transform(_settleController.value);
if (nextView != null) {
_view = nextView;
}
});
}
Rect _calculateDefaultArea({
required int? imageWidth,
required int? imageHeight,
required double viewWidth,
required double viewHeight,
}) {
if (imageWidth == null || imageHeight == null) {
return Rect.zero;
}
double height;
double width;
if ((widget.aspectRatio ?? 1.0) < 1) {
height = 1.0;
width =
((widget.aspectRatio ?? 1.0) * imageHeight * viewHeight * height) /
imageWidth /
viewWidth;
if (width > 1.0) {
width = 1.0;
height = (imageWidth * viewWidth * width) /
(imageHeight * viewHeight * (widget.aspectRatio ?? 1.0));
}
} else {
width = 1.0;
height = (imageWidth * viewWidth * width) /
(imageHeight * viewHeight * (widget.aspectRatio ?? 1.0));
if (height > 1.0) {
height = 1.0;
width =
((widget.aspectRatio ?? 1.0) * imageHeight * viewHeight * height) /
imageWidth /
viewWidth;
}
}
final aspectRatio = _maxAreaWidthMap[widget.aspectRatio];
if (aspectRatio != null) {
_maxAreaWidthMap[aspectRatio] = width;
}
return Rect.fromLTWH((1.0 - width) / 2, (1.0 - height) / 2, width, height);
}
void _updateImage(ImageInfo imageInfo, bool synchronousCall) {
final boundaries = _boundaries;
if (boundaries == null) {
return;
}
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
final image = imageInfo.image;
setState(() {
_image = image;
_scale = imageInfo.scale;
_ratio = max(
boundaries.width / image.width,
boundaries.height / image.height,
);
final viewWidth = boundaries.width / (image.width * _scale * _ratio);
final viewHeight = boundaries.height / (image.height * _scale * _ratio);
_area = _calculateDefaultArea(
viewWidth: viewWidth,
viewHeight: viewHeight,
imageWidth: image.width,
imageHeight: image.height,
);
_view = Rect.fromLTWH(
(viewWidth - 1.0) / 2,
(viewHeight - 1.0) / 2,
viewWidth,
viewHeight,
);
});
});
WidgetsBinding.instance.ensureVisualUpdate();
}
_CropHandleSide _hitCropHandle(Offset? localPoint) {
final boundaries = _boundaries;
if (localPoint == null || boundaries == null) {
return _CropHandleSide.none;
}
final viewRect = Rect.fromLTWH(
boundaries.width * _area.left,
boundaries.height * _area.top,
boundaries.width * _area.width,
boundaries.height * _area.height,
).deflate(_kCropHandleSize / 2);
if (Rect.fromLTWH(
viewRect.left - _kCropHandleHitSize / 2,
viewRect.top - _kCropHandleHitSize / 2,
_kCropHandleHitSize,
_kCropHandleHitSize,
).contains(localPoint)) {
return _CropHandleSide.topLeft;
}
if (Rect.fromLTWH(
viewRect.right - _kCropHandleHitSize / 2,
viewRect.top - _kCropHandleHitSize / 2,
_kCropHandleHitSize,
_kCropHandleHitSize,
).contains(localPoint)) {
return _CropHandleSide.topRight;
}
if (Rect.fromLTWH(
viewRect.left - _kCropHandleHitSize / 2,
viewRect.bottom - _kCropHandleHitSize / 2,
_kCropHandleHitSize,
_kCropHandleHitSize,
).contains(localPoint)) {
return _CropHandleSide.bottomLeft;
}
if (Rect.fromLTWH(
viewRect.right - _kCropHandleHitSize / 2,
viewRect.bottom - _kCropHandleHitSize / 2,
_kCropHandleHitSize,
_kCropHandleHitSize,
).contains(localPoint)) {
return _CropHandleSide.bottomRight;
}
return _CropHandleSide.none;
}
void _handleScaleStart(ScaleStartDetails details) {
_activate();
_settleController.stop(canceled: false);
_lastFocalPoint = details.focalPoint;
_action = _CropAction.none;
_handle = _hitCropHandle(_getLocalPoint(details.focalPoint));
_startScale = _scale;
_startView = _view;
}
Rect _getViewInBoundaries(double scale) =>
Offset(
max(
min(
_view.left,
_area.left * _view.width / scale,
),
_area.right * _view.width / scale - 1.0,
),
max(
min(
_view.top,
_area.top * _view.height / scale,
),
_area.bottom * _view.height / scale - 1.0,
),
) &
_view.size;
double get _maximumScale => widget.maximumScale;
double? get _minimumScale {
final boundaries = _boundaries;
final image = _image;
if (boundaries == null || image == null) {
return null;
}
final scaleX = boundaries.width * _area.width / (image.width * _ratio);
final scaleY = boundaries.height * _area.height / (image.height * _ratio);
return min(_maximumScale, max(scaleX, scaleY));
}
void _handleScaleEnd(ScaleEndDetails details) {
_deactivate();
final minimumScale = _minimumScale;
if (minimumScale == null) {
return;
}
final targetScale = _scale.clamp(minimumScale, _maximumScale);
_scaleTween = Tween<double>(
begin: _scale,
end: targetScale,
);
_startView = _view;
_viewTween = RectTween(
begin: _view,
end: _getViewInBoundaries(targetScale),
);
_settleController.value = 0.0;
_settleController.animateTo(
1.0,
curve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 350),
);
}
void _updateArea({
required _CropHandleSide cropHandleSide,
double? left,
double? top,
double? right,
double? bottom,
}) {
final image = _image;
if (image == null) {
return;
}
var areaLeft = _area.left + (left ?? 0.0);
var areaBottom = _area.bottom + (bottom ?? 0.0);
var areaTop = _area.top + (top ?? 0.0);
var areaRight = _area.right + (right ?? 0.0);
double width = areaRight - areaLeft;
double height = (image.width * _view.width * width) /
(image.height * _view.height * (widget.aspectRatio ?? 1.0));
final maxAreaWidth = _maxAreaWidthMap[widget.aspectRatio];
if ((height >= 1.0 || width >= 1.0) && maxAreaWidth != null) {
height = 1.0;
if (cropHandleSide == _CropHandleSide.bottomLeft ||
cropHandleSide == _CropHandleSide.topLeft) {
areaLeft = areaRight - maxAreaWidth;
} else {
areaRight = areaLeft + maxAreaWidth;
}
}
// ensure minimum rectangle
if (areaRight - areaLeft < _kCropMinFraction) {
if (left != null) {
areaLeft = areaRight - _kCropMinFraction;
} else {
areaRight = areaLeft + _kCropMinFraction;
}
}
if (areaBottom - areaTop < _kCropMinFraction) {
if (top != null) {
areaTop = areaBottom - _kCropMinFraction;
} else {
areaBottom = areaTop + _kCropMinFraction;
}
}
// adjust to aspect ratio if needed
final aspectRatio = widget.aspectRatio;
if (aspectRatio != null && aspectRatio > 0.0) {
if (top != null) {
areaTop = areaBottom - height;
if (areaTop < 0.0) {
areaTop = 0.0;
areaBottom = height;
}
} else {
areaBottom = areaTop + height;
if (areaBottom > 1.0) {
areaTop = 1.0 - height;
areaBottom = 1.0;
}
}
}
// ensure to remain within bounds of the view
if (areaLeft < 0.0) {
areaLeft = 0.0;
areaRight = _area.width;
} else if (areaRight > 1.0) {
areaLeft = 1.0 - _area.width;
areaRight = 1.0;
}
if (areaTop < 0.0) {
areaTop = 0.0;
areaBottom = _area.height;
} else if (areaBottom > 1.0) {
areaTop = 1.0 - _area.height;
areaBottom = 1.0;
}
setState(() {
_area = Rect.fromLTRB(areaLeft, areaTop, areaRight, areaBottom);
});
}
void _handleScaleUpdate(ScaleUpdateDetails details) {
if (_action == _CropAction.none) {
if (_handle == _CropHandleSide.none) {
_action = pointers == 2 ? _CropAction.scaling : _CropAction.moving;
} else {
_action = _CropAction.cropping;
}
}
if (_action == _CropAction.cropping) {
final boundaries = _boundaries;
if (boundaries == null) {
return;
}
final delta = details.focalPoint - _lastFocalPoint;
_lastFocalPoint = details.focalPoint;
final dx = delta.dx / boundaries.width;
final dy = delta.dy / boundaries.height;
if (_handle == _CropHandleSide.topLeft) {
_updateArea(left: dx, top: dy, cropHandleSide: _CropHandleSide.topLeft);
} else if (_handle == _CropHandleSide.topRight) {
_updateArea(
top: dy, right: dx, cropHandleSide: _CropHandleSide.topRight);
} else if (_handle == _CropHandleSide.bottomLeft) {
_updateArea(
left: dx, bottom: dy, cropHandleSide: _CropHandleSide.bottomLeft);
} else if (_handle == _CropHandleSide.bottomRight) {
_updateArea(
right: dx, bottom: dy, cropHandleSide: _CropHandleSide.bottomRight);
}
} else if (_action == _CropAction.moving) {
final image = _image;
if (image == null) {
return;
}
final delta = details.focalPoint - _lastFocalPoint;
_lastFocalPoint = details.focalPoint;
setState(() {
_view = _view.translate(
delta.dx / (image.width * _scale * _ratio),
delta.dy / (image.height * _scale * _ratio),
);
});
} else if (_action == _CropAction.scaling) {
final image = _image;
final boundaries = _boundaries;
if (image == null || boundaries == null) {
return;
}
setState(() {
_scale = _startScale * details.scale;
final dx = boundaries.width *
(1.0 - details.scale) /
(image.width * _scale * _ratio);
final dy = boundaries.height *
(1.0 - details.scale) /
(image.height * _scale * _ratio);
_view = Rect.fromLTWH(
_startView.left + dx / 2,
_startView.top + dy / 2,
_startView.width,
_startView.height,
);
});
}
}
}
class _CropPainter extends CustomPainter {
final ui.Image? image;
final Rect view;
final double ratio;
final Rect area;
final double scale;
final double active;
_CropPainter({
required this.image,
required this.view,
required this.ratio,
required this.area,
required this.scale,
required this.active,
});
@override
bool shouldRepaint(_CropPainter oldDelegate) {
return oldDelegate.image != image ||
oldDelegate.view != view ||
oldDelegate.ratio != ratio ||
oldDelegate.area != area ||
oldDelegate.active != active ||
oldDelegate.scale != scale;
}
@override
void paint(Canvas canvas, Size size) {
final rect = Rect.fromLTWH(
_kCropHandleSize / 2,
_kCropHandleSize / 2,
size.width - _kCropHandleSize,
size.height - _kCropHandleSize,
);
canvas.save();
canvas.translate(rect.left, rect.top);
final paint = Paint()..isAntiAlias = false;
final image = this.image;
if (image != null) {
final src = Rect.fromLTWH(
0.0,
0.0,
image.width.toDouble(),
image.height.toDouble(),
);
final dst = Rect.fromLTWH(
view.left * image.width * scale * ratio,
view.top * image.height * scale * ratio,
image.width * scale * ratio,
image.height * scale * ratio,
);
canvas.save();
canvas.clipRect(Rect.fromLTWH(0.0, 0.0, rect.width, rect.height));
canvas.drawImageRect(image, src, dst, paint);
canvas.restore();
}
paint.color = Color.fromRGBO(
0x0,
0x0,
0x0,
_kCropOverlayActiveOpacity * active +
_kCropOverlayInactiveOpacity * (1.0 - active));
final boundaries = Rect.fromLTWH(
rect.width * area.left,
rect.height * area.top,
rect.width * area.width,
rect.height * area.height,
);
canvas.drawRect(Rect.fromLTRB(0.0, 0.0, rect.width, boundaries.top), paint);
canvas.drawRect(
Rect.fromLTRB(0.0, boundaries.bottom, rect.width, rect.height), paint);
canvas.drawRect(
Rect.fromLTRB(0.0, boundaries.top, boundaries.left, boundaries.bottom),
paint);
canvas.drawRect(
Rect.fromLTRB(
boundaries.right, boundaries.top, rect.width, boundaries.bottom),
paint);
if (boundaries.isEmpty == false) {
_drawGrid(canvas, boundaries);
_drawHandles(canvas, boundaries);
}
canvas.restore();
}
void _drawHandles(Canvas canvas, Rect boundaries) {
final paint = Paint()
..isAntiAlias = true
..color = _kCropHandleColor;
canvas.drawOval(
Rect.fromLTWH(
boundaries.left - _kCropHandleSize / 2,
boundaries.top - _kCropHandleSize / 2,
_kCropHandleSize,
_kCropHandleSize,
),
paint,
);
canvas.drawOval(
Rect.fromLTWH(
boundaries.right - _kCropHandleSize / 2,
boundaries.top - _kCropHandleSize / 2,
_kCropHandleSize,
_kCropHandleSize,
),
paint,
);
canvas.drawOval(
Rect.fromLTWH(
boundaries.right - _kCropHandleSize / 2,
boundaries.bottom - _kCropHandleSize / 2,
_kCropHandleSize,
_kCropHandleSize,
),
paint,
);
canvas.drawOval(
Rect.fromLTWH(
boundaries.left - _kCropHandleSize / 2,
boundaries.bottom - _kCropHandleSize / 2,
_kCropHandleSize,
_kCropHandleSize,
),
paint,
);
}
void _drawGrid(Canvas canvas, Rect boundaries) {
if (active == 0.0) return;
final paint = Paint()
..isAntiAlias = false
..color = _kCropGridColor.withOpacity(_kCropGridColor.opacity * active)
..style = PaintingStyle.stroke
..strokeWidth = 1.0;
final path = Path()
..moveTo(boundaries.left, boundaries.top)
..lineTo(boundaries.right, boundaries.top)
..lineTo(boundaries.right, boundaries.bottom)
..lineTo(boundaries.left, boundaries.bottom)
..lineTo(boundaries.left, boundaries.top);
for (var column = 1; column < _kCropGridColumnCount; column++) {
path
..moveTo(
boundaries.left + column * boundaries.width / _kCropGridColumnCount,
boundaries.top)
..lineTo(
boundaries.left + column * boundaries.width / _kCropGridColumnCount,
boundaries.bottom);
}
for (var row = 1; row < _kCropGridRowCount; row++) {
path
..moveTo(boundaries.left,
boundaries.top + row * boundaries.height / _kCropGridRowCount)
..lineTo(boundaries.right,
boundaries.top + row * boundaries.height / _kCropGridRowCount);
}
canvas.drawPath(path, paint);
}
}
================================================
FILE: lib/src/image_crop.dart
================================================
part of image_crop;
class ImageOptions {
final int width;
final int height;
ImageOptions({
required this.width,
required this.height,
});
@override
int get hashCode => hashValues(width, height);
@override
bool operator ==(other) =>
other is ImageOptions && other.width == width && other.height == height;
@override
String toString() => '$runtimeType(width: $width, height: $height)';
}
class ImageCrop {
static const _channel =
const MethodChannel('plugins.lykhonis.com/image_crop');
static Future<bool> requestPermissions() => _channel
.invokeMethod('requestPermissions')
.then<bool>((result) => result);
static Future<ImageOptions> getImageOptions({
required File file,
}) async {
final result =
await _channel.invokeMethod('getImageOptions', {'path': file.path});
return ImageOptions(
width: result['width'],
height: result['height'],
);
}
static Future<File> cropImage({
required File file,
required Rect area,
double? scale,
}) =>
_channel.invokeMethod('cropImage', {
'path': file.path,
'left': area.left,
'top': area.top,
'right': area.right,
'bottom': area.bottom,
'scale': scale ?? 1.0,
}).then<File>((result) => File(result));
static Future<File> sampleImage({
required File file,
int? preferredSize,
int? preferredWidth,
int? preferredHeight,
}) async {
assert(() {
if (preferredSize == null &&
(preferredWidth == null || preferredHeight == null)) {
throw ArgumentError(
'Preferred size or both width and height of a resampled image must be specified.');
}
return true;
}());
final String path = await _channel.invokeMethod('sampleImage', {
'path': file.path,
'maximumWidth': preferredSize ?? preferredWidth,
'maximumHeight': preferredSize ?? preferredHeight,
});
return File(path);
}
}
================================================
FILE: pubspec.yaml
================================================
name: image_crop
description: A flutter plugin to crop image on iOS and Android. It processes image files off main thread natively. The plugin provides a Crop widget to display image cropping to a user.
version: 0.4.1
homepage: https://github.com/VolodymyrLykhonis/image_crop
environment:
sdk: ">=2.17.0 <3.0.0"
flutter: ">=2.5.0"
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
plugin:
platforms:
android:
package: com.lykhonis.imagecrop
pluginClass: ImageCropPlugin
ios:
pluginClass: ImageCropPlugin
gitextract_s2uz68ra/ ├── .github/ │ └── FUNDING.yml ├── .gitignore ├── .vscode/ │ └── launch.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── RELEASE.md ├── android/ │ ├── .gitignore │ ├── build.gradle │ ├── gradle/ │ │ └── wrapper/ │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradle.properties │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ └── java/ │ └── com/ │ └── lykhonis/ │ └── imagecrop/ │ └── ImageCropPlugin.java ├── example/ │ ├── .gitignore │ ├── README.md │ ├── android/ │ │ ├── app/ │ │ │ ├── build.gradle │ │ │ └── src/ │ │ │ └── main/ │ │ │ ├── AndroidManifest.xml │ │ │ ├── java/ │ │ │ │ └── com/ │ │ │ │ └── lykhonis/ │ │ │ │ └── imagecropexample/ │ │ │ │ └── MainActivity.java │ │ │ └── res/ │ │ │ ├── drawable/ │ │ │ │ └── launch_background.xml │ │ │ └── values/ │ │ │ └── styles.xml │ │ ├── build.gradle │ │ ├── gradle/ │ │ │ └── wrapper/ │ │ │ └── gradle-wrapper.properties │ │ ├── gradle.properties │ │ └── settings.gradle │ ├── ios/ │ │ ├── Flutter/ │ │ │ ├── .last_build_id │ │ │ ├── AppFrameworkInfo.plist │ │ │ ├── Debug.xcconfig │ │ │ ├── Flutter.podspec │ │ │ └── Release.xcconfig │ │ ├── Podfile │ │ ├── Runner/ │ │ │ ├── AppDelegate.h │ │ │ ├── AppDelegate.m │ │ │ ├── Assets.xcassets/ │ │ │ │ ├── AppIcon.appiconset/ │ │ │ │ │ └── Contents.json │ │ │ │ └── LaunchImage.imageset/ │ │ │ │ ├── Contents.json │ │ │ │ └── README.md │ │ │ ├── Base.lproj/ │ │ │ │ ├── LaunchScreen.storyboard │ │ │ │ └── Main.storyboard │ │ │ ├── Info.plist │ │ │ └── main.m │ │ ├── Runner.xcodeproj/ │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace/ │ │ │ │ └── contents.xcworkspacedata.xml │ │ │ └── xcshareddata/ │ │ │ └── xcschemes/ │ │ │ └── Runner.xcscheme.xml │ │ └── Runner.xcworkspace/ │ │ ├── contents.xcworkspacedata │ │ ├── contents.xcworkspacedata.xml │ │ └── xcshareddata/ │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings.xml │ ├── lib/ │ │ └── main.dart │ └── pubspec.yaml ├── ios/ │ ├── .gitignore │ ├── Assets/ │ │ └── .gitkeep │ ├── Classes/ │ │ ├── ImageCropPlugin.h │ │ └── ImageCropPlugin.m │ └── image_crop.podspec ├── lib/ │ ├── image_crop.dart │ └── src/ │ ├── crop.dart │ └── image_crop.dart └── pubspec.yaml
SYMBOL INDEX (81 symbols across 5 files)
FILE: android/src/main/java/com/lykhonis/imagecrop/ImageCropPlugin.java
class ImageCropPlugin (line 44) | public final class ImageCropPlugin implements FlutterPlugin , ActivityAw...
method ImageCropPlugin (line 54) | private ImageCropPlugin(Activity activity) {
method ImageCropPlugin (line 58) | public ImageCropPlugin(){ }
method registerWith (line 63) | public static void registerWith(Registrar registrar) {
method onAttachedToEngine (line 69) | @Override
method onDetachedFromEngine (line 74) | @Override
method onAttachedToActivity (line 80) | @Override
method onDetachedFromActivity (line 87) | @Override
method onReattachedToActivityForConfigChanges (line 95) | @Override
method onDetachedFromActivityForConfigChanges (line 100) | @Override
method setup (line 105) | private void setup(BinaryMessenger messenger) {
method onMethodCall (line 111) | @SuppressWarnings("ConstantConditions")
method io (line 138) | private synchronized void io(@NonNull Runnable runnable) {
method ui (line 145) | private void ui(@NonNull Runnable runnable) {
method cropImage (line 149) | private void cropImage(final String path, final RectF area, final floa...
method sampleImage (line 241) | private void sampleImage(final String path, final int maximumWidth, fi...
method compressBitmap (line 303) | @SuppressWarnings("TryFinallyCanBeTryWithResources")
method calculateInSampleSize (line 319) | private int calculateInSampleSize(int width, int height, int maximumWi...
method getImageOptions (line 334) | private void getImageOptions(final String path, final Result result) {
method requestPermissions (line 359) | private void requestPermissions(Result result) {
method onRequestPermissionsResult (line 373) | @Override
method getPermissionGrantResult (line 385) | private int getPermissionGrantResult(String permission, String[] permi...
method createTemporaryImageFile (line 394) | private File createTemporaryImageFile() throws IOException {
method decodeImageOptions (line 400) | private ImageOptions decodeImageOptions(String path) {
method copyExif (line 414) | private void copyExif(File source, File destination) {
class ImageOptions (line 454) | private static final class ImageOptions {
method ImageOptions (line 459) | ImageOptions(int width, int height, int degrees) {
method getHeight (line 465) | int getHeight() {
method getWidth (line 469) | int getWidth() {
method getDegrees (line 473) | int getDegrees() {
method isFlippedDimensions (line 477) | boolean isFlippedDimensions() {
method isRotated (line 481) | public boolean isRotated() {
FILE: example/android/app/src/main/java/com/lykhonis/imagecropexample/MainActivity.java
class MainActivity (line 7) | public class MainActivity extends FlutterActivity {
method onCreate (line 8) | @Override
FILE: example/lib/main.dart
function main (line 9) | void main()
class MyApp (line 20) | class MyApp extends StatefulWidget {
method createState (line 22) | _MyAppState createState()
class _MyAppState (line 25) | class _MyAppState extends State<MyApp> {
method dispose (line 32) | void dispose()
method build (line 40) | Widget build(BuildContext context)
method _buildOpeningImage (line 53) | Widget _buildOpeningImage()
method _buildCroppingImage (line 57) | Widget _buildCroppingImage()
method _buildOpenImage (line 87) | Widget _buildOpenImage()
method _openImage (line 97) | Future<void> _openImage()
method _cropImage (line 114) | Future<void> _cropImage()
FILE: lib/src/crop.dart
type _CropAction (line 13) | enum _CropAction { none, moving, cropping, scaling }
type _CropHandleSide (line 15) | enum _CropHandleSide { none, topLeft, topRight, bottomLeft, bottomRight }
class Crop (line 17) | class Crop extends StatefulWidget {
method createState (line 57) | State<StatefulWidget> createState()
method of (line 59) | CropState? of(BuildContext context)
class CropState (line 63) | class CropState extends State<Crop> with TickerProviderStateMixin, Drag {
method initState (line 106) | void initState()
method dispose (line 118) | void dispose()
method didChangeDependencies (line 130) | void didChangeDependencies()
method didUpdateWidget (line 137) | void didUpdateWidget(Crop oldWidget)
method _getImage (line 159) | void _getImage({bool force = false})
method build (line 177) | Widget build(BuildContext context)
method _activate (line 202) | void _activate()
method _deactivate (line 210) | void _deactivate()
method _getLocalPoint (line 234) | Offset? _getLocalPoint(Offset point)
method _settleAnimationChanged (line 245) | void _settleAnimationChanged()
method _calculateDefaultArea (line 255) | Rect _calculateDefaultArea({
method _updateImage (line 298) | void _updateImage(ImageInfo imageInfo, bool synchronousCall)
method _hitCropHandle (line 335) | _CropHandleSide _hitCropHandle(Offset? localPoint)
method _handleScaleStart (line 387) | void _handleScaleStart(ScaleStartDetails details)
method _getViewInBoundaries (line 397) | Rect _getViewInBoundaries(double scale)
method _handleScaleEnd (line 430) | void _handleScaleEnd(ScaleEndDetails details)
method _updateArea (line 457) | void _updateArea({
method _handleScaleUpdate (line 545) | void _handleScaleUpdate(ScaleUpdateDetails details)
class _CropPainter (line 621) | class _CropPainter extends CustomPainter {
method shouldRepaint (line 639) | bool shouldRepaint(_CropPainter oldDelegate)
method paint (line 649) | void paint(Canvas canvas, Size size)
method _drawHandles (line 714) | void _drawHandles(Canvas canvas, Rect boundaries)
method _drawGrid (line 760) | void _drawGrid(Canvas canvas, Rect boundaries)
FILE: lib/src/image_crop.dart
class ImageOptions (line 3) | class ImageOptions {
method toString (line 20) | String toString()
class ImageCrop (line 23) | class ImageCrop {
method requestPermissions (line 27) | Future<bool> requestPermissions()
method getImageOptions (line 31) | Future<ImageOptions> getImageOptions({
method cropImage (line 43) | Future<File> cropImage({
method sampleImage (line 57) | Future<File> sampleImage({
Condensed preview — 61 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (142K chars).
[
{
"path": ".github/FUNDING.yml",
"chars": 73,
"preview": "# These are supported funding model platforms\n\ngithub: VolodymyrLykhonis\n"
},
{
"path": ".gitignore",
"chars": 163,
"preview": ".DS_Store\n.dart_tool/\n\n.packages\n.pub/\npubspec.lock\n\n.idea/\n*.iml\n\nbuild/\n\nexample/.flutter-plugins-dependencies\nexample"
},
{
"path": ".vscode/launch.json",
"chars": 437,
"preview": "{\n // Use IntelliSense to learn about possible attributes.\n // Hover to view descriptions of existing attributes.\n"
},
{
"path": "CHANGELOG.md",
"chars": 1880,
"preview": "## 0.4.1\n\nCommunity Contributions. Thank you!\n\n* Dart 2.17 #89 (#91)\n* Fixed a few typos (#87)\n* Resolve #40 (#81)\n\n## 0"
},
{
"path": "LICENSE",
"chars": 11347,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 3477,
"preview": "# Image Cropping plugin for Flutter\n\nA flutter plugin to crop image on iOS and Android.\n\n\n jcenter"
},
{
"path": "android/gradle/wrapper/gradle-wrapper.properties",
"chars": 232,
"preview": "#Sat Jun 01 05:18:58 PDT 2019\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "android/gradle.properties",
"chars": 29,
"preview": "org.gradle.jvmargs=-Xmx1536M\n"
},
{
"path": "android/gradlew",
"chars": 5296,
"preview": "#!/usr/bin/env sh\n\n##############################################################################\n##\n## Gradle start up"
},
{
"path": "android/gradlew.bat",
"chars": 2176,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "android/settings.gradle",
"chars": 32,
"preview": "rootProject.name = 'image_crop'\n"
},
{
"path": "android/src/main/AndroidManifest.xml",
"chars": 285,
"preview": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package=\"com.lykhonis.imagecrop\">\n\n <u"
},
{
"path": "android/src/main/java/com/lykhonis/imagecrop/ImageCropPlugin.java",
"chars": 19328,
"preview": "package com.lykhonis.imagecrop;\n\nimport android.app.Activity;\nimport android.content.pm.PackageManager;\nimport android.g"
},
{
"path": "example/.gitignore",
"chars": 1294,
"preview": "# Miscellaneous\n*.class\n*.lock\n*.log\n*.pyc\n*.swp\n.DS_Store\n.atom/\n.buildlog/\n.history\n.svn/\n\n# IntelliJ related\n*.iml\n*."
},
{
"path": "example/README.md",
"chars": 183,
"preview": "# image_crop_example\n\nDemonstrates how to use the image_crop plugin.\n\n## Getting Started\n\nFor help getting started with "
},
{
"path": "example/android/app/build.gradle",
"chars": 1879,
"preview": "def localProperties = new Properties()\ndef localPropertiesFile = rootProject.file('local.properties')\nif (localPropertie"
},
{
"path": "example/android/app/src/main/AndroidManifest.xml",
"chars": 2062,
"preview": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package=\"com.lykhonis.imagecropexample\">\n"
},
{
"path": "example/android/app/src/main/java/com/lykhonis/imagecropexample/MainActivity.java",
"chars": 374,
"preview": "package com.lykhonis.imagecropexample;\n\nimport android.os.Bundle;\nimport io.flutter.app.FlutterActivity;\nimport io.flutt"
},
{
"path": "example/android/app/src/main/res/drawable/launch_background.xml",
"chars": 434,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Modify this file to customize your launch splash screen -->\n<layer-list xmln"
},
{
"path": "example/android/app/src/main/res/values/styles.xml",
"chars": 361,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <style name=\"LaunchTheme\" parent=\"@android:style/Theme.Black.NoTi"
},
{
"path": "example/android/build.gradle",
"chars": 470,
"preview": "buildscript {\n repositories {\n google()\n jcenter()\n }\n\n dependencies {\n classpath 'com.and"
},
{
"path": "example/android/gradle/wrapper/gradle-wrapper.properties",
"chars": 232,
"preview": "#Sat Jun 01 05:20:09 PDT 2019\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "example/android/gradle.properties",
"chars": 29,
"preview": "org.gradle.jvmargs=-Xmx1536M\n"
},
{
"path": "example/android/settings.gradle",
"chars": 484,
"preview": "include ':app'\n\ndef flutterProjectRoot = rootProject.projectDir.parentFile.toPath()\n\ndef plugins = new Properties()\ndef "
},
{
"path": "example/ios/Flutter/.last_build_id",
"chars": 32,
"preview": "96b858413dd1e970b76641c6cef4bcad"
},
{
"path": "example/ios/Flutter/AppFrameworkInfo.plist",
"chars": 773,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "example/ios/Flutter/Debug.xcconfig",
"chars": 106,
"preview": "#include \"Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig\"\n#include \"Generated.xcconfig\"\n"
},
{
"path": "example/ios/Flutter/Flutter.podspec",
"chars": 803,
"preview": "#\n# NOTE: This podspec is NOT to be published. It is only used as a local source!\n# This is a generated file; do n"
},
{
"path": "example/ios/Flutter/Release.xcconfig",
"chars": 108,
"preview": "#include \"Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig\"\n#include \"Generated.xcconfig\"\n"
},
{
"path": "example/ios/Podfile",
"chars": 1312,
"preview": "# Uncomment this line to define a global platform for your project\n# platform :ios, '9.0'\n\n# CocoaPods analytics sends n"
},
{
"path": "example/ios/Runner/AppDelegate.h",
"chars": 103,
"preview": "#import <Flutter/Flutter.h>\n#import <UIKit/UIKit.h>\n\n@interface AppDelegate : FlutterAppDelegate\n\n@end\n"
},
{
"path": "example/ios/Runner/AppDelegate.m",
"chars": 424,
"preview": "#include \"AppDelegate.h\"\n#include \"GeneratedPluginRegistrant.h\"\n\n@implementation AppDelegate\n\n- (BOOL)application:(UIApp"
},
{
"path": "example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json",
"chars": 2519,
"preview": "{\n \"images\" : [\n {\n \"size\" : \"20x20\",\n \"idiom\" : \"iphone\",\n \"filename\" : \"Icon-App-20x20@2x.png\",\n "
},
{
"path": "example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json",
"chars": 391,
"preview": "{\n \"images\" : [\n {\n \"idiom\" : \"universal\",\n \"filename\" : \"LaunchImage.png\",\n \"scale\" : \"1x\"\n },\n "
},
{
"path": "example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md",
"chars": 336,
"preview": "# Launch Screen Assets\n\nYou can customize the launch screen with your own desired assets by replacing the image files in"
},
{
"path": "example/ios/Runner/Base.lproj/LaunchScreen.storyboard",
"chars": 2377,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard"
},
{
"path": "example/ios/Runner/Base.lproj/Main.storyboard",
"chars": 1605,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard"
},
{
"path": "example/ios/Runner/Info.plist",
"chars": 1631,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "example/ios/Runner/main.m",
"chars": 226,
"preview": "#import <Flutter/Flutter.h>\n#import <UIKit/UIKit.h>\n#import \"AppDelegate.h\"\n\nint main(int argc, char* argv[]) {\n @autor"
},
{
"path": "example/ios/Runner.xcodeproj/project.pbxproj",
"chars": 18923,
"preview": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 50;\n\tobjects = {\n\n/* Begin PBXBuildFile section *"
},
{
"path": "example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata.xml",
"chars": 152,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n version = \"1.0\">\n <FileRef\n location = \"group:Runner.xcodepr"
},
{
"path": "example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme.xml",
"chars": 3331,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n LastUpgradeVersion = \"0910\"\n version = \"1.3\">\n <BuildAction\n "
},
{
"path": "example/ios/Runner.xcworkspace/contents.xcworkspacedata",
"chars": 224,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n version = \"1.0\">\n <FileRef\n location = \"group:Runner.xcodepr"
},
{
"path": "example/ios/Runner.xcworkspace/contents.xcworkspacedata.xml",
"chars": 224,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n version = \"1.0\">\n <FileRef\n location = \"group:Runner.xcodepr"
},
{
"path": "example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
"chars": 238,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings.xml",
"chars": 243,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "example/lib/main.dart",
"chars": 3469,
"preview": "import 'dart:io';\nimport 'dart:async';\n\nimport 'package:flutter/material.dart';\nimport 'package:flutter/services.dart';\n"
},
{
"path": "example/pubspec.yaml",
"chars": 363,
"preview": "name: image_crop_example\ndescription: Demonstrates how to use the image_crop plugin.\n\nversion: 1.0.0+1\n\nenvironment:\n s"
},
{
"path": "ios/.gitignore",
"chars": 360,
"preview": ".idea/\n.vagrant/\n.sconsign.dblite\n.svn/\n\n.DS_Store\n*.swp\nprofile\n\nDerivedData/\nbuild/\nGeneratedPluginRegistrant.h\nGenera"
},
{
"path": "ios/Assets/.gitkeep",
"chars": 0,
"preview": ""
},
{
"path": "ios/Classes/ImageCropPlugin.h",
"chars": 87,
"preview": "#import <Flutter/Flutter.h>\n\n@interface ImageCropPlugin : NSObject<FlutterPlugin>\n@end\n"
},
{
"path": "ios/Classes/ImageCropPlugin.m",
"chars": 11456,
"preview": "#import \"ImageCropPlugin.h\"\n\n#import <Photos/Photos.h>\n#import <MobileCoreServices/MobileCoreServices.h>\n\n@implementatio"
},
{
"path": "ios/image_crop.podspec",
"chars": 704,
"preview": "#\n# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html\n#\nPod::Spec.new do |s|\n s.name "
},
{
"path": "lib/image_crop.dart",
"chars": 275,
"preview": "library image_crop;\n\nimport 'dart:async';\nimport 'dart:io';\nimport 'dart:math';\nimport 'dart:ui' as ui;\n\nimport 'package"
},
{
"path": "lib/src/crop.dart",
"chars": 21849,
"preview": "part of image_crop;\n\nconst _kCropGridColumnCount = 3;\nconst _kCropGridRowCount = 3;\nconst _kCropGridColor = Color.fromRG"
},
{
"path": "lib/src/image_crop.dart",
"chars": 1992,
"preview": "part of image_crop;\n\nclass ImageOptions {\n final int width;\n final int height;\n\n ImageOptions({\n required this.wid"
},
{
"path": "pubspec.yaml",
"chars": 606,
"preview": "name: image_crop\ndescription: A flutter plugin to crop image on iOS and Android. It processes image files off main threa"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the lykhonis/image_crop GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 61 files (128.0 KB), approximately 34.5k tokens, and a symbol index with 81 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.