├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md.dart
│ └── feature_request.md.dart
└── pull_request_template.md
├── .gitignore
├── .metadata
├── CHANGELOG.md
├── LICENSE
├── README.md
├── analysis_options.yaml
├── android
├── .gitignore
├── build.gradle
├── settings.gradle
└── src
│ ├── main
│ ├── AndroidManifest.xml
│ └── kotlin
│ │ └── com
│ │ └── example
│ │ └── fast_image_compress
│ │ ├── Constants.kt
│ │ └── FastImageCompressPlugin.kt
│ └── test
│ └── kotlin
│ └── com
│ └── example
│ └── fast_image_compress
│ └── FastImageCompressPluginTest.kt
├── example
├── .gitignore
├── README.md
├── analysis_options.yaml
├── android
│ ├── .gitignore
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── kotlin
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── fast_image_compress_example
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── res
│ │ │ │ ├── drawable-v21
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── drawable
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── values-night
│ │ │ │ └── styles.xml
│ │ │ │ └── values
│ │ │ │ └── styles.xml
│ │ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ └── settings.gradle
├── integration_test
│ └── plugin_integration_test.dart
├── ios
│ ├── .gitignore
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Podfile
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ ├── Runner
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ │ ├── Icon-App-20x20@1x.png
│ │ │ │ ├── Icon-App-20x20@2x.png
│ │ │ │ ├── Icon-App-20x20@3x.png
│ │ │ │ ├── Icon-App-29x29@1x.png
│ │ │ │ ├── Icon-App-29x29@2x.png
│ │ │ │ ├── Icon-App-29x29@3x.png
│ │ │ │ ├── Icon-App-40x40@1x.png
│ │ │ │ ├── Icon-App-40x40@2x.png
│ │ │ │ ├── Icon-App-40x40@3x.png
│ │ │ │ ├── Icon-App-60x60@2x.png
│ │ │ │ ├── Icon-App-60x60@3x.png
│ │ │ │ ├── Icon-App-76x76@1x.png
│ │ │ │ ├── Icon-App-76x76@2x.png
│ │ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ │ └── LaunchImage.imageset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── LaunchImage.png
│ │ │ │ ├── LaunchImage@2x.png
│ │ │ │ ├── LaunchImage@3x.png
│ │ │ │ └── README.md
│ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── Runner-Bridging-Header.h
│ └── RunnerTests
│ │ └── RunnerTests.swift
├── lib
│ └── main.dart
├── pubspec.lock
├── pubspec.yaml
└── test
│ └── widget_test.dart
├── ios
├── .gitignore
├── Classes
│ └── FastImageCompressPlugin.swift
└── fast_image_compress.podspec
├── lib
├── fast_image_compress.dart
├── src
│ ├── fast_image_compress.dart
│ ├── fast_image_compress
│ │ ├── fast_image_compress_method_channel.dart
│ │ └── fast_image_compress_platform_interface.dart
│ └── image_compression_service.dart
└── values
│ └── constants.dart
├── preview
├── android_comparison_graph.png
├── banner.png
└── iOS_comparison_graph.png
└── pubspec.yaml
/.github/ISSUE_TEMPLATE/bug_report.md.dart:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md.dart:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | # Description
2 |
8 |
9 |
10 | ## Checklist
11 |
15 |
16 | - [ ] The title of my PR starts with a [Conventional Commit] prefix (`fix:`, `feat:`, `docs:` etc).
17 | - [ ] I have followed the [Contributor Guide] when preparing my PR.
18 | - [ ] I have updated/added tests for ALL new/updated/fixed functionality.
19 | - [ ] I have updated/added relevant documentation in `docs` and added dartdoc comments with `///`.
20 | - [ ] I have updated/added relevant examples in `examples` or `docs`.
21 |
22 |
23 | ## Breaking Change?
24 |
36 |
37 | - [ ] Yes, this PR is a breaking change.
38 | - [ ] No, this PR is not a breaking change.
39 |
40 |
41 | ## Related Issues
42 |
46 |
47 |
48 | [Conventional Commit]: https://conventionalcommits.org
49 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 | migrate_working_dir/
12 |
13 | # IntelliJ related
14 | *.iml
15 | *.ipr
16 | *.iws
17 | .idea/
18 |
19 | # The .vscode folder contains launch configuration and tasks you configure in
20 | # VS Code which you may wish to be included in version control, so this line
21 | # is commented out by default.
22 | #.vscode/
23 |
24 | # Flutter/Dart/Pub related
25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26 | /pubspec.lock
27 | **/doc/api/
28 | .dart_tool/
29 | build/
30 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: "2663184aa79047d0a33a14a3b607954f8fdd8730"
8 | channel: "stable"
9 |
10 | project_type: plugin
11 |
12 | # Tracks metadata for the flutter migrate command
13 | migration:
14 | platforms:
15 | - platform: root
16 | create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
17 | base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
18 | - platform: android
19 | create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
20 | base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
21 | - platform: ios
22 | create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
23 | base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
24 |
25 | # User provided section
26 |
27 | # List of Local paths (relative to this file) that should be
28 | # ignored by the migrate tool.
29 | #
30 | # Files that are not part of the templates will be ignored by default.
31 | unmanaged_files:
32 | - 'lib/main.dart'
33 | - 'ios/Runner.xcodeproj/project.pbxproj'
34 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [0.0.3]
2 |
3 | * Updated readme
4 |
5 | ## [0.0.2]
6 |
7 | * Updated readme
8 |
9 | ## [0.0.1] - Initial release
10 |
11 | * First release
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Simform Solutions
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 |
4 | # fast_image_compress
5 |
6 | [](https://pub.dartlang.org/packages/fast_image_compress)
7 | [](https://github.com/SimformSolutionsPvtLtd/fast_image_compress/blob/master/LICENSE)
8 |
9 | A Flutter plugin that allows you to compress images easily and quickly.
10 |
11 | ## Features
12 |
13 | Fast Image Compress can do much more (and we are just getting started)
14 |
15 | - 📱 **Supported platform**. iOS, Android
16 | - 🧪 **Batch processing**. Support batch processing using batchSize
17 | - 🖼️ **Supported image types** jpeg, png and heic
18 | - ⏱ **Parallelism**. Support parallel image compression
19 |
20 | ## Why fast_image_compress
21 |
22 | The following bar graph demonstrates the efficiency of our plugin compared to two other existing packages.
23 | The comparison was conducted by compressing one image at a time for various image sizes, measuring the time taken in milliseconds (Y-axis) against the image size in MB (X-axis).
24 |
25 | Below are the comparison graphs:
26 |
27 | Android | iOS
28 | :-------------------------:|:-------------------------:
29 |
|
30 |
31 | This visual representation highlights the better performance of our plugin in terms of compression speed and efficiency across different image sizes.
32 |
33 | ## Installing
34 |
35 | 1. Add dependency to `pubspec.yaml`
36 |
37 | ```dart
38 | dependencies:
39 | fast_image_compress:
40 | ```
41 | or run this command:
42 |
43 | ```bash
44 | flutter pub add fast_image_compress
45 | ```
46 |
47 | 2. Import the package
48 | ```dart
49 | import 'package:fast_image_compress/fast_image_compress.dart';
50 | ```
51 |
52 | Use as:
53 |
54 | [See full example](https://github.com/SimformSolutionsPvtLtd/fast_image_compress/blob/master/example/lib/main.dart)
55 |
56 | There are several ways to use the library api.
57 |
58 | ```dart
59 |
60 | // 1. Compress an image and get Uint8List
61 | Future compressImage(Uint8List imageData) async {
62 | final compressedImage = await fastImageCompress.compressImage(
63 | imageData: imageData,
64 | quality: 60,
65 | targetWidth: 400,
66 | imageQuality: ImageQuality.low,
67 | );
68 | return compressedImage;
69 | }
70 |
71 | // 2. Compress list of images and get a list of Uint8List
72 | Future> compressMultipleImages(List imageList) async {
73 | final result = await fastImageCompress.compressImageList(
74 | images: imageList,
75 | quality: 30,
76 | targetWidth: 800,
77 | batchSize: 3,
78 | imageQuality: ImageQuality.low,
79 | );
80 | return result;
81 | }
82 |
83 | // 3. Cancel the compression process
84 | Future _cancelCompression() async {
85 | await fastImageCompress.cancelCompression();
86 | }
87 |
88 | ```
89 | ## Parameters of `compressImage` function:
90 |
91 | | Parameter Name | Data type | Default Value | Description |
92 | |----------------|--------------|---------------------|-----------------------------------------------------|
93 | | imageData | Uint8List | - | The image to be compressed |
94 | | quality | int | 60 | The compression quality percentage |
95 | | targetWidth | int? | null | The desired width for the compressed image |
96 | | imageQuality | ImageQuality | ImageQuality.medium | The quality of the image to store after compression |
97 |
98 | ## Parameters of `compressImage` function:
99 |
100 | | Parameter Name | Data type | Default Value | Description |
101 | |----------------|--------------|---------------------|-----------------------------------------------------------|
102 | | imageData | Uint8List | - | The image to be compressed |
103 | | quality | int | 60 | The compression quality percentage |
104 | | targetWidth | int? | null | The desired width for the compressed image |
105 | | imageQuality | ImageQuality | ImageQuality.medium | The quality of the image to store after compression |
106 | | batchSize | int | 3 | The number of images to process simultaneously in a batch |
107 |
108 | ## About params
109 |
110 | ### targetWidth
111 |
112 | The `targetWidth` parameter allows you to resize the images to a specific width.
113 |
114 | Use this parameter when you need all images to have a uniform width. It is particularly useful for optimizing image processing performance.
115 | Recommended to use this parameter when image size or image width is large.
116 | ### batchSize
117 |
118 | The `batchSize` parameter determines how many images are processed in a single batch.
119 |
120 | - If the image sizes are large (greater than 50 MB), set batchSize to a smaller value to avoid memory issues.
121 | - If the image sizes are small, you can set a higher value (e.g., 6) for better performance.
122 |
123 | To dynamically adjust batchSize based on the number of CPU threads available on the device, you can use the following code:
124 | ```dart
125 | final maxAvailableCPUThreads = Platform.numberOfProcessors;
126 | final batchSize = maxAvailableCPUThreads > 0 ? maxAvailableCPUThreads ~/ 2 : 1;
127 | ```
128 | ### imageQuality
129 |
130 | The `imageQuality` parameter controls the quality of the processed images. It has three predefined values:
131 | - low
132 | - medium (default)
133 | - high
134 |
135 | ## Android
136 |
137 | You may need to update Kotlin to version `1.5.20` or higher.
138 |
139 | ## About EXIF information
140 |
141 | Using this library, the image orientation is maintained.
142 |
143 | #### HEIF(Heic)
144 |
145 | ##### Heif on iOS
146 |
147 | Only support iOS 11+.
148 |
149 | ##### Heif on Android
150 |
151 | Only support API 28+.
152 |
153 | Note: Requires hardware encoder support, so availability is not guaranteed on all devices running API 28 or higher.
154 | ## Main Contributors
155 |
156 |
161 |
162 | ## License
163 |
164 | ```
165 | MIT License
166 |
167 | Copyright (c) 2021 Simform Solutions
168 |
169 | Permission is hereby granted, free of charge, to any person obtaining a copy
170 | of this software and associated documentation files (the "Software"), to deal
171 | in the Software without restriction, including without limitation the rights
172 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
173 | copies of the Software, and to permit persons to whom the Software is
174 | furnished to do so, subject to the following conditions:
175 |
176 | The above copyright notice and this permission notice shall be included in all
177 | copies or substantial portions of the Software.
178 |
179 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
180 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
181 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
182 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
183 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
184 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
185 | SOFTWARE.
186 | ```
187 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | include: package:flutter_lints/flutter.yaml
2 |
3 | # Additional information about this file can be found at
4 | # https://dart.dev/guides/language/analysis-options
5 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .cxx
10 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | group = "com.example.fast_image_compress"
2 | version = "1.0-SNAPSHOT"
3 |
4 | buildscript {
5 | ext.kotlin_version = "1.5.20"
6 | repositories {
7 | google()
8 | mavenCentral()
9 | }
10 |
11 | dependencies {
12 | classpath("com.android.tools.build:gradle:8.1.0")
13 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | mavenCentral()
21 | }
22 | }
23 |
24 | apply plugin: "com.android.library"
25 | apply plugin: "kotlin-android"
26 |
27 | android {
28 | if (project.android.hasProperty("namespace")) {
29 | namespace = "com.example.fast_image_compress"
30 | }
31 |
32 | compileSdk = 34
33 |
34 | compileOptions {
35 | sourceCompatibility = JavaVersion.VERSION_1_8
36 | targetCompatibility = JavaVersion.VERSION_1_8
37 | }
38 |
39 | kotlinOptions {
40 | jvmTarget = JavaVersion.VERSION_1_8
41 | }
42 |
43 | sourceSets {
44 | main.java.srcDirs += "src/main/kotlin"
45 | test.java.srcDirs += "src/test/kotlin"
46 | }
47 |
48 | defaultConfig {
49 | minSdk = 21
50 | }
51 |
52 | dependencies {
53 | testImplementation("org.jetbrains.kotlin:kotlin-test")
54 | testImplementation("org.mockito:mockito-core:5.0.0")
55 | // Added dependencies for image processing and EXIF support
56 | implementation("androidx.exifinterface:exifinterface:1.3.7")
57 | }
58 |
59 | testOptions {
60 | unitTests.all {
61 | useJUnitPlatform()
62 |
63 | testLogging {
64 | events "passed", "skipped", "failed", "standardOut", "standardError"
65 | outputs.upToDateWhen {false}
66 | showStandardStreams = true
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'fast_image_compress'
2 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/android/src/main/kotlin/com/example/fast_image_compress/Constants.kt:
--------------------------------------------------------------------------------
1 | object Constants {
2 | const val METHOD_CHANNEL_NAME: String = "com.simform.fast_image_compress/compression"
3 | const val COMPRESSION_METHOD_NAME: String = "compressImage"
4 | const val CANCEL_COMPRESSION_METHOD_NAME: String = "cancelCompression"
5 | const val IMAGE_DATA: String = "imageData"
6 | const val TARGET_WIDTH: String = "targetWidth"
7 | const val COMPRESSION_QUALITY: String = "compressionQuality"
8 | const val IMAGE_QUALITY: String = "imageQuality"
9 | const val IMAGE_QUALITY_HIGH: String = "high"
10 | const val IMAGE_QUALITY_LOW: String = "low"
11 | const val IMAGE_QUALITY_MEDIUM: String = "medium"
12 | }
13 |
--------------------------------------------------------------------------------
/android/src/main/kotlin/com/example/fast_image_compress/FastImageCompressPlugin.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Simform Solutions
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be
12 | * included in all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | package com.example.fast_image_compress
24 |
25 | import Constants
26 | import android.graphics.Bitmap
27 | import android.graphics.BitmapFactory
28 | import android.graphics.Matrix
29 | import android.media.ExifInterface
30 | import android.os.Build
31 | import androidx.annotation.RequiresApi
32 | import io.flutter.embedding.engine.plugins.FlutterPlugin
33 | import io.flutter.plugin.common.MethodCall
34 | import io.flutter.plugin.common.MethodChannel
35 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler
36 | import io.flutter.plugin.common.MethodChannel.Result
37 | import java.io.ByteArrayInputStream
38 | import java.io.ByteArrayOutputStream
39 |
40 | /** FastImageCompressPlugin */
41 |
42 | enum class ImageQuality(val sampleSize: Int) {
43 | HIGH(8), MEDIUM(4), LOW(2)
44 | }
45 |
46 | class FastImageCompressPlugin: FlutterPlugin, MethodCallHandler {
47 |
48 | // MethodChannel for communication between Flutter and native Android
49 | private lateinit var channel: MethodChannel
50 | private var inputImageSize: Int = 0
51 |
52 | // Flag to handle cancellation of image compression
53 | @Volatile
54 | private var isCancelled = false
55 |
56 | // Called when the plugin is attached to the Flutter engine
57 | override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
58 | channel = MethodChannel(flutterPluginBinding.binaryMessenger, Constants.METHOD_CHANNEL_NAME)
59 | channel.setMethodCallHandler(this)
60 | }
61 |
62 | // Handles incoming method calls from Flutter
63 | @RequiresApi(Build.VERSION_CODES.N)
64 | override fun onMethodCall(call: MethodCall, result: Result) {
65 | if (call.method == Constants.COMPRESSION_METHOD_NAME) {
66 | // Retrieve arguments from the method call
67 | val byteArray = call.argument(Constants.IMAGE_DATA)
68 | val targetWidth = call.argument(Constants.TARGET_WIDTH)
69 | val compressionQuality = call.argument(Constants.COMPRESSION_QUALITY)
70 | val imageQualityInString = call.argument(Constants.IMAGE_QUALITY)
71 |
72 | // Determine the image quality based on the input string
73 | val imageQuality =
74 | if (imageQualityInString == Constants.IMAGE_QUALITY_HIGH) ImageQuality.HIGH
75 | else if (imageQualityInString == Constants.IMAGE_QUALITY_LOW) ImageQuality.LOW
76 | else ImageQuality.MEDIUM
77 |
78 | if (byteArray != null) {
79 | try {
80 | val options = BitmapFactory.Options()
81 | // Only fetches the image dimensions, doesn't load the image into memory
82 | options.inJustDecodeBounds = true
83 | BitmapFactory.decodeByteArray(byteArray, 0, byteArray.size, options)
84 | inputImageSize = byteArray.size
85 |
86 | // Calculate the sampling size for image decoding
87 | options.inSampleSize =
88 | calculateInSampleSize(options, targetWidth, imageQuality, compressionQuality)
89 | // Decodes the image fully with the calculated sample size
90 | options.inJustDecodeBounds = false
91 |
92 | // Decode the image into a Bitmap
93 | var bitmap =
94 | BitmapFactory.decodeByteArray(byteArray, 0, byteArray.size, options)
95 |
96 | // Handle cancellation
97 | if (isCancelled) {
98 | bitmap.recycle()
99 | result.error("CANCELLED", "Compression cancelled by user", null)
100 | return
101 | }
102 |
103 | // Read the image's EXIF data to handle orientation
104 | val exif = ExifInterface(ByteArrayInputStream(byteArray))
105 | val orientation = exif.getAttributeInt(
106 | ExifInterface.TAG_ORIENTATION,
107 | ExifInterface.ORIENTATION_NORMAL
108 | )
109 | val correctedBitmap = applyExifOrientation(bitmap, orientation)
110 |
111 | // Handle cancellation after EXIF correction
112 | if (isCancelled) {
113 | bitmap.recycle()
114 | result.error("CANCELLED", "Compression cancelled by user", null)
115 | return
116 | }
117 | val resizedBitmap = resizeBitmap(correctedBitmap, targetWidth)
118 |
119 | // Compress the image and convert it to a byte array
120 | val compressedBytes = bitmapToByteArray(resizedBitmap, compressionQuality)
121 | if (compressedBytes == null) {
122 | // Return the original image if compression fails or when compressed image
123 | // is larger than original image
124 | result.success(byteArray)
125 | } else {
126 | // Return the compressed image
127 | result.success(compressedBytes)
128 | }
129 |
130 | // Clean up resources
131 | correctedBitmap.recycle()
132 | resizedBitmap.recycle()
133 | bitmap.recycle()
134 |
135 | } catch (e: Exception) {
136 | // Handle any errors during image processing
137 | result.error(
138 | "DECODE_ERROR",
139 | "Error during image processing: ${e.message}",
140 | null
141 | )
142 | }
143 | }
144 | } else if (call.method == Constants.CANCEL_COMPRESSION_METHOD_NAME) {
145 | // Handle cancellation request
146 | isCancelled = true
147 | result.success(null)
148 | isCancelled = false
149 | } else {
150 | // Handle unimplemented methods
151 | result.notImplemented()
152 | }
153 | }
154 |
155 | // Called when the plugin is detached from the Flutter engine
156 | override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
157 | channel.setMethodCallHandler(null)
158 | }
159 |
160 | // Calculate the sampling size for image decoding based on target width or quality
161 | private fun calculateInSampleSize(
162 | options: BitmapFactory.Options,
163 | reqWidth: Int?,
164 | imageQuality: ImageQuality = ImageQuality.MEDIUM,
165 | compressionQuality: Int?,
166 | ): Int {
167 | val (width: Int, height: Int) = options.run { outWidth to outHeight }
168 | var inSampleSize = 1
169 | if (reqWidth != null) {
170 | if (width > reqWidth) {
171 | val factor = imageQuality.sampleSize
172 | val adjustedWidth: Int = width / factor
173 | while (adjustedWidth / inSampleSize >= reqWidth) {
174 | inSampleSize *= 2
175 | }
176 | }
177 | } else {
178 | val quality = compressionQuality ?: 80
179 | val sampleSize = (100 - quality) / 100
180 | inSampleSize = if (sampleSize < 2) 2 else sampleSize
181 | }
182 | return inSampleSize
183 | }
184 |
185 | // Compress a Bitmap into a byte array
186 | private fun bitmapToByteArray(bitmap: Bitmap, compressionQuality: Int? = 80): ByteArray? {
187 | val quality = compressionQuality ?: 80
188 | val stream = ByteArrayOutputStream()
189 | bitmap.compress(Bitmap.CompressFormat.JPEG, quality, stream)
190 | var outputImageSize = stream.toByteArray().size
191 |
192 | // To avoid increasing the size of an already compressed image, compare
193 | // input and output sizes, and use lower compression quality if needed.
194 | if (outputImageSize > inputImageSize) {
195 | var updatedCompQuality = quality;
196 | while (outputImageSize > inputImageSize && updatedCompQuality >= 10) {
197 | bitmap.compress(Bitmap.CompressFormat.JPEG, updatedCompQuality, stream)
198 | updatedCompQuality = updatedCompQuality - 10;
199 | outputImageSize = stream.toByteArray().size;
200 | }
201 | if (updatedCompQuality >= 10) {
202 | return stream.toByteArray()
203 | } else {
204 | return null
205 | }
206 | }
207 | return stream.toByteArray()
208 | }
209 |
210 | // Apply EXIF orientation to a Bitmap
211 | private fun applyExifOrientation(bitmap: Bitmap, orientation: Int): Bitmap {
212 | val matrix = Matrix()
213 | when (orientation) {
214 | ExifInterface.ORIENTATION_ROTATE_90 -> matrix.postRotate(90f)
215 | ExifInterface.ORIENTATION_ROTATE_180 -> matrix.postRotate(180f)
216 | ExifInterface.ORIENTATION_ROTATE_270 -> matrix.postRotate(270f)
217 | ExifInterface.ORIENTATION_FLIP_HORIZONTAL -> matrix.postScale(-1f, 1f)
218 | ExifInterface.ORIENTATION_FLIP_VERTICAL -> matrix.postScale(1f, -1f)
219 | }
220 | return Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true)
221 | }
222 |
223 | private fun resizeBitmap(bitmap: Bitmap, targetWidth: Int?): Bitmap {
224 | if (targetWidth == null || bitmap.width <= targetWidth) {
225 | return bitmap
226 | }
227 | val scale = targetWidth.toFloat() / bitmap.width
228 | val targetHeight = (bitmap.height * scale).toInt()
229 | return Bitmap.createScaledBitmap(bitmap, targetWidth, targetHeight, true)
230 | }
231 | }
232 |
--------------------------------------------------------------------------------
/android/src/test/kotlin/com/example/fast_image_compress/FastImageCompressPluginTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.fast_image_compress
2 |
3 | import io.flutter.plugin.common.MethodCall
4 | import io.flutter.plugin.common.MethodChannel
5 | import kotlin.test.Test
6 | import org.mockito.Mockito
7 |
8 | /*
9 | * This demonstrates a simple unit test of the Kotlin portion of this plugin's implementation.
10 | *
11 | * Once you have built the plugin's example app, you can run these tests from the command
12 | * line by running `./gradlew testDebugUnitTest` in the `example/android/` directory, or
13 | * you can run them directly from IDEs that support JUnit such as Android Studio.
14 | */
15 |
16 | internal class FastImageCompressPluginTest {
17 | @Test
18 | fun onMethodCall_getPlatformVersion_returnsExpectedValue() {
19 | val plugin = FastImageCompressPlugin()
20 |
21 | val call = MethodCall("getPlatformVersion", null)
22 | val mockResult: MethodChannel.Result = Mockito.mock(MethodChannel.Result::class.java)
23 | plugin.onMethodCall(call, mockResult)
24 |
25 | Mockito.verify(mockResult).success("Android " + android.os.Build.VERSION.RELEASE)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 | migrate_working_dir/
12 |
13 | # IntelliJ related
14 | *.iml
15 | *.ipr
16 | *.iws
17 | .idea/
18 |
19 | # The .vscode folder contains launch configuration and tasks you configure in
20 | # VS Code which you may wish to be included in version control, so this line
21 | # is commented out by default.
22 | #.vscode/
23 |
24 | # Flutter/Dart/Pub related
25 | **/doc/api/
26 | **/ios/Flutter/.last_build_id
27 | .dart_tool/
28 | .flutter-plugins
29 | .flutter-plugins-dependencies
30 | .pub-cache/
31 | .pub/
32 | /build/
33 |
34 | # Symbolication related
35 | app.*.symbols
36 |
37 | # Obfuscation related
38 | app.*.map.json
39 |
40 | # Android Studio will place build artifacts here
41 | /android/app/debug
42 | /android/app/profile
43 | /android/app/release
44 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # fast_image_compress_example
2 |
3 | Demonstrates how to use the fast_image_compress plugin.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13 |
14 | For help getting started with Flutter development, view the
15 | [online documentation](https://docs.flutter.dev/), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/example/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at https://dart.dev/lints.
17 | #
18 | # Instead of disabling a lint rule for the entire project in the
19 | # section below, it can also be suppressed for a single line of code
20 | # or a specific dart file by using the `// ignore: name_of_lint` and
21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
22 | # producing the lint.
23 | rules:
24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
26 |
27 | # Additional information about this file can be found at
28 | # https://dart.dev/guides/language/analysis-options
29 |
--------------------------------------------------------------------------------
/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
9 | # Remember to never publicly share your keystore.
10 | # See https://flutter.dev/to/reference-keystore
11 | key.properties
12 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id "com.android.application"
3 | id "kotlin-android"
4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
5 | id "dev.flutter.flutter-gradle-plugin"
6 | }
7 |
8 | android {
9 | namespace = "com.example.fast_image_compress_example"
10 | compileSdk = flutter.compileSdkVersion
11 | ndkVersion = flutter.ndkVersion
12 |
13 | compileOptions {
14 | sourceCompatibility = JavaVersion.VERSION_1_8
15 | targetCompatibility = JavaVersion.VERSION_1_8
16 | }
17 |
18 | kotlinOptions {
19 | jvmTarget = JavaVersion.VERSION_1_8
20 | }
21 |
22 | defaultConfig {
23 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
24 | applicationId = "com.example.fast_image_compress_example"
25 | // You can update the following values to match your application needs.
26 | // For more information, see: https://flutter.dev/to/review-gradle-config.
27 | minSdk = flutter.minSdkVersion
28 | targetSdk = flutter.targetSdkVersion
29 | versionCode = flutter.versionCode
30 | versionName = flutter.versionName
31 | }
32 |
33 | buildTypes {
34 | release {
35 | // TODO: Add your own signing config for the release build.
36 | // Signing with the debug keys for now, so `flutter run --release` works.
37 | signingConfig = signingConfigs.debug
38 | }
39 | }
40 | }
41 |
42 | flutter {
43 | source = "../.."
44 | }
45 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
15 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
33 |
34 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/example/android/app/src/main/kotlin/com/example/fast_image_compress_example/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.fast_image_compress_example
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity()
6 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | allprojects {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | }
6 | }
7 |
8 | rootProject.buildDir = "../build"
9 | subprojects {
10 | project.buildDir = "${rootProject.buildDir}/${project.name}"
11 | }
12 | subprojects {
13 | project.evaluationDependsOn(":app")
14 | }
15 |
16 | tasks.register("clean", Delete) {
17 | delete rootProject.buildDir
18 | }
19 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
6 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | def flutterSdkPath = {
3 | def properties = new Properties()
4 | file("local.properties").withInputStream { properties.load(it) }
5 | def flutterSdkPath = properties.getProperty("flutter.sdk")
6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7 | return flutterSdkPath
8 | }()
9 |
10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
11 |
12 | repositories {
13 | google()
14 | mavenCentral()
15 | gradlePluginPortal()
16 | }
17 | }
18 |
19 | plugins {
20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21 | id "com.android.application" version "8.1.0" apply false
22 | id "org.jetbrains.kotlin.android" version "1.8.22" apply false
23 | }
24 |
25 | include ":app"
26 |
--------------------------------------------------------------------------------
/example/integration_test/plugin_integration_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter integration test.
2 | //
3 | // Since integration tests run in a full Flutter application, they can interact
4 | // with the host side of a plugin implementation, unlike Dart unit tests.
5 | //
6 | // For more information about Flutter integration tests, please see
7 | // https://flutter.dev/to/integration-testing
8 |
9 | import 'package:flutter_test/flutter_test.dart';
10 | import 'package:integration_test/integration_test.dart';
11 |
12 | import 'package:fast_image_compress/fast_image_compress.dart';
13 |
14 | void main() {
15 | IntegrationTestWidgetsFlutterBinding.ensureInitialized();
16 |
17 | testWidgets('getPlatformVersion test', (WidgetTester tester) async {
18 | final FastImageCompress plugin = FastImageCompress();
19 | final String? version = await plugin.getPlatformVersion();
20 | // The version string depends on the host platform running the test, so
21 | // just assert that some non-empty string is returned.
22 | expect(version?.isNotEmpty, true);
23 | });
24 | }
25 |
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | **/dgph
2 | *.mode1v3
3 | *.mode2v3
4 | *.moved-aside
5 | *.pbxuser
6 | *.perspectivev3
7 | **/*sync/
8 | .sconsign.dblite
9 | .tags*
10 | **/.vagrant/
11 | **/DerivedData/
12 | Icon?
13 | **/Pods/
14 | **/.symlinks/
15 | profile
16 | xcuserdata
17 | **/.generated/
18 | Flutter/App.framework
19 | Flutter/Flutter.framework
20 | Flutter/Flutter.podspec
21 | Flutter/Generated.xcconfig
22 | Flutter/ephemeral/
23 | Flutter/app.flx
24 | Flutter/app.zip
25 | Flutter/flutter_assets/
26 | Flutter/flutter_export_environment.sh
27 | ServiceDefinitions.json
28 | Runner/GeneratedPluginRegistrant.*
29 |
30 | # Exceptions to above rules.
31 | !default.mode1v3
32 | !default.mode2v3
33 | !default.pbxuser
34 | !default.perspectivev3
35 |
--------------------------------------------------------------------------------
/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 12.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | # platform :ios, '12.0'
3 |
4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6 |
7 | project 'Runner', {
8 | 'Debug' => :debug,
9 | 'Profile' => :release,
10 | 'Release' => :release,
11 | }
12 |
13 | def flutter_root
14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15 | unless File.exist?(generated_xcode_build_settings_path)
16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17 | end
18 |
19 | File.foreach(generated_xcode_build_settings_path) do |line|
20 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
21 | return matches[1].strip if matches
22 | end
23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24 | end
25 |
26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27 |
28 | flutter_ios_podfile_setup
29 |
30 | target 'Runner' do
31 | use_frameworks!
32 | use_modular_headers!
33 |
34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35 | target 'RunnerTests' do
36 | inherit! :search_paths
37 | end
38 | end
39 |
40 | post_install do |installer|
41 | installer.pods_project.targets.each do |target|
42 | flutter_additional_ios_build_settings(target)
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 54;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11 | 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
13 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
14 | 7741351EECE1AC18D6006886 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3FF5DCF4877E8D2C7CD8271 /* Pods_Runner.framework */; };
15 | 8B1703AA6B7C8F6A927C4520 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 95FAC674254D4EE2B5E006C3 /* Pods_RunnerTests.framework */; };
16 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
17 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
18 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
19 | /* End PBXBuildFile section */
20 |
21 | /* Begin PBXContainerItemProxy section */
22 | 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = {
23 | isa = PBXContainerItemProxy;
24 | containerPortal = 97C146E61CF9000F007C117D /* Project object */;
25 | proxyType = 1;
26 | remoteGlobalIDString = 97C146ED1CF9000F007C117D;
27 | remoteInfo = Runner;
28 | };
29 | /* End PBXContainerItemProxy section */
30 |
31 | /* Begin PBXCopyFilesBuildPhase section */
32 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = {
33 | isa = PBXCopyFilesBuildPhase;
34 | buildActionMask = 2147483647;
35 | dstPath = "";
36 | dstSubfolderSpec = 10;
37 | files = (
38 | );
39 | name = "Embed Frameworks";
40 | runOnlyForDeploymentPostprocessing = 0;
41 | };
42 | /* End PBXCopyFilesBuildPhase section */
43 |
44 | /* Begin PBXFileReference section */
45 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
46 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
47 | 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; };
48 | 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
49 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
50 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; };
51 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
52 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
53 | 8294979EF67912803FA8DE80 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; };
54 | 8C075462DF624701D23735B6 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; };
55 | 90134392400DEB6C469C0A48 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; };
56 | 95FAC674254D4EE2B5E006C3 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
57 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
58 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
59 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
60 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
61 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
62 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
63 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
64 | A338DC13694C939BFAD5DA78 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; };
65 | D3F04B877C49C14AD89CFE8B /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; };
66 | F3A4779CD51BFE15E57268BF /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; };
67 | F3FF5DCF4877E8D2C7CD8271 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
68 | /* End PBXFileReference section */
69 |
70 | /* Begin PBXFrameworksBuildPhase section */
71 | 97C146EB1CF9000F007C117D /* Frameworks */ = {
72 | isa = PBXFrameworksBuildPhase;
73 | buildActionMask = 2147483647;
74 | files = (
75 | 7741351EECE1AC18D6006886 /* Pods_Runner.framework in Frameworks */,
76 | );
77 | runOnlyForDeploymentPostprocessing = 0;
78 | };
79 | EB797B1A259071077FB2217B /* Frameworks */ = {
80 | isa = PBXFrameworksBuildPhase;
81 | buildActionMask = 2147483647;
82 | files = (
83 | 8B1703AA6B7C8F6A927C4520 /* Pods_RunnerTests.framework in Frameworks */,
84 | );
85 | runOnlyForDeploymentPostprocessing = 0;
86 | };
87 | /* End PBXFrameworksBuildPhase section */
88 |
89 | /* Begin PBXGroup section */
90 | 331C8082294A63A400263BE5 /* RunnerTests */ = {
91 | isa = PBXGroup;
92 | children = (
93 | 331C807B294A618700263BE5 /* RunnerTests.swift */,
94 | );
95 | path = RunnerTests;
96 | sourceTree = "";
97 | };
98 | 366334C26DFD4E79A896A7EB /* Frameworks */ = {
99 | isa = PBXGroup;
100 | children = (
101 | F3FF5DCF4877E8D2C7CD8271 /* Pods_Runner.framework */,
102 | 95FAC674254D4EE2B5E006C3 /* Pods_RunnerTests.framework */,
103 | );
104 | name = Frameworks;
105 | sourceTree = "";
106 | };
107 | 825E4289BA5DEF72D3C01CD4 /* Pods */ = {
108 | isa = PBXGroup;
109 | children = (
110 | A338DC13694C939BFAD5DA78 /* Pods-Runner.debug.xcconfig */,
111 | 8C075462DF624701D23735B6 /* Pods-Runner.release.xcconfig */,
112 | 8294979EF67912803FA8DE80 /* Pods-Runner.profile.xcconfig */,
113 | D3F04B877C49C14AD89CFE8B /* Pods-RunnerTests.debug.xcconfig */,
114 | 90134392400DEB6C469C0A48 /* Pods-RunnerTests.release.xcconfig */,
115 | F3A4779CD51BFE15E57268BF /* Pods-RunnerTests.profile.xcconfig */,
116 | );
117 | name = Pods;
118 | path = Pods;
119 | sourceTree = "";
120 | };
121 | 9740EEB11CF90186004384FC /* Flutter */ = {
122 | isa = PBXGroup;
123 | children = (
124 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
125 | 9740EEB21CF90195004384FC /* Debug.xcconfig */,
126 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
127 | 9740EEB31CF90195004384FC /* Generated.xcconfig */,
128 | );
129 | name = Flutter;
130 | sourceTree = "";
131 | };
132 | 97C146E51CF9000F007C117D = {
133 | isa = PBXGroup;
134 | children = (
135 | 9740EEB11CF90186004384FC /* Flutter */,
136 | 97C146F01CF9000F007C117D /* Runner */,
137 | 97C146EF1CF9000F007C117D /* Products */,
138 | 331C8082294A63A400263BE5 /* RunnerTests */,
139 | 825E4289BA5DEF72D3C01CD4 /* Pods */,
140 | 366334C26DFD4E79A896A7EB /* Frameworks */,
141 | );
142 | sourceTree = "";
143 | };
144 | 97C146EF1CF9000F007C117D /* Products */ = {
145 | isa = PBXGroup;
146 | children = (
147 | 97C146EE1CF9000F007C117D /* Runner.app */,
148 | 331C8081294A63A400263BE5 /* RunnerTests.xctest */,
149 | );
150 | name = Products;
151 | sourceTree = "";
152 | };
153 | 97C146F01CF9000F007C117D /* Runner */ = {
154 | isa = PBXGroup;
155 | children = (
156 | 97C146FA1CF9000F007C117D /* Main.storyboard */,
157 | 97C146FD1CF9000F007C117D /* Assets.xcassets */,
158 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
159 | 97C147021CF9000F007C117D /* Info.plist */,
160 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
161 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
162 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
163 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
164 | );
165 | path = Runner;
166 | sourceTree = "";
167 | };
168 | /* End PBXGroup section */
169 |
170 | /* Begin PBXNativeTarget section */
171 | 331C8080294A63A400263BE5 /* RunnerTests */ = {
172 | isa = PBXNativeTarget;
173 | buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
174 | buildPhases = (
175 | 764EC07350A8C42306195043 /* [CP] Check Pods Manifest.lock */,
176 | 331C807D294A63A400263BE5 /* Sources */,
177 | 331C807F294A63A400263BE5 /* Resources */,
178 | EB797B1A259071077FB2217B /* Frameworks */,
179 | );
180 | buildRules = (
181 | );
182 | dependencies = (
183 | 331C8086294A63A400263BE5 /* PBXTargetDependency */,
184 | );
185 | name = RunnerTests;
186 | productName = RunnerTests;
187 | productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */;
188 | productType = "com.apple.product-type.bundle.unit-test";
189 | };
190 | 97C146ED1CF9000F007C117D /* Runner */ = {
191 | isa = PBXNativeTarget;
192 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
193 | buildPhases = (
194 | 2420477B4DA95A678AB55B30 /* [CP] Check Pods Manifest.lock */,
195 | 9740EEB61CF901F6004384FC /* Run Script */,
196 | 97C146EA1CF9000F007C117D /* Sources */,
197 | 97C146EB1CF9000F007C117D /* Frameworks */,
198 | 97C146EC1CF9000F007C117D /* Resources */,
199 | 9705A1C41CF9048500538489 /* Embed Frameworks */,
200 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
201 | 6238F906AFF1EC5CA4FA1432 /* [CP] Embed Pods Frameworks */,
202 | );
203 | buildRules = (
204 | );
205 | dependencies = (
206 | );
207 | name = Runner;
208 | productName = Runner;
209 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
210 | productType = "com.apple.product-type.application";
211 | };
212 | /* End PBXNativeTarget section */
213 |
214 | /* Begin PBXProject section */
215 | 97C146E61CF9000F007C117D /* Project object */ = {
216 | isa = PBXProject;
217 | attributes = {
218 | BuildIndependentTargetsInParallel = YES;
219 | LastUpgradeCheck = 1510;
220 | ORGANIZATIONNAME = "";
221 | TargetAttributes = {
222 | 331C8080294A63A400263BE5 = {
223 | CreatedOnToolsVersion = 14.0;
224 | TestTargetID = 97C146ED1CF9000F007C117D;
225 | };
226 | 97C146ED1CF9000F007C117D = {
227 | CreatedOnToolsVersion = 7.3.1;
228 | LastSwiftMigration = 1100;
229 | };
230 | };
231 | };
232 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
233 | compatibilityVersion = "Xcode 9.3";
234 | developmentRegion = en;
235 | hasScannedForEncodings = 0;
236 | knownRegions = (
237 | en,
238 | Base,
239 | );
240 | mainGroup = 97C146E51CF9000F007C117D;
241 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
242 | projectDirPath = "";
243 | projectRoot = "";
244 | targets = (
245 | 97C146ED1CF9000F007C117D /* Runner */,
246 | 331C8080294A63A400263BE5 /* RunnerTests */,
247 | );
248 | };
249 | /* End PBXProject section */
250 |
251 | /* Begin PBXResourcesBuildPhase section */
252 | 331C807F294A63A400263BE5 /* Resources */ = {
253 | isa = PBXResourcesBuildPhase;
254 | buildActionMask = 2147483647;
255 | files = (
256 | );
257 | runOnlyForDeploymentPostprocessing = 0;
258 | };
259 | 97C146EC1CF9000F007C117D /* Resources */ = {
260 | isa = PBXResourcesBuildPhase;
261 | buildActionMask = 2147483647;
262 | files = (
263 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
264 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
265 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
266 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
267 | );
268 | runOnlyForDeploymentPostprocessing = 0;
269 | };
270 | /* End PBXResourcesBuildPhase section */
271 |
272 | /* Begin PBXShellScriptBuildPhase section */
273 | 2420477B4DA95A678AB55B30 /* [CP] Check Pods Manifest.lock */ = {
274 | isa = PBXShellScriptBuildPhase;
275 | buildActionMask = 2147483647;
276 | files = (
277 | );
278 | inputFileListPaths = (
279 | );
280 | inputPaths = (
281 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
282 | "${PODS_ROOT}/Manifest.lock",
283 | );
284 | name = "[CP] Check Pods Manifest.lock";
285 | outputFileListPaths = (
286 | );
287 | outputPaths = (
288 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
289 | );
290 | runOnlyForDeploymentPostprocessing = 0;
291 | shellPath = /bin/sh;
292 | 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";
293 | showEnvVarsInLog = 0;
294 | };
295 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
296 | isa = PBXShellScriptBuildPhase;
297 | alwaysOutOfDate = 1;
298 | buildActionMask = 2147483647;
299 | files = (
300 | );
301 | inputPaths = (
302 | "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
303 | );
304 | name = "Thin Binary";
305 | outputPaths = (
306 | );
307 | runOnlyForDeploymentPostprocessing = 0;
308 | shellPath = /bin/sh;
309 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
310 | };
311 | 6238F906AFF1EC5CA4FA1432 /* [CP] Embed Pods Frameworks */ = {
312 | isa = PBXShellScriptBuildPhase;
313 | buildActionMask = 2147483647;
314 | files = (
315 | );
316 | inputFileListPaths = (
317 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
318 | );
319 | name = "[CP] Embed Pods Frameworks";
320 | outputFileListPaths = (
321 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
322 | );
323 | runOnlyForDeploymentPostprocessing = 0;
324 | shellPath = /bin/sh;
325 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
326 | showEnvVarsInLog = 0;
327 | };
328 | 764EC07350A8C42306195043 /* [CP] Check Pods Manifest.lock */ = {
329 | isa = PBXShellScriptBuildPhase;
330 | buildActionMask = 2147483647;
331 | files = (
332 | );
333 | inputFileListPaths = (
334 | );
335 | inputPaths = (
336 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
337 | "${PODS_ROOT}/Manifest.lock",
338 | );
339 | name = "[CP] Check Pods Manifest.lock";
340 | outputFileListPaths = (
341 | );
342 | outputPaths = (
343 | "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt",
344 | );
345 | runOnlyForDeploymentPostprocessing = 0;
346 | shellPath = /bin/sh;
347 | 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";
348 | showEnvVarsInLog = 0;
349 | };
350 | 9740EEB61CF901F6004384FC /* Run Script */ = {
351 | isa = PBXShellScriptBuildPhase;
352 | alwaysOutOfDate = 1;
353 | buildActionMask = 2147483647;
354 | files = (
355 | );
356 | inputPaths = (
357 | );
358 | name = "Run Script";
359 | outputPaths = (
360 | );
361 | runOnlyForDeploymentPostprocessing = 0;
362 | shellPath = /bin/sh;
363 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
364 | };
365 | /* End PBXShellScriptBuildPhase section */
366 |
367 | /* Begin PBXSourcesBuildPhase section */
368 | 331C807D294A63A400263BE5 /* Sources */ = {
369 | isa = PBXSourcesBuildPhase;
370 | buildActionMask = 2147483647;
371 | files = (
372 | 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */,
373 | );
374 | runOnlyForDeploymentPostprocessing = 0;
375 | };
376 | 97C146EA1CF9000F007C117D /* Sources */ = {
377 | isa = PBXSourcesBuildPhase;
378 | buildActionMask = 2147483647;
379 | files = (
380 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
381 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
382 | );
383 | runOnlyForDeploymentPostprocessing = 0;
384 | };
385 | /* End PBXSourcesBuildPhase section */
386 |
387 | /* Begin PBXTargetDependency section */
388 | 331C8086294A63A400263BE5 /* PBXTargetDependency */ = {
389 | isa = PBXTargetDependency;
390 | target = 97C146ED1CF9000F007C117D /* Runner */;
391 | targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */;
392 | };
393 | /* End PBXTargetDependency section */
394 |
395 | /* Begin PBXVariantGroup section */
396 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = {
397 | isa = PBXVariantGroup;
398 | children = (
399 | 97C146FB1CF9000F007C117D /* Base */,
400 | );
401 | name = Main.storyboard;
402 | sourceTree = "";
403 | };
404 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
405 | isa = PBXVariantGroup;
406 | children = (
407 | 97C147001CF9000F007C117D /* Base */,
408 | );
409 | name = LaunchScreen.storyboard;
410 | sourceTree = "";
411 | };
412 | /* End PBXVariantGroup section */
413 |
414 | /* Begin XCBuildConfiguration section */
415 | 249021D3217E4FDB00AE95B9 /* Profile */ = {
416 | isa = XCBuildConfiguration;
417 | buildSettings = {
418 | ALWAYS_SEARCH_USER_PATHS = NO;
419 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
420 | CLANG_ANALYZER_NONNULL = YES;
421 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
422 | CLANG_CXX_LIBRARY = "libc++";
423 | CLANG_ENABLE_MODULES = YES;
424 | CLANG_ENABLE_OBJC_ARC = YES;
425 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
426 | CLANG_WARN_BOOL_CONVERSION = YES;
427 | CLANG_WARN_COMMA = YES;
428 | CLANG_WARN_CONSTANT_CONVERSION = YES;
429 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
430 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
431 | CLANG_WARN_EMPTY_BODY = YES;
432 | CLANG_WARN_ENUM_CONVERSION = YES;
433 | CLANG_WARN_INFINITE_RECURSION = YES;
434 | CLANG_WARN_INT_CONVERSION = YES;
435 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
436 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
437 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
438 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
439 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
440 | CLANG_WARN_STRICT_PROTOTYPES = YES;
441 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
442 | CLANG_WARN_UNREACHABLE_CODE = YES;
443 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
444 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
445 | COPY_PHASE_STRIP = NO;
446 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
447 | ENABLE_NS_ASSERTIONS = NO;
448 | ENABLE_STRICT_OBJC_MSGSEND = YES;
449 | ENABLE_USER_SCRIPT_SANDBOXING = NO;
450 | GCC_C_LANGUAGE_STANDARD = gnu99;
451 | GCC_NO_COMMON_BLOCKS = YES;
452 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
453 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
454 | GCC_WARN_UNDECLARED_SELECTOR = YES;
455 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
456 | GCC_WARN_UNUSED_FUNCTION = YES;
457 | GCC_WARN_UNUSED_VARIABLE = YES;
458 | IPHONEOS_DEPLOYMENT_TARGET = 12.0;
459 | MTL_ENABLE_DEBUG_INFO = NO;
460 | SDKROOT = iphoneos;
461 | SUPPORTED_PLATFORMS = iphoneos;
462 | TARGETED_DEVICE_FAMILY = "1,2";
463 | VALIDATE_PRODUCT = YES;
464 | };
465 | name = Profile;
466 | };
467 | 249021D4217E4FDB00AE95B9 /* Profile */ = {
468 | isa = XCBuildConfiguration;
469 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
470 | buildSettings = {
471 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
472 | CLANG_ENABLE_MODULES = YES;
473 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
474 | DEVELOPMENT_TEAM = K7XJG666ZW;
475 | ENABLE_BITCODE = NO;
476 | INFOPLIST_FILE = Runner/Info.plist;
477 | LD_RUNPATH_SEARCH_PATHS = (
478 | "$(inherited)",
479 | "@executable_path/Frameworks",
480 | );
481 | PRODUCT_BUNDLE_IDENTIFIER = com.example.fastImageCompressExample;
482 | PRODUCT_NAME = "$(TARGET_NAME)";
483 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
484 | SWIFT_VERSION = 5.0;
485 | VERSIONING_SYSTEM = "apple-generic";
486 | };
487 | name = Profile;
488 | };
489 | 331C8088294A63A400263BE5 /* Debug */ = {
490 | isa = XCBuildConfiguration;
491 | baseConfigurationReference = D3F04B877C49C14AD89CFE8B /* Pods-RunnerTests.debug.xcconfig */;
492 | buildSettings = {
493 | BUNDLE_LOADER = "$(TEST_HOST)";
494 | CODE_SIGN_STYLE = Automatic;
495 | CURRENT_PROJECT_VERSION = 1;
496 | GENERATE_INFOPLIST_FILE = YES;
497 | MARKETING_VERSION = 1.0;
498 | PRODUCT_BUNDLE_IDENTIFIER = com.example.fastImageCompressExample.RunnerTests;
499 | PRODUCT_NAME = "$(TARGET_NAME)";
500 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
501 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
502 | SWIFT_VERSION = 5.0;
503 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
504 | };
505 | name = Debug;
506 | };
507 | 331C8089294A63A400263BE5 /* Release */ = {
508 | isa = XCBuildConfiguration;
509 | baseConfigurationReference = 90134392400DEB6C469C0A48 /* Pods-RunnerTests.release.xcconfig */;
510 | buildSettings = {
511 | BUNDLE_LOADER = "$(TEST_HOST)";
512 | CODE_SIGN_STYLE = Automatic;
513 | CURRENT_PROJECT_VERSION = 1;
514 | GENERATE_INFOPLIST_FILE = YES;
515 | MARKETING_VERSION = 1.0;
516 | PRODUCT_BUNDLE_IDENTIFIER = com.example.fastImageCompressExample.RunnerTests;
517 | PRODUCT_NAME = "$(TARGET_NAME)";
518 | SWIFT_VERSION = 5.0;
519 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
520 | };
521 | name = Release;
522 | };
523 | 331C808A294A63A400263BE5 /* Profile */ = {
524 | isa = XCBuildConfiguration;
525 | baseConfigurationReference = F3A4779CD51BFE15E57268BF /* Pods-RunnerTests.profile.xcconfig */;
526 | buildSettings = {
527 | BUNDLE_LOADER = "$(TEST_HOST)";
528 | CODE_SIGN_STYLE = Automatic;
529 | CURRENT_PROJECT_VERSION = 1;
530 | GENERATE_INFOPLIST_FILE = YES;
531 | MARKETING_VERSION = 1.0;
532 | PRODUCT_BUNDLE_IDENTIFIER = com.example.fastImageCompressExample.RunnerTests;
533 | PRODUCT_NAME = "$(TARGET_NAME)";
534 | SWIFT_VERSION = 5.0;
535 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
536 | };
537 | name = Profile;
538 | };
539 | 97C147031CF9000F007C117D /* Debug */ = {
540 | isa = XCBuildConfiguration;
541 | buildSettings = {
542 | ALWAYS_SEARCH_USER_PATHS = NO;
543 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
544 | CLANG_ANALYZER_NONNULL = YES;
545 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
546 | CLANG_CXX_LIBRARY = "libc++";
547 | CLANG_ENABLE_MODULES = YES;
548 | CLANG_ENABLE_OBJC_ARC = YES;
549 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
550 | CLANG_WARN_BOOL_CONVERSION = YES;
551 | CLANG_WARN_COMMA = YES;
552 | CLANG_WARN_CONSTANT_CONVERSION = YES;
553 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
554 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
555 | CLANG_WARN_EMPTY_BODY = YES;
556 | CLANG_WARN_ENUM_CONVERSION = YES;
557 | CLANG_WARN_INFINITE_RECURSION = YES;
558 | CLANG_WARN_INT_CONVERSION = YES;
559 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
560 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
561 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
562 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
563 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
564 | CLANG_WARN_STRICT_PROTOTYPES = YES;
565 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
566 | CLANG_WARN_UNREACHABLE_CODE = YES;
567 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
568 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
569 | COPY_PHASE_STRIP = NO;
570 | DEBUG_INFORMATION_FORMAT = dwarf;
571 | ENABLE_STRICT_OBJC_MSGSEND = YES;
572 | ENABLE_TESTABILITY = YES;
573 | ENABLE_USER_SCRIPT_SANDBOXING = NO;
574 | GCC_C_LANGUAGE_STANDARD = gnu99;
575 | GCC_DYNAMIC_NO_PIC = NO;
576 | GCC_NO_COMMON_BLOCKS = YES;
577 | GCC_OPTIMIZATION_LEVEL = 0;
578 | GCC_PREPROCESSOR_DEFINITIONS = (
579 | "DEBUG=1",
580 | "$(inherited)",
581 | );
582 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
583 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
584 | GCC_WARN_UNDECLARED_SELECTOR = YES;
585 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
586 | GCC_WARN_UNUSED_FUNCTION = YES;
587 | GCC_WARN_UNUSED_VARIABLE = YES;
588 | IPHONEOS_DEPLOYMENT_TARGET = 12.0;
589 | MTL_ENABLE_DEBUG_INFO = YES;
590 | ONLY_ACTIVE_ARCH = YES;
591 | SDKROOT = iphoneos;
592 | TARGETED_DEVICE_FAMILY = "1,2";
593 | };
594 | name = Debug;
595 | };
596 | 97C147041CF9000F007C117D /* Release */ = {
597 | isa = XCBuildConfiguration;
598 | buildSettings = {
599 | ALWAYS_SEARCH_USER_PATHS = NO;
600 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
601 | CLANG_ANALYZER_NONNULL = YES;
602 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
603 | CLANG_CXX_LIBRARY = "libc++";
604 | CLANG_ENABLE_MODULES = YES;
605 | CLANG_ENABLE_OBJC_ARC = YES;
606 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
607 | CLANG_WARN_BOOL_CONVERSION = YES;
608 | CLANG_WARN_COMMA = YES;
609 | CLANG_WARN_CONSTANT_CONVERSION = YES;
610 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
611 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
612 | CLANG_WARN_EMPTY_BODY = YES;
613 | CLANG_WARN_ENUM_CONVERSION = YES;
614 | CLANG_WARN_INFINITE_RECURSION = YES;
615 | CLANG_WARN_INT_CONVERSION = YES;
616 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
617 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
618 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
619 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
620 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
621 | CLANG_WARN_STRICT_PROTOTYPES = YES;
622 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
623 | CLANG_WARN_UNREACHABLE_CODE = YES;
624 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
625 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
626 | COPY_PHASE_STRIP = NO;
627 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
628 | ENABLE_NS_ASSERTIONS = NO;
629 | ENABLE_STRICT_OBJC_MSGSEND = YES;
630 | ENABLE_USER_SCRIPT_SANDBOXING = NO;
631 | GCC_C_LANGUAGE_STANDARD = gnu99;
632 | GCC_NO_COMMON_BLOCKS = YES;
633 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
634 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
635 | GCC_WARN_UNDECLARED_SELECTOR = YES;
636 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
637 | GCC_WARN_UNUSED_FUNCTION = YES;
638 | GCC_WARN_UNUSED_VARIABLE = YES;
639 | IPHONEOS_DEPLOYMENT_TARGET = 12.0;
640 | MTL_ENABLE_DEBUG_INFO = NO;
641 | SDKROOT = iphoneos;
642 | SUPPORTED_PLATFORMS = iphoneos;
643 | SWIFT_COMPILATION_MODE = wholemodule;
644 | SWIFT_OPTIMIZATION_LEVEL = "-O";
645 | TARGETED_DEVICE_FAMILY = "1,2";
646 | VALIDATE_PRODUCT = YES;
647 | };
648 | name = Release;
649 | };
650 | 97C147061CF9000F007C117D /* Debug */ = {
651 | isa = XCBuildConfiguration;
652 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
653 | buildSettings = {
654 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
655 | CLANG_ENABLE_MODULES = YES;
656 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
657 | DEVELOPMENT_TEAM = K7XJG666ZW;
658 | ENABLE_BITCODE = NO;
659 | INFOPLIST_FILE = Runner/Info.plist;
660 | LD_RUNPATH_SEARCH_PATHS = (
661 | "$(inherited)",
662 | "@executable_path/Frameworks",
663 | );
664 | PRODUCT_BUNDLE_IDENTIFIER = com.example.fastImageCompressExample;
665 | PRODUCT_NAME = "$(TARGET_NAME)";
666 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
667 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
668 | SWIFT_VERSION = 5.0;
669 | VERSIONING_SYSTEM = "apple-generic";
670 | };
671 | name = Debug;
672 | };
673 | 97C147071CF9000F007C117D /* Release */ = {
674 | isa = XCBuildConfiguration;
675 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
676 | buildSettings = {
677 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
678 | CLANG_ENABLE_MODULES = YES;
679 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
680 | DEVELOPMENT_TEAM = K7XJG666ZW;
681 | ENABLE_BITCODE = NO;
682 | INFOPLIST_FILE = Runner/Info.plist;
683 | LD_RUNPATH_SEARCH_PATHS = (
684 | "$(inherited)",
685 | "@executable_path/Frameworks",
686 | );
687 | PRODUCT_BUNDLE_IDENTIFIER = com.example.fastImageCompressExample;
688 | PRODUCT_NAME = "$(TARGET_NAME)";
689 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
690 | SWIFT_VERSION = 5.0;
691 | VERSIONING_SYSTEM = "apple-generic";
692 | };
693 | name = Release;
694 | };
695 | /* End XCBuildConfiguration section */
696 |
697 | /* Begin XCConfigurationList section */
698 | 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = {
699 | isa = XCConfigurationList;
700 | buildConfigurations = (
701 | 331C8088294A63A400263BE5 /* Debug */,
702 | 331C8089294A63A400263BE5 /* Release */,
703 | 331C808A294A63A400263BE5 /* Profile */,
704 | );
705 | defaultConfigurationIsVisible = 0;
706 | defaultConfigurationName = Release;
707 | };
708 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
709 | isa = XCConfigurationList;
710 | buildConfigurations = (
711 | 97C147031CF9000F007C117D /* Debug */,
712 | 97C147041CF9000F007C117D /* Release */,
713 | 249021D3217E4FDB00AE95B9 /* Profile */,
714 | );
715 | defaultConfigurationIsVisible = 0;
716 | defaultConfigurationName = Release;
717 | };
718 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
719 | isa = XCConfigurationList;
720 | buildConfigurations = (
721 | 97C147061CF9000F007C117D /* Debug */,
722 | 97C147071CF9000F007C117D /* Release */,
723 | 249021D4217E4FDB00AE95B9 /* Profile */,
724 | );
725 | defaultConfigurationIsVisible = 0;
726 | defaultConfigurationName = Release;
727 | };
728 | /* End XCConfigurationList section */
729 | };
730 | rootObject = 97C146E61CF9000F007C117D /* Project object */;
731 | }
732 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
43 |
49 |
50 |
51 |
52 |
53 |
63 |
65 |
71 |
72 |
73 |
74 |
80 |
82 |
88 |
89 |
90 |
91 |
93 |
94 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Flutter
2 | import UIKit
3 |
4 | @main
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | 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.
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSPhotoLibraryUsageDescription
6 | Fast Image Compress needs access to your photo library to pick images.
7 | NSCameraUsageDescription
8 | Fast Image Compress needs access to your camera to capture new images.
9 | NSMicrophoneUsageDescription
10 | Fast Image Compress needs access to your microphone to record videos.
11 | CFBundleDevelopmentRegion
12 | $(DEVELOPMENT_LANGUAGE)
13 | CFBundleDisplayName
14 | Fast Image Compress
15 | CFBundleExecutable
16 | $(EXECUTABLE_NAME)
17 | CFBundleIdentifier
18 | $(PRODUCT_BUNDLE_IDENTIFIER)
19 | CFBundleInfoDictionaryVersion
20 | 6.0
21 | CFBundleName
22 | fast_image_compress_example
23 | CFBundlePackageType
24 | APPL
25 | CFBundleShortVersionString
26 | $(FLUTTER_BUILD_NAME)
27 | CFBundleSignature
28 | ????
29 | CFBundleVersion
30 | $(FLUTTER_BUILD_NUMBER)
31 | LSRequiresIPhoneOS
32 |
33 | UILaunchStoryboardName
34 | LaunchScreen
35 | UIMainStoryboardFile
36 | Main
37 | UISupportedInterfaceOrientations
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationLandscapeLeft
41 | UIInterfaceOrientationLandscapeRight
42 |
43 | UISupportedInterfaceOrientations~ipad
44 |
45 | UIInterfaceOrientationPortrait
46 | UIInterfaceOrientationPortraitUpsideDown
47 | UIInterfaceOrientationLandscapeLeft
48 | UIInterfaceOrientationLandscapeRight
49 |
50 | CADisableMinimumFrameDurationOnPhone
51 |
52 | UIApplicationSupportsIndirectInputEvents
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/example/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/example/ios/RunnerTests/RunnerTests.swift:
--------------------------------------------------------------------------------
1 | import Flutter
2 | import UIKit
3 | import XCTest
4 |
5 |
6 | @testable import fast_image_compress
7 |
8 | // This demonstrates a simple unit test of the Swift portion of this plugin's implementation.
9 | //
10 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest.
11 |
12 | class RunnerTests: XCTestCase {
13 |
14 | func testGetPlatformVersion() {
15 | let plugin = FastImageCompressPlugin()
16 |
17 | let call = FlutterMethodCall(methodName: "getPlatformVersion", arguments: [])
18 |
19 | let resultExpectation = expectation(description: "result block must be called.")
20 | plugin.handle(call) { result in
21 | XCTAssertEqual(result as! String, "iOS " + UIDevice.current.systemVersion)
22 | resultExpectation.fulfill()
23 | }
24 | waitForExpectations(timeout: 1)
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'dart:typed_data';
3 |
4 | import 'package:fast_image_compress/fast_image_compress.dart';
5 | import 'package:flutter/material.dart';
6 | import 'package:image_picker/image_picker.dart';
7 |
8 | void main() {
9 | runApp(const MyApp());
10 | }
11 |
12 | class MyApp extends StatelessWidget {
13 | const MyApp({super.key});
14 |
15 | @override
16 | Widget build(BuildContext context) {
17 | return MaterialApp(
18 | title: 'Fast Image Compress Example',
19 | theme: ThemeData(
20 | primarySwatch: Colors.red,
21 | ),
22 | home: const CompressionExamplePage(),
23 | );
24 | }
25 | }
26 |
27 | class CompressionExamplePage extends StatefulWidget {
28 | const CompressionExamplePage({super.key});
29 |
30 | @override
31 | CompressionExamplePageState createState() => CompressionExamplePageState();
32 | }
33 |
34 | class CompressionExamplePageState extends State {
35 | final FastImageCompress fastImageCompress = FastImageCompress();
36 | final ImagePicker _imagePicker = ImagePicker();
37 | List? _originalImageList;
38 | List? _compressedImageList;
39 | bool _isCompressing = false;
40 | double _progress = 0.0;
41 | int _completedCount = 0;
42 | bool _isCancelled = false;
43 |
44 | Future _pickImage() async {
45 | setState(() {
46 | _originalImageList = [];
47 | _compressedImageList = null;
48 | });
49 |
50 | final pickedFiles = await _imagePicker.pickMultiImage(limit: 30);
51 | if (pickedFiles.isNotEmpty) {
52 | final res = await Future.wait(
53 | pickedFiles.map((file) async => await file.readAsBytes()),
54 | );
55 | setState(() {
56 | _originalImageList = res;
57 | _compressedImageList = null; // Reset compressed image
58 | });
59 | }
60 | }
61 |
62 | Future _compressImage() async {
63 | if (_originalImageList == null || _originalImageList!.isEmpty) return;
64 |
65 | setState(() {
66 | _isCancelled = false;
67 | _isCompressing = true;
68 | _progress = 0.0;
69 | });
70 |
71 | final totalImages = _originalImageList!.length;
72 | fastImageCompress.progressStream.listen((completedCount) {
73 | if (_isCancelled == false) {
74 | setState(() {
75 | _progress = (completedCount / totalImages);
76 | _completedCount = completedCount;
77 | });
78 | }
79 | });
80 |
81 | final compressedImageList = await fastImageCompress.compressImageList(
82 | images: _originalImageList!,
83 | quality: 90,
84 | batchSize: 2,
85 | imageQuality: ImageQuality.high,
86 | targetWidth: 300,
87 | );
88 |
89 | if (_isCancelled == false) {
90 | setState(() {
91 | _compressedImageList = compressedImageList;
92 | _isCompressing = false;
93 | });
94 | }
95 | }
96 |
97 | Future _cancelCompression() async {
98 | await fastImageCompress.cancelCompression();
99 | setState(() {
100 | _isCancelled = true;
101 | _compressedImageList = null;
102 | _isCompressing = false;
103 | _progress = 0;
104 | _completedCount = 0;
105 | });
106 | }
107 |
108 | @override
109 | Widget build(BuildContext context) {
110 | final totalSelectedImages = _originalImageList?.length;
111 | return Scaffold(
112 | appBar: AppBar(
113 | title: const Text('Image Compression Example'),
114 | ),
115 | body: Padding(
116 | padding: const EdgeInsets.all(16.0),
117 | child: Column(
118 | children: [
119 | ElevatedButton(
120 | onPressed: _pickImage,
121 | child: const Text('Pick Image'),
122 | ),
123 | if (_originalImageList != null) ...[
124 | const SizedBox(height: 20),
125 | Text(
126 | 'Selected image count: ${_originalImageList?.length ?? 0}',
127 | ),
128 | ],
129 | const SizedBox(height: 20),
130 | if (!_isCompressing) ...[
131 | ElevatedButton(
132 | onPressed: _compressImage,
133 | child: const Text('Compress Image'),
134 | ),
135 | const SizedBox(height: 20),
136 | ] else ...[
137 | ElevatedButton(
138 | onPressed: _cancelCompression,
139 | child: const Text('Cancel Compression'),
140 | ),
141 | const SizedBox(height: 20),
142 | ],
143 | Padding(
144 | padding: const EdgeInsets.symmetric(horizontal: 8.0),
145 | child: LinearProgressIndicator(value: _progress),
146 | ),
147 | const SizedBox(height: 10),
148 | if (totalSelectedImages != null && totalSelectedImages > 0)
149 | Text(
150 | '$_completedCount/$totalSelectedImages Compressed',
151 | style: const TextStyle(fontSize: 16.0),
152 | ),
153 | if (_compressedImageList != null &&
154 | _compressedImageList!.isNotEmpty) ...[
155 | const SizedBox(height: 20),
156 | const Text('Compressed Images:'),
157 | const SizedBox(height: 20),
158 | Expanded(
159 | child: ListView.builder(
160 | itemBuilder: (BuildContext context, int index) {
161 | if (index < _compressedImageList!.length) {
162 | final actualImageSize =
163 | (_originalImageList![index].lengthInBytes / 1024)
164 | .toStringAsFixed(2);
165 | final compressedImageSize =
166 | (_compressedImageList![index].lengthInBytes / 1024)
167 | .toStringAsFixed(2);
168 | return Column(
169 | children: [
170 | Image.memory(_compressedImageList![index]),
171 | Text(
172 | 'Actual Image Size: $actualImageSize Kb \nCompressed Image Size: $compressedImageSize Kb',
173 | ),
174 | ],
175 | );
176 | }
177 | return null;
178 | },
179 | ),
180 | ),
181 | ],
182 | ],
183 | ),
184 | ),
185 | );
186 | }
187 |
188 | @override
189 | void dispose() {
190 | fastImageCompress.dispose();
191 | super.dispose();
192 | }
193 | }
194 |
--------------------------------------------------------------------------------
/example/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | async:
5 | dependency: transitive
6 | description:
7 | name: async
8 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
9 | url: "https://pub.dev"
10 | source: hosted
11 | version: "2.11.0"
12 | boolean_selector:
13 | dependency: transitive
14 | description:
15 | name: boolean_selector
16 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
17 | url: "https://pub.dev"
18 | source: hosted
19 | version: "2.1.1"
20 | characters:
21 | dependency: transitive
22 | description:
23 | name: characters
24 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
25 | url: "https://pub.dev"
26 | source: hosted
27 | version: "1.3.0"
28 | clock:
29 | dependency: transitive
30 | description:
31 | name: clock
32 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
33 | url: "https://pub.dev"
34 | source: hosted
35 | version: "1.1.1"
36 | collection:
37 | dependency: transitive
38 | description:
39 | name: collection
40 | sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
41 | url: "https://pub.dev"
42 | source: hosted
43 | version: "1.18.0"
44 | cross_file:
45 | dependency: transitive
46 | description:
47 | name: cross_file
48 | sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670"
49 | url: "https://pub.dev"
50 | source: hosted
51 | version: "0.3.4+2"
52 | cupertino_icons:
53 | dependency: "direct main"
54 | description:
55 | name: cupertino_icons
56 | sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
57 | url: "https://pub.dev"
58 | source: hosted
59 | version: "1.0.8"
60 | fake_async:
61 | dependency: transitive
62 | description:
63 | name: fake_async
64 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
65 | url: "https://pub.dev"
66 | source: hosted
67 | version: "1.3.1"
68 | fast_image_compress:
69 | dependency: "direct main"
70 | description:
71 | path: ".."
72 | relative: true
73 | source: path
74 | version: "0.0.1"
75 | file:
76 | dependency: transitive
77 | description:
78 | name: file
79 | sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
80 | url: "https://pub.dev"
81 | source: hosted
82 | version: "7.0.0"
83 | file_selector_linux:
84 | dependency: transitive
85 | description:
86 | name: file_selector_linux
87 | sha256: "54cbbd957e1156d29548c7d9b9ec0c0ebb6de0a90452198683a7d23aed617a33"
88 | url: "https://pub.dev"
89 | source: hosted
90 | version: "0.9.3+2"
91 | file_selector_macos:
92 | dependency: transitive
93 | description:
94 | name: file_selector_macos
95 | sha256: "271ab9986df0c135d45c3cdb6bd0faa5db6f4976d3e4b437cf7d0f258d941bfc"
96 | url: "https://pub.dev"
97 | source: hosted
98 | version: "0.9.4+2"
99 | file_selector_platform_interface:
100 | dependency: transitive
101 | description:
102 | name: file_selector_platform_interface
103 | sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b
104 | url: "https://pub.dev"
105 | source: hosted
106 | version: "2.6.2"
107 | file_selector_windows:
108 | dependency: transitive
109 | description:
110 | name: file_selector_windows
111 | sha256: "8f5d2f6590d51ecd9179ba39c64f722edc15226cc93dcc8698466ad36a4a85a4"
112 | url: "https://pub.dev"
113 | source: hosted
114 | version: "0.9.3+3"
115 | flutter:
116 | dependency: "direct main"
117 | description: flutter
118 | source: sdk
119 | version: "0.0.0"
120 | flutter_driver:
121 | dependency: transitive
122 | description: flutter
123 | source: sdk
124 | version: "0.0.0"
125 | flutter_lints:
126 | dependency: "direct dev"
127 | description:
128 | name: flutter_lints
129 | sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c"
130 | url: "https://pub.dev"
131 | source: hosted
132 | version: "4.0.0"
133 | flutter_plugin_android_lifecycle:
134 | dependency: transitive
135 | description:
136 | name: flutter_plugin_android_lifecycle
137 | sha256: "9b78450b89f059e96c9ebb355fa6b3df1d6b330436e0b885fb49594c41721398"
138 | url: "https://pub.dev"
139 | source: hosted
140 | version: "2.0.23"
141 | flutter_test:
142 | dependency: "direct dev"
143 | description: flutter
144 | source: sdk
145 | version: "0.0.0"
146 | flutter_web_plugins:
147 | dependency: transitive
148 | description: flutter
149 | source: sdk
150 | version: "0.0.0"
151 | fuchsia_remote_debug_protocol:
152 | dependency: transitive
153 | description: flutter
154 | source: sdk
155 | version: "0.0.0"
156 | http:
157 | dependency: transitive
158 | description:
159 | name: http
160 | sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
161 | url: "https://pub.dev"
162 | source: hosted
163 | version: "1.2.2"
164 | http_parser:
165 | dependency: transitive
166 | description:
167 | name: http_parser
168 | sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
169 | url: "https://pub.dev"
170 | source: hosted
171 | version: "4.0.2"
172 | image_picker:
173 | dependency: "direct main"
174 | description:
175 | name: image_picker
176 | sha256: "021834d9c0c3de46bf0fe40341fa07168407f694d9b2bb18d532dc1261867f7a"
177 | url: "https://pub.dev"
178 | source: hosted
179 | version: "1.1.2"
180 | image_picker_android:
181 | dependency: transitive
182 | description:
183 | name: image_picker_android
184 | sha256: fa8141602fde3f7e2f81dbf043613eb44dfa325fa0bcf93c0f142c9f7a2c193e
185 | url: "https://pub.dev"
186 | source: hosted
187 | version: "0.8.12+18"
188 | image_picker_for_web:
189 | dependency: transitive
190 | description:
191 | name: image_picker_for_web
192 | sha256: "717eb042ab08c40767684327be06a5d8dbb341fe791d514e4b92c7bbe1b7bb83"
193 | url: "https://pub.dev"
194 | source: hosted
195 | version: "3.0.6"
196 | image_picker_ios:
197 | dependency: transitive
198 | description:
199 | name: image_picker_ios
200 | sha256: "4f0568120c6fcc0aaa04511cb9f9f4d29fc3d0139884b1d06be88dcec7641d6b"
201 | url: "https://pub.dev"
202 | source: hosted
203 | version: "0.8.12+1"
204 | image_picker_linux:
205 | dependency: transitive
206 | description:
207 | name: image_picker_linux
208 | sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa"
209 | url: "https://pub.dev"
210 | source: hosted
211 | version: "0.2.1+1"
212 | image_picker_macos:
213 | dependency: transitive
214 | description:
215 | name: image_picker_macos
216 | sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62"
217 | url: "https://pub.dev"
218 | source: hosted
219 | version: "0.2.1+1"
220 | image_picker_platform_interface:
221 | dependency: transitive
222 | description:
223 | name: image_picker_platform_interface
224 | sha256: "9ec26d410ff46f483c5519c29c02ef0e02e13a543f882b152d4bfd2f06802f80"
225 | url: "https://pub.dev"
226 | source: hosted
227 | version: "2.10.0"
228 | image_picker_windows:
229 | dependency: transitive
230 | description:
231 | name: image_picker_windows
232 | sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb"
233 | url: "https://pub.dev"
234 | source: hosted
235 | version: "0.2.1+1"
236 | integration_test:
237 | dependency: "direct dev"
238 | description: flutter
239 | source: sdk
240 | version: "0.0.0"
241 | leak_tracker:
242 | dependency: transitive
243 | description:
244 | name: leak_tracker
245 | sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
246 | url: "https://pub.dev"
247 | source: hosted
248 | version: "10.0.5"
249 | leak_tracker_flutter_testing:
250 | dependency: transitive
251 | description:
252 | name: leak_tracker_flutter_testing
253 | sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
254 | url: "https://pub.dev"
255 | source: hosted
256 | version: "3.0.5"
257 | leak_tracker_testing:
258 | dependency: transitive
259 | description:
260 | name: leak_tracker_testing
261 | sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
262 | url: "https://pub.dev"
263 | source: hosted
264 | version: "3.0.1"
265 | lints:
266 | dependency: transitive
267 | description:
268 | name: lints
269 | sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235"
270 | url: "https://pub.dev"
271 | source: hosted
272 | version: "4.0.0"
273 | matcher:
274 | dependency: transitive
275 | description:
276 | name: matcher
277 | sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
278 | url: "https://pub.dev"
279 | source: hosted
280 | version: "0.12.16+1"
281 | material_color_utilities:
282 | dependency: transitive
283 | description:
284 | name: material_color_utilities
285 | sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
286 | url: "https://pub.dev"
287 | source: hosted
288 | version: "0.11.1"
289 | meta:
290 | dependency: transitive
291 | description:
292 | name: meta
293 | sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
294 | url: "https://pub.dev"
295 | source: hosted
296 | version: "1.15.0"
297 | mime:
298 | dependency: transitive
299 | description:
300 | name: mime
301 | sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
302 | url: "https://pub.dev"
303 | source: hosted
304 | version: "2.0.0"
305 | path:
306 | dependency: transitive
307 | description:
308 | name: path
309 | sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
310 | url: "https://pub.dev"
311 | source: hosted
312 | version: "1.9.0"
313 | platform:
314 | dependency: transitive
315 | description:
316 | name: platform
317 | sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
318 | url: "https://pub.dev"
319 | source: hosted
320 | version: "3.1.5"
321 | plugin_platform_interface:
322 | dependency: transitive
323 | description:
324 | name: plugin_platform_interface
325 | sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
326 | url: "https://pub.dev"
327 | source: hosted
328 | version: "2.1.8"
329 | process:
330 | dependency: transitive
331 | description:
332 | name: process
333 | sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32"
334 | url: "https://pub.dev"
335 | source: hosted
336 | version: "5.0.2"
337 | sky_engine:
338 | dependency: transitive
339 | description: flutter
340 | source: sdk
341 | version: "0.0.99"
342 | source_span:
343 | dependency: transitive
344 | description:
345 | name: source_span
346 | sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
347 | url: "https://pub.dev"
348 | source: hosted
349 | version: "1.10.0"
350 | stack_trace:
351 | dependency: transitive
352 | description:
353 | name: stack_trace
354 | sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
355 | url: "https://pub.dev"
356 | source: hosted
357 | version: "1.11.1"
358 | stream_channel:
359 | dependency: transitive
360 | description:
361 | name: stream_channel
362 | sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
363 | url: "https://pub.dev"
364 | source: hosted
365 | version: "2.1.2"
366 | string_scanner:
367 | dependency: transitive
368 | description:
369 | name: string_scanner
370 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
371 | url: "https://pub.dev"
372 | source: hosted
373 | version: "1.2.0"
374 | sync_http:
375 | dependency: transitive
376 | description:
377 | name: sync_http
378 | sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
379 | url: "https://pub.dev"
380 | source: hosted
381 | version: "0.3.1"
382 | term_glyph:
383 | dependency: transitive
384 | description:
385 | name: term_glyph
386 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
387 | url: "https://pub.dev"
388 | source: hosted
389 | version: "1.2.1"
390 | test_api:
391 | dependency: transitive
392 | description:
393 | name: test_api
394 | sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
395 | url: "https://pub.dev"
396 | source: hosted
397 | version: "0.7.2"
398 | typed_data:
399 | dependency: transitive
400 | description:
401 | name: typed_data
402 | sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006
403 | url: "https://pub.dev"
404 | source: hosted
405 | version: "1.4.0"
406 | vector_math:
407 | dependency: transitive
408 | description:
409 | name: vector_math
410 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
411 | url: "https://pub.dev"
412 | source: hosted
413 | version: "2.1.4"
414 | vm_service:
415 | dependency: transitive
416 | description:
417 | name: vm_service
418 | sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
419 | url: "https://pub.dev"
420 | source: hosted
421 | version: "14.2.5"
422 | web:
423 | dependency: transitive
424 | description:
425 | name: web
426 | sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
427 | url: "https://pub.dev"
428 | source: hosted
429 | version: "1.1.0"
430 | webdriver:
431 | dependency: transitive
432 | description:
433 | name: webdriver
434 | sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
435 | url: "https://pub.dev"
436 | source: hosted
437 | version: "3.0.3"
438 | sdks:
439 | dart: ">=3.5.3 <4.0.0"
440 | flutter: ">=3.24.0"
441 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: fast_image_compress_example
2 | description: "Demonstrates how to use the fast_image_compress plugin."
3 | # The following line prevents the package from being accidentally published to
4 | # pub.dev using `flutter pub publish`. This is preferred for private packages.
5 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev
6 |
7 | environment:
8 | sdk: ^3.5.3
9 |
10 | # Dependencies specify other packages that your package needs in order to work.
11 | # To automatically upgrade your package dependencies to the latest versions
12 | # consider running `flutter pub upgrade --major-versions`. Alternatively,
13 | # dependencies can be manually updated by changing the version numbers below to
14 | # the latest version available on pub.dev. To see which dependencies have newer
15 | # versions available, run `flutter pub outdated`.
16 | dependencies:
17 | flutter:
18 | sdk: flutter
19 |
20 | fast_image_compress:
21 | # When depending on this package from a real application you should use:
22 | # fast_image_compress: ^x.y.z
23 | # See https://dart.dev/tools/pub/dependencies#version-constraints
24 | # The example app is bundled with the plugin so we use a path dependency on
25 | # the parent directory to use the current plugin's version.
26 | path: ../
27 |
28 | # The following adds the Cupertino Icons font to your application.
29 | # Use with the CupertinoIcons class for iOS style icons.
30 | cupertino_icons: ^1.0.8
31 | image_picker:
32 |
33 | dev_dependencies:
34 | integration_test:
35 | sdk: flutter
36 | flutter_test:
37 | sdk: flutter
38 |
39 | # The "flutter_lints" package below contains a set of recommended lints to
40 | # encourage good coding practices. The lint set provided by the package is
41 | # activated in the `analysis_options.yaml` file located at the root of your
42 | # package. See that file for information about deactivating specific lint
43 | # rules and activating additional ones.
44 | flutter_lints: ^4.0.0
45 |
46 | # For information on the generic Dart part of this file, see the
47 | # following page: https://dart.dev/tools/pub/pubspec
48 |
49 | # The following section is specific to Flutter packages.
50 | flutter:
51 |
52 | # The following line ensures that the Material Icons font is
53 | # included with your application, so that you can use the icons in
54 | # the material Icons class.
55 | uses-material-design: true
56 |
57 | # To add assets to your application, add an assets section, like this:
58 | # assets:
59 | # - images/a_dot_burr.jpeg
60 | # - images/a_dot_ham.jpeg
61 |
62 | # An image asset can refer to one or more resolution-specific "variants", see
63 | # https://flutter.dev/to/resolution-aware-images
64 |
65 | # For details regarding adding assets from package dependencies, see
66 | # https://flutter.dev/to/asset-from-package
67 |
68 | # To add custom fonts to your application, add a fonts section here,
69 | # in this "flutter" section. Each entry in this list should have a
70 | # "family" key with the font family name, and a "fonts" key with a
71 | # list giving the asset and other descriptors for the font. For
72 | # example:
73 | # fonts:
74 | # - family: Schyler
75 | # fonts:
76 | # - asset: fonts/Schyler-Regular.ttf
77 | # - asset: fonts/Schyler-Italic.ttf
78 | # style: italic
79 | # - family: Trajan Pro
80 | # fonts:
81 | # - asset: fonts/TrajanPro.ttf
82 | # - asset: fonts/TrajanPro_Bold.ttf
83 | # weight: 700
84 | #
85 | # For details regarding fonts from package dependencies,
86 | # see https://flutter.dev/to/font-from-package
87 |
--------------------------------------------------------------------------------
/example/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility in the flutter_test package. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_test/flutter_test.dart';
10 |
11 | import 'package:fast_image_compress_example/main.dart';
12 |
13 | void main() {
14 | testWidgets('Verify Platform version', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(const MyApp());
17 |
18 | // Verify that platform version is retrieved.
19 | expect(
20 | find.byWidgetPredicate(
21 | (Widget widget) =>
22 | widget is Text && widget.data!.startsWith('Running on:'),
23 | ),
24 | findsOneWidget,
25 | );
26 | });
27 | }
28 |
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vagrant/
3 | .sconsign.dblite
4 | .svn/
5 |
6 | .DS_Store
7 | *.swp
8 | profile
9 |
10 | DerivedData/
11 | build/
12 | GeneratedPluginRegistrant.h
13 | GeneratedPluginRegistrant.m
14 |
15 | .generated/
16 |
17 | *.pbxuser
18 | *.mode1v3
19 | *.mode2v3
20 | *.perspectivev3
21 |
22 | !default.pbxuser
23 | !default.mode1v3
24 | !default.mode2v3
25 | !default.perspectivev3
26 |
27 | xcuserdata
28 |
29 | *.moved-aside
30 |
31 | *.pyc
32 | *sync/
33 | Icon?
34 | .tags*
35 |
36 | /Flutter/Generated.xcconfig
37 | /Flutter/ephemeral/
38 | /Flutter/flutter_export_environment.sh
39 | PrivacyInfo.xcprivacy
40 |
41 |
--------------------------------------------------------------------------------
/ios/Classes/FastImageCompressPlugin.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Simform Solutions
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be
12 | * included in all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | import Flutter
24 | import UIKit
25 |
26 | // Define constants used throughout the plugin
27 | enum Constants{
28 | static let methodChannelName = "com.simform.fast_image_compress/compression"
29 | static let compressionMethodName = "compressImage"
30 | static let cancelCompressionMethodName = "cancelCompression"
31 | static let imageData = "imageData"
32 | static let targetWidth = "targetWidth"
33 | static let compressionQuality = "compressionQuality"
34 | static let imageQuality = "imageQuality"
35 | static let high = "high"
36 | static let low = "low"
37 | static let medium = "medium"
38 | }
39 |
40 | // Enum to represent image quality levels and their associated downscaling factors
41 | enum ImageQuality {
42 | case low, medium, high
43 |
44 | var sampleFactor: CGFloat {
45 | switch self {
46 | case .low: return 4.0
47 | case .medium: return 2.0
48 | case .high: return 1.0
49 | }
50 | }
51 | }
52 |
53 | // Main plugin class that implements the FlutterPlugin protocol
54 | public class FastImageCompressPlugin: NSObject, FlutterPlugin {
55 | private var isCancelled = false // Flag to track cancellation of ongoing compression
56 |
57 | // Registers the plugin with the Flutter framework
58 | public static func register(with registrar: FlutterPluginRegistrar) {
59 | let channel = FlutterMethodChannel(name: Constants.methodChannelName, binaryMessenger: registrar.messenger())
60 | let instance = FastImageCompressPlugin()
61 | registrar.addMethodCallDelegate(instance, channel: channel)
62 | }
63 |
64 | // Handles method calls from Flutter
65 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
66 | switch call.method {
67 | case Constants.compressionMethodName:
68 | handleCompression(call: call, result: result) // Handle image compression
69 | case Constants.cancelCompressionMethodName:
70 | handleCancellation(result: result) // Handle cancellation of compression
71 | default:
72 | result(FlutterMethodNotImplemented) // Return not implemented for unknown methods
73 | }
74 | }
75 |
76 | // MARK: - Handlers
77 |
78 | // Handles the image compression logic
79 | private func handleCompression(call: FlutterMethodCall, result: @escaping FlutterResult) {
80 | // Validate and extract arguments from the method call
81 | guard let args = call.arguments as? [String: Any],
82 | let imageData = args[Constants.imageData] as? FlutterStandardTypedData,
83 | let imageQualityInString = args[Constants.imageQuality] as? String else {
84 | result(FlutterError(code: "INVALID_ARGS", message: "Invalid arguments provided", details: nil))
85 | return
86 | }
87 |
88 | // Optional arguments for compression quality and target width
89 | let compressionQuality = args[Constants.compressionQuality] as? Int
90 | let targetWidth = args[Constants.targetWidth] as? Int
91 |
92 | // Determine the image quality based on the provided string
93 | let imageQuality: ImageQuality = {
94 | switch imageQualityInString {
95 | case Constants.high: return .high
96 | case Constants.low: return .low
97 | default: return .medium
98 | }
99 | }()
100 |
101 | isCancelled = false // Reset cancellation flag
102 | // Start resizing and compressing the image
103 | resizeImage(imageData: imageData.data, targetWidth: targetWidth, compressionQuality: compressionQuality, imageQuality: imageQuality, result: result)
104 | }
105 |
106 | // Handles the cancellation of image compression
107 | private func handleCancellation(result: @escaping FlutterResult) {
108 | isCancelled = true // Set the cancellation flag
109 | result(nil) // Acknowledge the cancellation to Flutter
110 | }
111 |
112 | // MARK: - Image Processing
113 |
114 | // Resizes the image and compresses it based on the provided parameters
115 | private func resizeImage(imageData: Data, targetWidth: Int?, compressionQuality: Int? = 80, imageQuality: ImageQuality, result: FlutterResult) {
116 | // Decode the image data into a UIImage
117 | guard let image = UIImage(data: imageData) else {
118 | result(FlutterError(code: "INVALID_IMAGE", message: "Unable to decode image data", details: nil))
119 | return
120 | }
121 |
122 | // Resize the image
123 | let resizedImage = createResizedImage(image: image, targetWidth: targetWidth, imageQuality: imageQuality)
124 | guard let finalImage = resizedImage else {
125 | result(FlutterError(code: "IMAGE_PROCESSING_FAILED", message: "Unable to resize image", details: nil))
126 | return
127 | }
128 |
129 | // Compress the resized image
130 | compressImage(finalImage: finalImage, imageData: imageData, compressionQuality: compressionQuality, result: result)
131 | }
132 |
133 | // Resizes the image to the target width and quality
134 | private func createResizedImage(image: UIImage, targetWidth: Int?, imageQuality: ImageQuality) -> UIImage? {
135 | let factor = imageQuality.sampleFactor // Get the downscaling factor based on quality
136 | var adjustedWidth = image.size.width / factor
137 |
138 | // Adjust the width if a specific target width is provided
139 | if let targetWidth = targetWidth, targetWidth < Int(image.size.width) {
140 | adjustedWidth = CGFloat(targetWidth)
141 | }
142 |
143 | // Calculate the scale and adjusted height
144 | let scale = adjustedWidth / image.size.width
145 | let adjustedHeight = image.size.height * scale
146 |
147 | // Perform the resizing operation
148 | UIGraphicsBeginImageContext(CGSize(width: adjustedWidth, height: adjustedHeight))
149 | image.draw(in: CGRect(x: 0, y: 0, width: adjustedWidth, height: adjustedHeight))
150 | let resizedImage = UIGraphicsGetImageFromCurrentImageContext()
151 | UIGraphicsEndImageContext()
152 |
153 | return resizedImage
154 | }
155 |
156 | // Compresses the resized image and returns the compressed data
157 | private func compressImage(finalImage: UIImage, imageData: Data, compressionQuality: Int?, result: FlutterResult) {
158 | var quality = Double(compressionQuality ?? 80) / 100.0 // Default quality is 80%
159 | var compressedData = finalImage.jpegData(compressionQuality: quality)
160 |
161 | let inputImageSize = imageData.count
162 | var outputImageSize = compressedData?.count ?? Int.max
163 |
164 | // To avoid increasing the size of an already compressed image, compare
165 | // input and output sizes, and use lower compression quality if needed.
166 | if outputImageSize > inputImageSize {
167 | compressedData = performIterativeCompression(finalImage: finalImage, inputImageSize: inputImageSize, initialQuality: quality)
168 | }
169 |
170 | // Return the compressed data or an error if compression failed
171 | if let compressedData = compressedData {
172 | result(FlutterStandardTypedData(bytes: compressedData))
173 | } else {
174 | result(FlutterError(code: "COMPRESSION_FAILED", message: "Failed to compress image", details: nil))
175 | }
176 | }
177 |
178 | // Performs iterative compression to reduce the image size
179 | private func performIterativeCompression(finalImage: UIImage, inputImageSize: Int, initialQuality: Double) -> Data? {
180 | var quality = initialQuality
181 | var updatedCompQuality = Int(quality * 100)
182 | var compressedData: Data?
183 |
184 | // Reduce quality in steps of 10 until the size is acceptable or the minimum quality is reached
185 | repeat {
186 | if isCancelled { return nil } // Exit if the operation is cancelled
187 |
188 | updatedCompQuality -= 10
189 | quality = Double(updatedCompQuality) / 100.0
190 | compressedData = finalImage.jpegData(compressionQuality: quality)
191 | } while (compressedData?.count ?? Int.max) > inputImageSize && updatedCompQuality >= 10
192 |
193 | return updatedCompQuality < 10 ? nil : compressedData
194 | }
195 | }
196 |
--------------------------------------------------------------------------------
/ios/fast_image_compress.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
3 | # Run `pod lib lint fast_image_compress.podspec` to validate before publishing.
4 | #
5 | Pod::Spec.new do |s|
6 | s.name = 'fast_image_compress'
7 | s.version = '0.0.1'
8 | s.summary = 'A Flutter plugin for fast image compression.'
9 | s.description = <<-DESC
10 | A fast image compression plugin which performs compression on large images in parallel.
11 | DESC
12 | s.homepage = 'http://example.com'
13 | s.license = { :file => '../LICENSE' }
14 | s.author = { 'Simform Solutions' => 'developer@simform.com'}
15 | s.source = { :http => 'https://github.com/SimformSolutionsPvtLtd/fast_image_compress/tree/master' }
16 | s.source_files = 'Classes/**/*'
17 | s.dependency 'Flutter'
18 | s.platform = :ios, '12.0'
19 |
20 | # Flutter.framework does not contain a i386 slice.
21 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
22 | s.swift_version = '5.0'
23 |
24 | # If your plugin requires a privacy manifest, for example if it uses any
25 | # required reason APIs, update the PrivacyInfo.xcprivacy file to describe your
26 | # plugin's privacy impact, and then uncomment this line. For more information,
27 | # see https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
28 | # s.resource_bundles = {'fast_image_compress_privacy' => ['Resources/PrivacyInfo.xcprivacy']}
29 | end
30 |
--------------------------------------------------------------------------------
/lib/fast_image_compress.dart:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Simform Solutions
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be
12 | * included in all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | library fast_image_compress;
24 |
25 | export 'src/fast_image_compress.dart';
26 | export 'src/image_compression_service.dart';
27 | export 'src/fast_image_compress/fast_image_compress_method_channel.dart';
28 | export 'src/fast_image_compress/fast_image_compress_platform_interface.dart';
29 |
--------------------------------------------------------------------------------
/lib/src/fast_image_compress.dart:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Simform Solutions
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be
12 | * included in all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | import 'dart:async';
24 | import 'dart:typed_data';
25 |
26 | import '../fast_image_compress.dart';
27 |
28 | class FastImageCompress {
29 | final ImageCompressionService _compressionService = ImageCompressionService();
30 |
31 | /// Get the platform version (already implemented)
32 | Future getPlatformVersion() {
33 | return FastImageCompressPlatform.instance.getPlatformVersion();
34 | }
35 |
36 | final StreamController _progressController =
37 | StreamController.broadcast();
38 | final StreamController _compressImageStreamController =
39 | StreamController.broadcast();
40 | int _completedCount = 0;
41 | bool isCompressionCancelled = false;
42 |
43 | /// Get image compression progress stream
44 | Stream get progressStream => _progressController.stream;
45 |
46 | Stream get compressedImageStream =>
47 | _compressImageStreamController.stream;
48 |
49 | /// Compresses a single image.
50 | ///
51 | /// This function compresses a single image based on the specified quality,
52 | /// target width, and image quality level. It returns the compressed image
53 | /// data or `null` if the compression is cancelled.
54 | ///
55 | /// - [imageData]: The image data as a `Uint8List` to be compressed.
56 | /// - [quality]: The compression quality percentage (default is 80).
57 | /// Must be a value between 0 and 100, where 100 represents the highest quality.
58 | /// - [targetWidth]: The desired width for the compressed image (default is 500).
59 | /// The height will be scaled proportionally to maintain the aspect ratio.
60 | /// - [imageQuality]: The quality of the image to undergo compression. This can be
61 | /// `ImageQuality.high`, `ImageQuality.medium`, or `ImageQuality.low` (default is `ImageQuality.medium`).
62 | ///
63 | /// ### Returns:
64 | /// A `Future` that resolves to the compressed image data as a `Uint8List`,
65 | /// or `null` if the compression is cancelled.
66 | ///
67 | /// ### Throws:
68 | /// - An `AssertionError` if:
69 | /// - [quality] is not between 0 and 100.
70 | /// - [targetWidth] is less than 1.
71 | ///
72 | /// ### Notes:
73 | /// - If `isCompressionCancelled` is set to `true` before or during execution,
74 | /// the function will reset the flag and return `null`.
75 | Future? compressImage({
76 | required Uint8List imageData,
77 | int quality = 60,
78 | int? targetWidth = 500,
79 | ImageQuality imageQuality = ImageQuality.medium,
80 | }) {
81 | assert(
82 | quality > 0 || quality < 100,
83 | 'quality value should be between 0 to 100',
84 | );
85 | if (targetWidth != null) {
86 | assert(targetWidth > 1, "targetWidth can't be less than 1");
87 | }
88 |
89 | if (isCompressionCancelled) {
90 | isCompressionCancelled = false;
91 | return null;
92 | }
93 | return _compressionService.compressImage(
94 | imageData,
95 | quality,
96 | targetWidth,
97 | imageQuality,
98 | );
99 | }
100 |
101 | /// Compresses a list of images in batches.
102 | ///
103 | /// This function processes a list of images, compressing them based on the
104 | /// specified quality, target width, and image quality level. Images are
105 | /// processed in parallel batches to optimize performance.
106 | ///
107 | /// - [images]: A list of `Uint8List` objects representing the images to be compressed.
108 | /// - [quality]: The compression quality percentage (default is 80).
109 | /// Must be a value between 0 and 100, where 100 represents the highest quality.
110 | /// - [targetWidth]: The desired width for the compressed images (default is 500).
111 | /// The height will be scaled proportionally to maintain the aspect ratio.
112 | /// - [batchSize]: The number of images to process simultaneously in a batch (default is 3).
113 | /// Must be at least 1.
114 | /// - [imageQuality]: The quality of the image to undergo compression. This can be
115 | /// `ImageQuality.high`, `ImageQuality.medium`, or `ImageQuality.low` (default is `ImageQuality.medium`).
116 | ///
117 | /// ### Returns:
118 | /// A `Future` that resolves to a `List` containing the compressed images.
119 | ///
120 | /// ### Throws:
121 | /// - An `AssertionError` if:
122 | /// - [quality] is not between 0 and 100.
123 | /// - [targetWidth] is less than 1.
124 | /// - [batchSize] is less than 1.
125 | ///
126 | /// ### Notes:
127 | /// - Compression can be cancelled during execution by setting `isCompressionCancelled`
128 | /// to `true`. Cancelled images will not be included in the result.
129 | /// - Progress of the compression process is reported via the `_progressController`.
130 | Future> compressImageList({
131 | required List images,
132 | int quality = 60,
133 | int? targetWidth,
134 | int batchSize = 3,
135 | ImageQuality imageQuality = ImageQuality.medium,
136 | }) async {
137 | assert(
138 | quality > 0 || quality < 100,
139 | 'quality value should be between 0 to 100',
140 | );
141 | if (targetWidth != null) {
142 | assert(targetWidth > 1, "targetWidth can't be less than 1");
143 | }
144 | assert(batchSize >= 1, "batchSize should be greater than or equal to 1");
145 | List compressedImages = [];
146 | _completedCount = 0;
147 |
148 | for (var i = 0; i < images.length; i += batchSize) {
149 | final batch = images.skip(i).take(batchSize).toList();
150 |
151 | await Future.wait(batch.map((image) async {
152 | if (isCompressionCancelled) return;
153 | final compressedImage = await _compressionService.compressImage(
154 | image,
155 | quality,
156 | targetWidth,
157 | imageQuality,
158 | );
159 | if (compressedImage != null) {
160 | compressedImages.add(compressedImage);
161 | _completedCount++;
162 | _progressController.add(_completedCount);
163 | _compressImageStreamController.add(compressedImage);
164 | }
165 | }));
166 | }
167 | isCompressionCancelled = false;
168 | return compressedImages;
169 | }
170 |
171 | /// Cancels the ongoing image compression process.
172 | Future cancelCompression() async {
173 | isCompressionCancelled = true;
174 | await _compressionService.cancelCompression();
175 | }
176 |
177 | /// Dispose resources
178 | void dispose() {
179 | _progressController.close();
180 | _compressImageStreamController.close();
181 | _compressionService.dispose();
182 | }
183 | }
184 |
--------------------------------------------------------------------------------
/lib/src/fast_image_compress/fast_image_compress_method_channel.dart:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Simform Solutions
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be
12 | * included in all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | import 'package:flutter/foundation.dart';
24 | import 'package:flutter/services.dart';
25 |
26 | import 'fast_image_compress_platform_interface.dart';
27 |
28 | /// An implementation of [FastImageCompressPlatform] that uses method channels.
29 | class MethodChannelFastImageCompress extends FastImageCompressPlatform {
30 | /// The method channel used to interact with the native platform.
31 | @visibleForTesting
32 | final methodChannel = const MethodChannel('fast_image_compress');
33 |
34 | @override
35 | Future getPlatformVersion() async {
36 | final version =
37 | await methodChannel.invokeMethod('getPlatformVersion');
38 | return version;
39 | }
40 |
41 | @override
42 | Future compressImage(
43 | Uint8List imageData,
44 | int? targetWidth,
45 | int compressionQuality,
46 | String imageQuality,
47 | ) async {
48 | try {
49 | final result = await methodChannel.invokeMethod(
50 | 'compressImage',
51 | {
52 | 'imageData': imageData,
53 | 'targetWidth': targetWidth,
54 | 'compressionQuality': compressionQuality,
55 | 'imageQuality': imageQuality,
56 | },
57 | );
58 | return result;
59 | } catch (e) {
60 | // Handle any exceptions that might occur
61 | throw PlatformException(
62 | code: 'COMPRESS_IMAGE_FAILED',
63 | message: 'Failed to compress the image: $e',
64 | );
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/lib/src/fast_image_compress/fast_image_compress_platform_interface.dart:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Simform Solutions
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be
12 | * included in all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | import 'dart:typed_data';
24 |
25 | import 'package:plugin_platform_interface/plugin_platform_interface.dart';
26 |
27 | import 'fast_image_compress_method_channel.dart';
28 |
29 | abstract class FastImageCompressPlatform extends PlatformInterface {
30 | /// Constructs a FastImageCompressPlatform.
31 | FastImageCompressPlatform() : super(token: _token);
32 |
33 | static final Object _token = Object();
34 |
35 | static FastImageCompressPlatform _instance = MethodChannelFastImageCompress();
36 |
37 | /// The default instance of [FastImageCompressPlatform] to use.
38 | ///
39 | /// Defaults to [MethodChannelFastImageCompress].
40 | static FastImageCompressPlatform get instance => _instance;
41 |
42 | /// Platform-specific implementations should set this with their own
43 | /// platform-specific class that extends [FastImageCompressPlatform] when
44 | /// they register themselves.
45 | static set instance(FastImageCompressPlatform instance) {
46 | PlatformInterface.verifyToken(instance, _token);
47 | _instance = instance;
48 | }
49 |
50 | Future getPlatformVersion() {
51 | throw UnimplementedError('platformVersion() has not been implemented.');
52 | }
53 |
54 | /// Compress an image given its byte data and target width.
55 | Future compressImage(
56 | Uint8List imageData,
57 | int? targetWidth,
58 | int compressionQuality,
59 | String imageQuality,
60 | ) {
61 | throw UnimplementedError('compressImage() has not been implemented.');
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/lib/src/image_compression_service.dart:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Simform Solutions
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be
12 | * included in all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | import 'dart:async';
24 | import 'dart:isolate';
25 |
26 | import 'package:fast_image_compress/values/constants.dart';
27 | import 'package:flutter/services.dart';
28 |
29 | class ImageCompressionService {
30 | SendPort? _isolateSendPort;
31 | Isolate? _isolate;
32 | bool isInitialized = false;
33 | static const platform = MethodChannel(Constants.methodChannelName);
34 |
35 | Future initializeIsolate() async {
36 | if (_isolate != null) return;
37 | final receivePort = ReceivePort();
38 | final initData = (RootIsolateToken.instance!, receivePort.sendPort);
39 | _isolate = await Isolate.spawn(_isolateMain, initData);
40 | _isolateSendPort = await receivePort.first as SendPort;
41 | isInitialized = true;
42 | }
43 |
44 | Future compressImage(
45 | Uint8List imageData,
46 | int quality,
47 | int? targetWidth,
48 | ImageQuality imageQuality,
49 | ) async {
50 | if (!isInitialized) await initializeIsolate();
51 | final responsePort = ReceivePort();
52 | _isolateSendPort!.send({
53 | Constants.imageData: imageData,
54 | Constants.quality: quality,
55 | Constants.targetWidth: targetWidth,
56 | Constants.port: responsePort.sendPort,
57 | Constants.imageQuality: imageQuality
58 | });
59 | return await responsePort.first as Uint8List?;
60 | }
61 |
62 | static void _isolateMain(
63 | (RootIsolateToken rootToken, SendPort sendPort) params,
64 | ) {
65 | final receivePort = ReceivePort();
66 | params.$2.send(receivePort.sendPort);
67 |
68 | BackgroundIsolateBinaryMessenger.ensureInitialized(params.$1);
69 |
70 | receivePort.listen((message) async {
71 | if (message is Map) {
72 | try {
73 | final imageData = message[Constants.imageData] as Uint8List;
74 | final quality = message[Constants.quality] as int;
75 | final targetWidth = message[Constants.targetWidth] as int?;
76 | final responsePort = message[Constants.port] as SendPort;
77 | final imageQuality = message[Constants.imageQuality] as ImageQuality;
78 |
79 | Uint8List? processedImage;
80 | processedImage = await imageCompress(
81 | imageData,
82 | targetWidth,
83 | quality,
84 | imageQuality.name,
85 | );
86 |
87 | responsePort.send(processedImage);
88 | } catch (_) {
89 | message[Constants.port].send(null);
90 | }
91 | }
92 | });
93 | }
94 |
95 | static Future imageCompress(
96 | Uint8List imageData,
97 | int? targetWidth,
98 | int compressionQuality,
99 | String imageQuality,
100 | ) async {
101 | try {
102 | final message = {
103 | Constants.imageData: imageData,
104 | Constants.targetWidth: targetWidth,
105 | Constants.compressionQuality: compressionQuality,
106 | Constants.imageQuality: imageQuality,
107 | };
108 | final resizedImage = await platform.invokeMethod(
109 | Constants.compressImageMethodName,
110 | message,
111 | );
112 | return resizedImage;
113 | } on PlatformException catch (_) {
114 | return null;
115 | }
116 | }
117 |
118 | Future cancelCompression() async {
119 | await platform.invokeMethod(Constants.cancelCompressionMethodName);
120 | }
121 |
122 | void dispose() {
123 | _isolate?.kill();
124 | _isolate = null;
125 | }
126 | }
127 |
128 | enum ImageQuality {
129 | low,
130 | medium,
131 | high;
132 | }
133 |
--------------------------------------------------------------------------------
/lib/values/constants.dart:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Simform Solutions
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be
12 | * included in all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | class Constants {
24 | const Constants._();
25 | static const String methodChannelName =
26 | 'com.simform.fast_image_compress/compression';
27 | static const String compressImageMethodName = 'compressImage';
28 | static const String cancelCompressionMethodName = 'cancelCompression';
29 | static const String imageData = 'imageData';
30 | static const String quality = 'quality';
31 | static const String compressionQuality = 'compressionQuality';
32 | static const String targetWidth = 'targetWidth';
33 | static const String imageQuality = 'imageQuality';
34 | static const String port = 'port';
35 | }
36 |
--------------------------------------------------------------------------------
/preview/android_comparison_graph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/preview/android_comparison_graph.png
--------------------------------------------------------------------------------
/preview/banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/preview/banner.png
--------------------------------------------------------------------------------
/preview/iOS_comparison_graph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimformSolutionsPvtLtd/fast_image_compress/1af0277549c8e4defeb171f05f744ca5e7474075/preview/iOS_comparison_graph.png
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: fast_image_compress
2 | description: "A Flutter plugin that allows you to compress images easily and quickly."
3 | version: 0.0.3
4 | homepage: "https://github.com/SimformSolutionsPvtLtd/fast_image_compress"
5 | issue_tracker: "https://github.com/SimformSolutionsPvtLtd/fast_image_compress/issues"
6 | topics:
7 | - image-compression
8 | - image-processing
9 | - parallel-processing
10 | - image
11 | - compression
12 |
13 | environment:
14 | sdk: ^3.5.3
15 | flutter: '>=3.3.0'
16 |
17 | dependencies:
18 | flutter:
19 | sdk: flutter
20 | plugin_platform_interface: ^2.0.2
21 |
22 |
23 | dev_dependencies:
24 | flutter_test:
25 | sdk: flutter
26 | flutter_lints: ^4.0.0
27 | pana:
28 |
29 | # For information on the generic Dart part of this file, see the
30 | # following page: https://dart.dev/tools/pub/pubspec
31 |
32 | # The following section is specific to Flutter packages.
33 | flutter:
34 | # This section identifies this Flutter project as a plugin project.
35 | # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.)
36 | # which should be registered in the plugin registry. This is required for
37 | # using method channels.
38 | # The Android 'package' specifies package in which the registered class is.
39 | # This is required for using method channels on Android.
40 | # The 'ffiPlugin' specifies that native code should be built and bundled.
41 | # This is required for using `dart:ffi`.
42 | # All these are used by the tooling to maintain consistency when
43 | # adding or updating assets for this project.
44 | plugin:
45 | platforms:
46 | android:
47 | package: com.example.fast_image_compress
48 | pluginClass: FastImageCompressPlugin
49 | ios:
50 | pluginClass: FastImageCompressPlugin
51 |
52 | # To add assets to your plugin package, add an assets section, like this:
53 | # assets:
54 | # - images/a_dot_burr.jpeg
55 | # - images/a_dot_ham.jpeg
56 | #
57 | # For details regarding assets in packages, see
58 | # https://flutter.dev/to/asset-from-package
59 | #
60 | # An image asset can refer to one or more resolution-specific "variants", see
61 | # https://flutter.dev/to/resolution-aware-images
62 |
63 | # To add custom fonts to your plugin package, add a fonts section here,
64 | # in this "flutter" section. Each entry in this list should have a
65 | # "family" key with the font family name, and a "fonts" key with a
66 | # list giving the asset and other descriptors for the font. For
67 | # example:
68 | # fonts:
69 | # - family: Schyler
70 | # fonts:
71 | # - asset: fonts/Schyler-Regular.ttf
72 | # - asset: fonts/Schyler-Italic.ttf
73 | # style: italic
74 | # - family: Trajan Pro
75 | # fonts:
76 | # - asset: fonts/TrajanPro.ttf
77 | # - asset: fonts/TrajanPro_Bold.ttf
78 | # weight: 700
79 | #
80 | # For details regarding fonts in packages, see
81 | # https://flutter.dev/to/font-from-package
82 |
--------------------------------------------------------------------------------