crop_your_image
crop_your_image copied to clipboard
LateInitializationError: Field '_delegate@20417691' has not been initialized.
Hello, everyone. Thank you for taking the time to discuss this issue during your busy schedule. When I first encountered this problem in the afternoon, I improved my code and put the CropController into the constructor to ensure that the initialization is completed when the object is instantiated. In fact, he worked. But when I ran it again at night, this error occurred again. I am not sure if this is a bug, and I hope to get everyone's help. Below is the error message and some codes. Thank you
`======== Exception caught by gesture =============================================================== The following LateError was thrown while handling a gesture: LateInitializationError: Field '_delegate@20417691' has not been initialized.
When the exception was thrown, this was the stack:
#0 CropController._delegate (package:crop_your_image/src/controller.dart)
#1 CropController.image= (package:crop_your_image/src/controller.dart:18:33)
#2 ImageFiles.changeImageFile (package:data_matrix/model/image_files.dart:16:20)
#3 _ContentState.build.
@override Widget build(BuildContext context) { return ChangeNotifierProvider<ImageFiles>( create: (ctx) => ImageFiles(CropController()), child: MaterialApp(
`class ImageFiles extends ChangeNotifier{ ImageFiles(this.cropController);
ImageFiles.withImageFiles(this.cropController,this.deliveryImageFile);
File? deliveryImageFile; CropController cropController;
void changeImageFile(File newImageFile){ deliveryImageFile = newImageFile; cropController.image = newImageFile.readAsBytesSync(); notifyListeners(); }`
return Consumer( builder: (ctx, ImageFiles imageFile, child){ return ListTile( leading: Image.file(imageFileList[index]), title: Text(imageFileList[index].path.split('\\').last,overflow: TextOverflow.visible,), onTap: (){ imageFile.changeImageFile(imageFileList[index]); }, ); }, );
+1 same problem, when i try to pick an image from user lib
来信获悉,感谢您的支持!耑此奉复 钟冠彬This is an automatic reply, confirming that your e-mail was received.Thank you
Same problem. I also try to crop an image from user library.
Workaround: it is ok after the controller has been built at least once. (I guess).
Thank you all for your feedback and suggestions.
@ZhongGuanbin Can you provide the minimum code to reproduce the issue? It'll be great if the code can be run when I just copy and paste it to my VSCode.
来信获悉,感谢您的支持!耑此奉复 钟冠彬This is an automatic reply, confirming that your e-mail was received.Thank you
news? I have the same problem
来信获悉,感谢您的支持!耑此奉复 钟冠彬This is an automatic reply, confirming that your e-mail was received.Thank you