sampleImage static method

Future<File> sampleImage({
  1. required File file,
  2. int? preferredSize,
  3. int? preferredWidth,
  4. int? preferredHeight,
})

Implementation

static Future<File> sampleImage({
  required File file,
  int? preferredSize,
  int? preferredWidth,
  int? preferredHeight,
}) async {
  assert(() {
    if (preferredSize == null &&
        (preferredWidth == null || preferredHeight == null)) {
      throw ArgumentError(
          'Preferred size or both width and height of a resampled image must be specified.');
    }
    return true;
  }());

  final String path = await _channel.invokeMethod('sampleImage', {
    'path': file.path,
    'maximumWidth': preferredSize ?? preferredWidth,
    'maximumHeight': preferredSize ?? preferredHeight,
  });

  return File(path);
}