xclud / flutter_crop

Crop any widget/image in Android, iOS, Web and Desktop with fancy and customizable UI, in pure Dart code.
https://pub.dev/packages/crop
MIT License
259 stars 84 forks source link

Having issues cropping a widget with out an image #91

Open frankjoshua opened 2 months ago

frankjoshua commented 2 months ago

All I get is a blank screen. Here is a minimal example.

` import 'package:crop/crop.dart'; import 'package:flutter/material.dart';

class CropView extends StatelessWidget {

final controller = CropController(aspectRatio: 1 / 1);

@override Widget build(BuildContext context) { return Crop( controller: controller, child: Container(width: double.infinity, height: double.infinity, color: Colors.purple,), ); } } `

If instead of a container I use an image then it works fine but I need to crop widgets. That's why I chose this library.

======== Exception caught by rendering library ===================================================== I/flutter (27268): The following assertion was thrown while executing callbacks for The following assertion was thrown during paint(): RenderBox was not laid out: RenderRepaintBoundary#a514d NEEDS-PAINT 'package:flutter/src/rendering/box.dart': Failed assertion: line 2165 pos 12: 'hasSize'

The relevant error-causing widget was: I/flutter (27268): FrameTiming: CropRenderObjectWidget CropRenderObjectWidget:file:///home/josh/.pub-cache/hosted/pub.dev/crop-0.5.5/lib/src/crop.dart:346:7 When the exception was thrown, this was the stack:

2 RenderBox.size (package:flutter/src/rendering/box.dart:2165:12)

3 RenderBox.paintBounds (package:flutter/src/rendering/box.dart:2903:41)

I/flutter (27268): 'package:flutter/src/widgets/binding.dart': Failed assertion:

4 PaintingContext._repaintCompositedChild (package:flutter/src/rendering/object.dart:165:56)

5 PaintingContext.repaintCompositedChild (package:flutter/src/rendering/object.dart:109:5)

6 PaintingContext._compositeChild (package:flutter/src/rendering/object.dart:261:7)

7 PaintingContext.paintChild (package:flutter/src/rendering/object.dart:242:7)

8 RenderCrop.paint (package:crop/src/crop_render.dart:87:15)

9 RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:3239:7)

10 PaintingContext.paintChild (package:flutter/src/rendering/object.dart:250:13)

11 RenderBoxContainerDefaultsMixin.defaultPaint (package:flutter/src/rendering/box.dart:3158:15)