PaintingEditor.autoSource constructor

PaintingEditor.autoSource({
  1. Key? key,
  2. Uint8List? byteArray,
  3. File? file,
  4. String? assetPath,
  5. String? networkUrl,
  6. required PaintEditorInitConfigs initConfigs,
})

Constructs a PaintingEditor widget with an image loaded automatically based on the provided source.

Either byteArray, file, networkUrl, or assetPath must be provided.

Implementation

factory PaintingEditor.autoSource({
  Key? key,
  Uint8List? byteArray,
  File? file,
  String? assetPath,
  String? networkUrl,
  required PaintEditorInitConfigs initConfigs,
}) {
  if (byteArray != null) {
    return PaintingEditor.memory(
      byteArray,
      key: key,
      initConfigs: initConfigs,
    );
  } else if (file != null) {
    return PaintingEditor.file(
      file,
      key: key,
      initConfigs: initConfigs,
    );
  } else if (networkUrl != null) {
    return PaintingEditor.network(
      networkUrl,
      key: key,
      initConfigs: initConfigs,
    );
  } else if (assetPath != null) {
    return PaintingEditor.asset(
      assetPath,
      key: key,
      initConfigs: initConfigs,
    );
  } else {
    throw ArgumentError(
        "Either 'byteArray', 'file', 'networkUrl' or 'assetPath' must be provided.");
  }
}