パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.0.6

image_crop_widget

画像を切り抜くためのFlutterウィジェット。このウィジェットは完全にDartで記述されており、最小限の依存関係を持っています。

30日間ダウンロード
28
いいね数
9
Pub ポイント
40

パッケージをインストール

flutter pub add image_crop_widget

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

アプリ内で画像を直接切り抜くために設計されたFlutterウィジェットです。Dartで完全に構築されており、最小限の依存関係で、画像操作のための軽量かつ効率的なソリューションを提供します。選択および切り抜き領域の調整を行うための直感的なコントロールを備えており、プロフィール画像の編集や画像前処理に最適です。Flutterプロジェクトにスムーズに統合でき、さまざまな画面サイズでの応答性のあるデザインをサポートしています。

用途

  • プロフィール画像の切り抜き
  • アップロード前の画像前処理
  • ユーザー生成コンテンツの編集
  • アプリ内の写真編集ツール
  • カスタム画像選択ワークフロー

主な機能

  • 純粋なDart実装
  • 最小限の依存関係
  • レスポンシブUI
  • 直感的なドラッグアンドドロップのクロップコントロール
  • Flutter プロジェクトとの簡単な統合

適している対象

  • 画像が多く含まれるアプリを開発する開発者
  • ユーザーの画像を切り取る必要があるアプリ
  • 軽量な依存関係を重視するプロジェクト
  • シンプルなソリューションを探しているフロントエンド開発者
  • 画像編集が必要なモバイルアプリの機能

注意事項

  • 基本的な切り取り機能に限定
  • 組み込みの画像フィルターや強化機能なし
  • 切り抜き画像出力の手動処理が必要
  • 非常に大きな画像には最適化されていません
  • 複数のクロップ領域を同時にサポートしていません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

image_crop_widget

A Flutter widget to crop images. The widget is completely written in Dart and has minimal dependencies.

The widget displays the image within the given layout space. On top of the image a transparent rectangular overlay, with handles on each corner, is drawn. The overlay handles can be dragged by touch to adjust the cropping area.

Example

By calling the cropImage() method on the widget's state object, the image area that is marked by the overlay is returned as a new image object.

To acquire the widget's state you can use a GlobalKey object.

Example:

import 'dart:ui'; // This imports the 'Image' class.

final key = GlobalKey<ImageCropState>();
Image imageObject = ...

...

ImageCrop(key: key, image: imageObject) // This could be used inside a  build method.

...
await key.currentState.rotateImage(); // Rotate the image be 90° clockwise.
final cropedImage = await key.currentState.cropImage(); // This could be used inside a 'onPress' handler method.

How to create an image object

The Image class from dart:ui is typically not instantiated directly. Instead, you could convert your image data into a Uint8List and instantiate the image like this:

Uint8List bytes = ...
final codec = await instantiateImageCodec(bytes);
final frame = await codec.getNextFrame();
final image = frame.image;

How to display an image object

The Image object can be displayed with the Flutter Image widget. One way to do this, is by converting the image into a Uint8List and pass it into the widget's memory constructor. Please note, that the widget is not the same Image class as the image object itself.

final cropedImage = await key.currentState.cropImage();
final byte = await cropedImage.toByteData(format: ui.ImageByteFormat.png);
final byteList = byte.buffer.asUint8List();

Image.memory(byteList)

How to persist an image object

The Image object can be persisted into a file or a database. To do this, you can convert the image object into a Uint8List and write it into a File or your database object.

final cropedImage = await key.currentState.cropImage();
final byte = await cropedImage.toByteData(format: ui.ImageByteFormat.png);
final byteList = byte.buffer.asUint8List();

final imageFile = File("Some path and filename"); // You can use the path_provider package to locate the right path.
final result = await imageFile.writeAsBytes(byteList);

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。