flutter-custom-image-crop icon indicating copy to clipboard operation
flutter-custom-image-crop copied to clipboard

The app “Runner” has been killed by the operating system because it is using too much memory.

Open Fahmisbas opened this issue 1 year ago • 2 comments

the example app is crashed when building.

Flutter SDK version 3.22.2 custom_image_crop: ^0.0.13

the entire code:

import 'dart:math';

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

void main() => runApp(MyHomePage(
      title: 'test',
    ));

class MyHomePage extends StatefulWidget {
  final String title;

  MyHomePage({
    required this.title,
    Key? key,
  }) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late CustomImageCropController controller;

  @override
  void initState() {
    super.initState();
    controller = CustomImageCropController();
  }

  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Column(
          children: [
            Expanded(
              child: CustomImageCrop(
                cropController: controller,
                image: const AssetImage(
                    'assets/test.png'), // Any Imageprovider will work, try with a NetworkImage for example...
              ),
            ),
            Row(
              children: [
                IconButton(
                    icon: const Icon(Icons.refresh),
                    onPressed: controller.reset),
                IconButton(
                    icon: const Icon(Icons.zoom_in),
                    onPressed: () =>
                        controller.addTransition(CropImageData(scale: 1.33))),
                IconButton(
                    icon: const Icon(Icons.zoom_out),
                    onPressed: () =>
                        controller.addTransition(CropImageData(scale: 0.75))),
                IconButton(
                    icon: const Icon(Icons.rotate_left),
                    onPressed: () => controller
                        .addTransition(CropImageData(angle: -pi / 4))),
                IconButton(
                    icon: const Icon(Icons.rotate_right),
                    onPressed: () =>
                        controller.addTransition(CropImageData(angle: pi / 4))),
                IconButton(
                  icon: const Icon(Icons.crop),
                  onPressed: () async {
                    final image = await controller.onCropImage();
                    if (image != null) {
                      showDialog(
                          context: context,
                          builder: (_) => Image(image: image));
                    }
                  },
                ),
              ],
            ),
            SizedBox(height: MediaQuery.of(context).padding.bottom),
          ],
        ),
      ),
    );
  }
}
Screenshot 2024-06-16 at 23 00 17

Fahmisbas avatar Jun 16 '24 15:06 Fahmisbas

Running on M1 pro and iPhone 15 Emulator

Fahmisbas avatar Jun 16 '24 16:06 Fahmisbas

Possibly the image you were using was to big, do you also have it on device and with other images?

ikbendewilliam avatar Dec 30 '24 13:12 ikbendewilliam