Closed demirdev closed 3 years ago
I develop app on debug and crop widget works great. But on release version of apk, crop widget seems complete grey box like below.
I showing MyCustomCropWidget in stack with showCrop variable.
// Stack .. [... // Camera Preview , Visibility( visible: showCrop, child: MyCustomCropWidget( imagePath: imagePath, clipOkay: clipOkay, deleteAllPhotos: () { deleteAllPhotos(); setState(() { showCrop = false; }); }, ), ) // .... ] / stack
import 'dart:io'; import 'package:flutter/material.dart'; import 'package:image_crop/image_crop.dart'; import 'package:path/path.dart'; import 'package:myapp/common/widgets/cancel_button.dart'; import 'package:myapp/helpers/file_helper.dart'; class MyCustomCropWidget extends StatefulWidget { final String imagePath; final Function clipOkay; final Function deleteAllPhotos; const MyCustomCropWidget( {Key key, this.imagePath, this.clipOkay, this.deleteAllPhotos}) : super(key: key); @override _MyCustomCropWidgetState createState() => _MyCustomCropWidgetState(); } class _MyCustomCropWidgetState extends State<MyCustomCropWidget> { final cropKey = GlobalKey<CropState>(); @override Widget build(BuildContext context) { return Container( color: Colors.black, child: Stack( children: [ Container( padding: const EdgeInsets.all(20.0), child: Crop( key: cropKey, image: FileImage(File(widget.imagePath)), // aspectRatio: 4.0 / 3.0, ), ), Positioned( left: 0, right: 0, bottom: 0, child: Stack( children: [ CancelButton( onPressed: widget.deleteAllPhotos, ), Padding( padding: const EdgeInsets.only(bottom: 16.0), child: Positioned.fill( child: Align( alignment: Alignment.center, child: IconButton( icon: Icon(Icons.check), color: Colors.white, iconSize: 60, onPressed: () async { print("Image Source for Crop: " + widget.imagePath); final croppedImage = await ImageCrop.cropImage( file: File(widget.imagePath), area: cropKey.currentState.area, ); print("cropped image path: " + croppedImage.path); // delete original image. await File(widget.imagePath).delete(); String fileLocation = join(await FileHelper.localPath, "files/"); if (!(await Directory(fileLocation).exists())) await Directory(fileLocation).create(); fileLocation = join(fileLocation, basename(croppedImage.path)); await FileHelper.moveFile( File(croppedImage.path), fileLocation); widget.clipOkay(fileLocation); }, ), ), ), ), ], ), ) ], ), ); } }
I realize got error when buildcrop widget about stacked children. I removed Positioned.fill widgets and change Stack widgets to Column and Row widgets. Problem solved. Please remove this issue. Thanks.
I develop app on debug and crop widget works great. But on release version of apk, crop widget seems complete grey box like below.
I showing MyCustomCropWidget in stack with showCrop variable.