takePhoto method

Future<void> takePhoto()

Implementation

Future<void> takePhoto() async {
  try {
    showLoading();
    XFile? xFile = await getFile();

    if (xFile == null) {
      throw 'Unread File';
    }

    File file = File(xFile.path);

    if (mounted) {
      closeLoading();
    }
    if (!widget.side.isSelfie) {
      await SystemChrome.setPreferredOrientations(<DeviceOrientation>[
        DeviceOrientation.portraitUp,
      ]);
    }
    widget.onTakePhoto(
      file,
      emoji,
    );
  } catch (error) {
    widget.onError?.call(error);
  }
}