fluttercandies / extended_image

A powerful official extension library of image, which support placeholder(loading)/ failed state, cache network, zoom pan image, photo view, slide out page, editor(crop,rotate,flip), paint custom etc.
https://fluttercandies.github.io/extended_image/
MIT License
1.91k stars 500 forks source link

Not able to identify that cropping event was finished. #589

Closed BalajiKrish0705 closed 1 year ago

BalajiKrish0705 commented 1 year ago

In my situation, I aim to crop an image and subsequently perform edits such as adjusting brightness. Currently, the cropped image is obtained by utilizing the "cropImageDataWithNativeLibrary()" method using image_editor package, upon clicking a button. However, I desire to retrieve the cropped image without relying on a button click. Instead, I seek to obtain the image through this method after the completion of the cropping event, similar to utilizing "onPanEnd" in a gesture detector widget or "onChangeEnd" in a slider widget. Is there a solution to address this issue?

Main.dart file

import 'package:flutter/material.dart';
import 'package:extended_image/extended_image.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Image Editing Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: ImageEditingPage(),
    );
  }
}

class ImageEditingPage extends StatefulWidget {
  @override
  _ImageEditingPageState createState() => _ImageEditingPageState();
}

class _ImageEditingPageState extends State<ImageEditingPage> {
  GlobalKey<ExtendedImageEditorState> editorKey =
      GlobalKey<ExtendedImageEditorState>();
  bool _cropping = false;
  bool _editing = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Image Editing Demo'),
      ),
      body: Center(
        child: Column(
          children: [
            SizedBox(height: 20),
            ElevatedButton(
              child: Text('Crop Image'),
              onPressed: _cropping ? null : _startCropping,
            ),
            SizedBox(height: 20),
            ElevatedButton(
              child: Text('Rotate Image'),
              onPressed: _editing ? null : () => _startEditing(),
            ),
            SizedBox(height: 20),
            ElevatedButton(
              child: Text('Flip Image'),
              onPressed: _editing ? null : () => _startEditing(),
            ),
            SizedBox(height: 20),
            ElevatedButton(
              child: Text('Reset Image'),
              onPressed: _editing ? null : _resetImage,
            ),
            SizedBox(height: 20),
            Expanded(
              child: ExtendedImage.network(
                'https://photo.tuchong.com/4870004/f/298584322.jpg', // Replace with your image URL
                fit: BoxFit.contain,
                mode: ExtendedImageMode.editor,
                extendedImageEditorKey: editorKey,
              ),
            ),
          ],
        ),
      ),
    );
  }

  void _startCropping() {
    setState(() {
      _cropping = true;
    });
  }

  void _startEditing() {
    setState(() {
      _editing = true;
      editorKey.currentState?.rotate();
    });
    editorKey.currentState?.editAction;
  }

  void _resetImage() {
    editorKey.currentState?.reset();
  }
}
zmtzawqlp commented 1 year ago

I couldn't get your point.

BalajiKrish0705 commented 1 year ago

I would like to determine if there is a method available to recognize when the cropping event has concluded. Currently, the "editActionDetailsIsChanged" method provides information about each movement during the cropping process. However, I specifically want to identify the point at which the cropping event is completely finished.

zmtzawqlp commented 1 year ago

cropping event? croping is base on the user code, it's not refer to this library

zmtzawqlp commented 1 year ago

reopen it if have any more info