
import 'package:file_picker/file_picker.dart';
import 'package:image_picker/image_picker.dart';

class FilePick {
  static final _picker = ImagePicker();

  static Future<XFile?> galleryPick() async {
    final pickedImage = await _picker.pickImage(source: ImageSource.gallery);
    if (pickedImage != null) {
      return pickedImage;
    }
    return null;
  }

  static Future<List<XFile>?> multipleGalleryPick() async {
    final pickedImages = await _picker.pickMultiImage();
    if(pickedImages.isNotEmpty) {
      return pickedImages;
    }
    return null;
  }

  static Future<List<String>?> documentPick() async {
    var result = await FilePicker.platform.pickFiles(allowMultiple: true);
    var paths = result?.files.nonNulls.map((e) => e.path).toList();
    return paths?.nonNulls.toList();
  }
}
