flutter_native_image
This project is based on flutter_native_image.
1. Installation and Usage
1.1 Installation
Go to the project directory and add the following dependencies in pubspec.yaml
pubspec.yaml
...
dependencies:
flutter_native_image:
git:
url: https://gitcode.com/CPF-Flutter/flutter_native_image.git
# ref: Select the TAG version adapted to different frameworks according to the table below
ref: 0.0.6_1-ohos-1.0.0
...
Execute Command
flutter pub get
TAG naming rule:
original version-ohos-version-number, changes between different TAGs are detailed in CHANGELOG.OpenHarmony.md.
| Flutter Framework Version | TAG Name | Branch Name |
|---|---|---|
| 3.7 | 0.0.6_1-ohos-1.0.0 | master |
| 3.22 | - | - |
| 3.27 | 0.0.6_1-ohos-1.0.0 | master |
| 3.35 | 0.0.6_1-ohos-1.0.0 | master |
1.2 Usage
For use cases ohos/example.
2. Constraints
2.1 Compatibility
This document is verified based on the following versions:
- Flutter: 3.7.12-ohos-1.1.3; SDK: 5.0.0(12); IDE: DevEco Studio: 5.1.0.828; ROM: 5.1.0.130 SP8;
- Flutter: 3.22.1-ohos-1.0.3; SDK: 5.0.0(12); IDE: DevEco Studio: 5.1.0.828; ROM: 5.1.0.130 SP8;
- Flutter: 3.35.8-ohos-0.0.1-canary1; SDK: 6.0.1(21); IDE: DevEco Studio: 6.0.1.260; ROM: 6.0.0.130 SP8;
3. API
If the value of **ohos Support** is **yes**, it means that the ohos platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android.
| Name | Description | Type | Input | Output | ohos Support |
|---|---|---|---|---|---|
| compressImage | Compress an image | function | String fileName,{int percentage = 70,int quality = 70,int targetWidth = 0,int targetHeight = 0} | Future | yes |
| getImageProperties | Gets the properties of an image | function | String fileName | Future | yes |
| cropImage | Crops an image | function | String fileName, int originX, int originY, int width, int height | Future | yes |
4. Properties
If the value of **ohos Support** is **yes**, it means that the ohos platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android.
4.1 compressImage
| Name | Description | Type | Input | Output | ohos Support |
|---|---|---|---|---|---|
| fileName | Path of the image file to compress | String | / | / | yes |
| percentage | Resize percentage (0-100) for scaling | int | / | / | yes |
| quality | Compression quality (0-100) | int | / | / | yes |
| targetWidth | Target width in pixels (overrides percentage) | int | / | / | yes |
| targetHeight | Target height in pixels (overrides percentage) | int | / | / | yes |
4.2 ImageProperties
| Name | Description | Type | Input | Ouput | ohos Support |
|---|---|---|---|---|---|
| width | Width of the image | int? | / | / | yes |
| height | Height of the image | int? | / | / | yes |
| orientation | Orientation flag | ImageOrientation | / | / | yes |
4.3 cropImage
| Name | Description | Type | Input | Output | ohos Support |
|---|---|---|---|---|---|
| fileName | Path of the image file to crop | String | / | / | yes |
| originX | X-coordinate of crop origin | int | / | / | yes |
| originY | Y-coordinate of crop origin | int | / | / | yes |
| width | Width of the crop area | int | / | / | yes |
| height | Height of the crop area | int | / | / | yes |
5. Known Issues
6. Others
7. License
This project is licensed under The MIT License.