搜索插件、代码仓与 APP 分类

editable_image 封面
插件详情v2.0.0

editable_image

用于创建完全可自定义和可编辑图像控件的 Flutter 包。

AndroidiOSmacOS
近 30 天下载
55
喜欢数
48
Pub 分数
140

安装插件

flutter pub add editable_image

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,可创建完全可自定义且可编辑的图像小部件,允许用户在应用内直接修改图像。它支持交互式功能,如裁剪、调整大小和定位,非常适合用于个人资料图片、头像和聊天气泡。该包专为 Android、iOS 和 macOS 平台的无缝集成而设计,为开发者提供 UI 设计和用户交互方面的灵活性。凭借简洁的 API 和响应式行为,它提升了需要动态图像处理的应用程序的用户体验。

适合场景

  • 个人资料图片编辑
  • 头像自定义
  • 聊天头像修改
  • 用户生成内容创作
  • 交互式图像叠加

主要特点

  • 可自定义的图像编辑
  • 跨平台支持(Android、iOS、macOS)
  • 交互式裁剪和调整大小
  • 响应式 UI 组件
  • 与现有 Flutter 应用轻松集成

适合对象

  • 社交媒体应用
  • 用户配置文件管理
  • 消息应用
  • 照片编辑工具
  • 自定义 UI 组件

使用建议

  • 需要仔细处理图像分辨率
  • 可能会影响大图像的性能
  • 仅限基本编辑功能
  • 不适合高级照片编辑
  • 依赖于平台特定的渲染行为

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Editable Image | Flutter Package

Flutter package for creating a fully customizable and editable image widget. The package has been written solely in Dart Language.

 

editable_image_gif_1 editable_image_gif_2

 

Features

A powerful and fully customizable widget. It provides a custom widget to save time.

For example, almost in every profile settings interface, etc., there is a profile image. Instead of writing from scratch, this widget can be used and can save a lot of time.

 

 

Getting started

Let's take a look at how to implement EditableImage to fastly create user interfaces for profile picture edit, etc.

First, add following line to pubspec.yaml:

editable_image: ^2.0.0

Second, import EditableImage:

import 'package:editable_image/editable_image.dart';

Lastly, make platform-specific setups by applying the following instructions.

Android Setup
  • The minimum required SDK version is 21. Therefore, please find the following line inside android/app/build.gradle and modify it:
compileSdkVersion 33
..
..
..
minSdkVersion 21
targetSdkVersion 33
  • Please upgrade the Kotlin version (ext.kotlin_version) to 1.7.0 or the latest version. To do that, find the following line inside android/build.gradle and modify it:
ext.kotlin_version = '1.7.0'
  • Please upgrade the Gradle version (ext.kotlin_version) to 6.8.3 or the latest version but lower than 7.0.0. To do that, find the following line inside android/gradle/wrapper/gradle-wrapper.properties and modify it:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
  • Please go to your project folder and add android:exported="true" to AndroidManifest.xml file
<activity
     android:name=".MainActivity"
     android:exported="true"
     android:launchMode="singleTop"
     android:theme="@style/LaunchTheme"
 </activity>
  • Required permissions: READ_EXTERNAL_STORAGE. Please modify android/app/src/main/AndroidManifest.xml and update accordingly:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  • I recommand you add android:requestLegacyExternalStorage="true" to AndroidManifest.xml. Therefore, please modify android/app/src/main/AndroidManifest.xml and add the following line inside application:
<application android:requestLegacyExternalStorage="true"</application>

If you found some warning logs with Glide appearing, then the main project needs an implementation of AppGlideModule. See Generated API.

iOS Setup
  • Platform version must be at least 9.0. Please modify ios/Podfile and update accordingly:
platform :ios, '11.0'
  • Add the following lines to ios/Runner/Info.plist:
<key>NSAppTransportSecurity</key>
<dict>
	<key>NSAllowsArbitraryLoads</key>
	<true/>
</dict>
<key>NSPhotoLibraryUsageDescription</key>
<string>Put here your permission description.</string>
macOS Setup
  • Platform version must be at least 10.15. Please modify macos/Podfile and update accordingly:
platform :osx, '10.15'
  • Please set the minimum deployment target to 10.15. Use XCode to open macos/Runner.xcworkspace:

  • Follow the iOS instructions and modify ios/Runner/Info.plist accordingly.

 

Usage

Basic usage example:

main.dart

// A simple usage of EditableImage.
// This method gets called when trying to change an image.
void _directUpdateImage(File? file) async {
    if (file == null) return;

    setState(() {
      _profilePicFile = file;
    });
}

EditableImage(
// Define the method that will run on the change process of the image.
onChange: (file) => _directUpdateImage(file),

// Define the source of the image.
image: _profilePicFile != null
    ? Image.file(_profilePicFile!, fit: BoxFit.cover)
    : null,

// Define the size of EditableImage.
size: 150.0,

// Define the Theme of image picker.
imagePickerTheme: ThemeData(
    // Define the default brightness and colors.
    primaryColor: Colors.white,
    shadowColor: Colors.transparent,
    backgroundColor: Colors.white70,
    iconTheme: const IconThemeData(color: Colors.black87),

    // Define the default font family.
    fontFamily: 'Georgia',
),

// Define the border of the image if needed.
imageBorder: Border.all(color: Colors.black87, width: 2.0),

// Define the border of the icon if needed.
editIconBorder: Border.all(color: Colors.black87, width: 2.0),
),

 

Example

More examples can be found in /example folder on GitHub.

User Profile 1 - an example of basic implementation of EditableImage. Simple project that simulates user profile edit screen.

User Profile 2 - an example of implementation of EditableImage. Simple project that simulates user profile edit screen.

 

Additional information

This package has been written solely in Dart Language yet it has the wechat_assets_picker as a dependency. Therefore, EditableImage currently supports only Android, iOS, and macOS platforms. In the future, other platform supports may be added.

For more information please visit GitHub.

 

Feature requests and bugs

Please file feature requests and bugs at the issue tracker.

 

Maintainers

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。