pickImage method

Future<void> pickImage()

Opens a file picker to select an image, then processes and stores it.

Implementation

Future<void> pickImage() async =>
await FilePicker.platform.pickFiles(
  type              : FileType.custom,
  allowedExtensions : AcceptedFormats.values.map((e) => e.name).toList(),
  allowMultiple     : false,
  withData          : !PlatformPort().requirePath(),
)
.then((pick) async {
  if(pick != null){
    if(pick.files.isNotEmpty) {
      startLoading();
      await _useCase
      .createDataFromPlatformFile(
        key     : _key,
        file    : pick.files.first,
        maxSize : _maxSize,
      )
      .then(_setData)
      .onError(_setError)
      .whenComplete(() => stopLoading() );
    }
  }
});