Closed c-seeger closed 3 months ago
I'm on web and always getting the error cropper not initialized. I pass it throug the CropperDialog and call it within initState but its not working
import 'package:flutter/material.dart'; import 'package:image_cropper/image_cropper.dart'; class CropperDialog extends StatefulWidget { const CropperDialog( {required this.cropper, required this.initCropper, required this.crop, required this.rotate, required this.scale, required this.children, super.key}); final Widget cropper; final void Function() initCropper; final Future<String?> Function() crop; final void Function(RotationAngle) rotate; final void Function(num) scale; final List<Widget> children; @override State<CropperDialog> createState() => _CropperDialogState(); } class _CropperDialogState extends State<CropperDialog> { @override void initState() { super.initState(); widget.initCropper(); } @override Widget build(BuildContext context) { return Dialog.fullscreen( child: Builder( builder: (BuildContext context) { return IntrinsicHeight( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: widget.children, ), ); }, ), ); } }
Widget customDialogBuilder( BuildContext context, Widget cropper, void Function() initCropper, Future<String?> Function() crop, void Function(RotationAngle) rotate, void Function(num) scale) { return CropperDialog( cropper: cropper, initCropper: initCropper, crop: crop, rotate: rotate, scale: scale, children: <Widget>[ const SizedBox(height: 50), header(context), const Spacer(), body(context, cropper), const Spacer(), footer(context, crop, rotate, initCropper), ]); } Widget footer(... // contains sth like this // ElevatedButton( // onPressed: () async { // final String? result = await crop(); // if (context.mounted) { // Navigator.of(context).pop(result); // } // }, Widget header(... Widget body(... return <PlatformUiSettings>[ WebUiSettings( context: context, size: CropperSize( width: screenWidth.round() + 100, height: screenHeight.round(), ), zoomable: true, zoomOnTouch: true, zoomOnWheel: true, cropBoxResizable: false, customDialogBuilder: (Widget cropper, void Function() initCropper, Future<String?> Function() crop, void Function(RotationAngle) rotate, void Function(num) scale) { return customDialogBuilder( context, cropper, initCropper, crop, rotate, scale); }, ), ];
I also get the error when not using customDialogBuilder at all
found it, was using an older cropper js, after updating it worked
I'm on web and always getting the error cropper not initialized. I pass it throug the CropperDialog and call it within initState but its not working