showPicker method

void showPicker({
  1. CallbackData? callback,
  2. CameraType type = CameraType.full,
  3. bool resizeImage = true,
})

Implementation

void showPicker(
    {CallbackData? callback,
    CameraType type = CameraType.full,
    bool resizeImage = true}) async {
  switch (type) {
    case CameraType.camera:
      XFile? image = await _imgFromCamera(resizeImage);
      if (callback != null) {
        callback(image?.path);
      }
      // Navigator.of(context!).pop();
      break;
    case CameraType.photo:
      XFile? image = await _imgFromGallery(resizeImage);
      if (callback != null) {
        callback(image?.path);
      }
      // Navigator.of(context!).pop();
      break;
    case CameraType.full:
      showModalBottomSheet(
          context: context!,
          builder: (BuildContext bc) {
            return SafeArea(
              child: Wrap(
                children: <Widget>[
                  ListTile(
                      leading: const Icon(Icons.photo_library),
                      title: Text('photogallery'.tr,
                          style: const TextStyle(fontSize: fontSize15)),
                      onTap: () async {
                        XFile? image = await _imgFromGallery(resizeImage);
                        Navigator.of(context!).pop();
                        if (callback != null && image != null) {
                          callback(image.path);
                        }
                      }),
                  ListTile(
                    leading: const Icon(Icons.photo_camera),
                    title: Text('camera'.tr,
                        style: const TextStyle(fontSize: fontSize15)),
                    onTap: () async {
                      XFile? image = await _imgFromCamera(resizeImage);
                      Navigator.of(context!).pop();
                      if (callback != null && image != null) {
                        callback(image.path);
                      }
                    },
                  ),
                ],
              ),
            );
          });
      break;
    default:
  }
}