pickImage method

void pickImage(
  1. int type
)

open image picker from camera, gallery, or cancel the selection

Implementation

void pickImage(int type) async {
  final cameraPermission = Permission.camera;
  final storagePermission = Permission.camera;
  if (type == 1) {
    final permissionStatus = await cameraPermission.request();
    if (permissionStatus.isGranted) {
      final path = await _getImagePathFromSource(1);
      final imageMessage = _getImageMEssageFromPath(path);
      handleImageSelect(imageMessage);
      return;
    } else {
      handleImageSelect(null);
      return;
    }
  } else {
    final permissionStatus = await storagePermission.request();
    if (permissionStatus.isGranted) {
      final path = await _getImagePathFromSource(2);
      final imageMessage = _getImageMEssageFromPath(path);
      handleImageSelect(imageMessage);
      return;
    } else {
      handleImageSelect(null);
      return;
    }
  }
}