share method Null safety

Future<void> share(
  1. {String subject = '',
  2. String? text,
  3. double? pixelRatio}
)

Shares the selected wallpaperModel at pixelRatio with the provided subject and text

Implementation

Future<void> share(
    {String subject = '', String? text, double? pixelRatio}) async {
  final tempDir = await getTemporaryDirectory();

  Uint8List? imageFile =
      await screenshotController.capture(pixelRatio: pixelRatio);
  if (imageFile != null) {
    var path = '${tempDir.path}/share.jpg';

    final file = await File(path).create();
    file.writeAsBytesSync(imageFile);

    Share.shareFiles([path], text: text, subject: subject);
  }
}