onChangePhotoTapped method

Future<void> onChangePhotoTapped({
  1. bool camera = false,
})

Implementation

Future<void> onChangePhotoTapped({bool camera = false}) async {
  final ImagePicker picker = ImagePicker();
  XFile? image = await picker.pickImage(
    source: camera ? ImageSource.camera : ImageSource.gallery,
  );
  if (image != null) {
    final CroppedFile? croppedFile = await ImageCropper().cropImage(
      sourcePath: image.path,
      aspectRatioPresets: [
        CropAspectRatioPreset.square,
        CropAspectRatioPreset.ratio3x2,
        CropAspectRatioPreset.original,
        CropAspectRatioPreset.ratio4x3,
        CropAspectRatioPreset.ratio16x9
      ],
      // androidUiSettings: AndroidUiSettings(
      //     toolbarColor: AppTheme.orange,
      //     toolbarWidgetColor: Colors.white,
      //     initAspectRatio: CropAspectRatioPreset.original,
      //     lockAspectRatio: false),
      // iosUiSettings: const IOSUiSettings(
      //   minimumAspectRatio: 1.0,
      // ),
    );
    if (croppedFile != null) {
      image = XFile(croppedFile.path);
    }
    this.image.value = MemoryImage(await image.readAsBytes());
  }
}