pickImage method

Future<void> pickImage({
  1. int? maxSize,
  2. dynamic onAdd()?,
})

Open the image dialog picker

Implementation

Future<void> pickImage({final int? maxSize, final Function()? onAdd}) async =>
await FilePicker.platform.pickFiles(
  type              : FileType.custom,
  allowedExtensions : _fileTypes,
  lockParentWindow  : true,
  allowMultiple     : false,
  withData          : true
).then((response) async {
  if (response == null) {
    _reset(error: false);
  } else {
    final f = response.files.single;
    setFromBytes(
      name      : f.name,
      extension : f.extension ?? '',
      bytes     : f.bytes,
      maxSize   : maxSize,
    );
    onAdd?.call();
  }
  notifyListeners();
})
.onError((error, stackTrace) => _reset(error: false));