Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnCrop not fired #101

Open
talamaska opened this issue May 11, 2023 · 8 comments
Open

OnCrop not fired #101

talamaska opened this issue May 11, 2023 · 8 comments

Comments

@talamaska
Copy link

talamaska commented May 11, 2023

Hi, just tried to update my dependency image package to latest 4.0.17 and after calling controller.crop() I see the Status is changing but the callback onCrop is not called.

@gliitterpuke
Copy link

Experiencing the same

@chooyan-eng
Copy link
Owner

@talamaska @gliitterpuke I couldn't reproduce the issue with an example app. Can you provide your flutter doctor and the minimum code which reproduces the issue?

@chooyan-eng
Copy link
Owner

And can you try again with 0.7.5, the latest version?

@talamaska
Copy link
Author

e the issue with an example app. Can you provi

It was reproduced on older flutter. and previous version of the package
[√] Flutter (Channel stable, 3.7.12, on Microsoft Windows [Version 10.0.19045.3086], locale bg-BG)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Professional 2022 17.5.4)
[√] Android Studio (version 2022.2)
[√] VS Code (version 1.79.2)
[√] Connected device (4 available)
[√] HTTP Host Availability

I haven't had a chance to upgrade flutter and the package yet

@chooyan-eng
Copy link
Owner

chooyan-eng commented Jun 30, 2023

@talamaska I switched my flutter version to 3.7.12 using FVM and 0.7.4 of crop_your_image, but I still couldn't reproduce the issue.

I'm waiting for your result of trying the latest version and the minimum code that reproduces the issue.

$ fvm flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.12, on macOS 12.5.1 21G83 darwin-arm64, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.73.0)
[✓] VS Code (version 1.61.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

• No issues found!

@krystof-cejchan
Copy link

I have the same issue.
The onCrop is never fired, however using crop() method works fine, however I need to access the image data, not just show it.

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.13.2, on Microsoft Windows [Version 10.0.19045.3448], locale cs-CZ)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.18)
[√] Android Studio (version 2022.2)
[√] IntelliJ IDEA Community Edition (version 2021.3)
[√] VS Code (version 1.82.2)
[√] Connected device (4 available)
[√] Network resources

• No issues found!

and my code is the following, the class requires bytes of the input image.

import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:crop_your_image/crop_your_image.dart';
import 'package:phone_client/image_transformation/image2graph.dart';

class ImageCropping extends StatefulWidget {
  const ImageCropping({Key? key, required this.imageData}) : super(key: key);
  final Uint8List imageData;

  @override
  State<ImageCropping> createState() => _ImageCroppingState(imageData);
}

class _ImageCroppingState extends State<ImageCropping>
    with WidgetsBindingObserver {
  _ImageCroppingState(this.imageData);

  final Uint8List imageData;
  final CropController _cropController = CropController();

  late Uint8List _croppedData = imageData;

  final Color backgroundColour = const Color.fromARGB(255, 0, 204, 17);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: GestureDetector(
          child: Crop(
            controller: _cropController,
            image: imageData,
            onCropped: (croppedData) => setState(() {
              _croppedData = croppedData;
            }),
            initialAreaBuilder: (rect) => Rect.fromLTRB(rect.left + 54,
                rect.top + 62, rect.right - 54, rect.bottom - 62),
            cornerDotBuilder: (size, edgeAlignment) =>
                const DotControl(color: Color.fromARGB(255, 0, 204, 17)),
            interactive: true,
            baseColor: backgroundColour,
            fixArea: false,
          ),
        ),
        floatingActionButtonLocation:
            FloatingActionButtonLocation.miniEndDocked,
        floatingActionButton: FloatingActionButton.small(
            backgroundColor: Colors.black87,
            foregroundColor: const Color.fromARGB(255, 75, 189, 0),
            onPressed: () => _crop(context),
            child: const Icon(Icons.done_all_rounded)));
  }

  void _crop(BuildContext context) {
    Navigator.push(
      context,
      MaterialPageRoute(
          builder: (context) => ImageTransformation(imageData: _croppedData)),
    );
  }
}

@talamaska
Copy link
Author

talamaska commented Oct 26, 2023

I can confirm image: ^4.1.3 and crop_your_image: ^0.7.5 plus flutter 3.13.8 the callback is firing again.

@justprodev
Copy link
Contributor

justprodev commented Mar 4, 2024

Hi, @chooyan-eng

Please correct me if I wrong, but seems that you don't handle error when calling ImageImageCropper finally.

Now I got InvalidRectError by somehow on Xiaomi K50 pro and don't see any feedback from the crop_your_image library. Why that error happens is another story, but error should be handled.

May be some way to get errors should be introduced.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants