image static method

Stream image(
  1. String filePath
)

Implementation

static Stream image(String filePath) async* {
  final ByteData bytes = await rootBundle.load(filePath);
  final directory = (await getApplicationDocumentsDirectory()).path;
  final File imageFile = File('$directory/my_image.png');

  await imageFile.writeAsBytes(bytes.buffer.asUint8List());

  yield await Share.shareXFiles([XFile(imageFile.absolute.path)]);
  imageFile.delete();
}