Image.file constructor

Image.file(
  1. File file
)

Implementation

factory Image.file(File file) {
  if (!file.existsSync()) {
    throw ArgumentError('File does not exist');
  }

  final String extension = file.path.split('.').last;
  final bytes = file.readAsBytesSync();
  final encoded = convert.base64.encode(bytes);

  return Image._('data:image/$extension;base64,$encoded');
}