diff --git a/packages/share_plus/share_plus/example/lib/main.dart b/packages/share_plus/share_plus/example/lib/main.dart index 3fe08511e0..913a6e33ce 100644 --- a/packages/share_plus/share_plus/example/lib/main.dart +++ b/packages/share_plus/share_plus/example/lib/main.dart @@ -245,20 +245,25 @@ class DemoAppState extends State { void _onShareXFileFromAssets(BuildContext context) async { final box = context.findRenderObject() as RenderBox?; final scaffoldMessenger = ScaffoldMessenger.of(context); - final data = await rootBundle.load('assets/flutter_logo.png'); - final buffer = data.buffer; - final shareResult = await Share.shareXFiles( - [ - XFile.fromData( - buffer.asUint8List(data.offsetInBytes, data.lengthInBytes), - name: 'flutter_logo.png', - mimeType: 'image/png', - ), - ], - sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, - ); - - scaffoldMessenger.showSnackBar(getResultSnackBar(shareResult)); + try { + final data = await rootBundle.load('assets/flutter_logo.png'); + final buffer = data.buffer; + final shareResult = await Share.shareXFiles( + [ + XFile.fromData( + buffer.asUint8List(data.offsetInBytes, data.lengthInBytes), + name: 'flutter_logo.png', + mimeType: 'image/png', + ), + ], + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, + ); + scaffoldMessenger.showSnackBar(getResultSnackBar(shareResult)); + } catch (e) { + scaffoldMessenger.showSnackBar( + SnackBar(content: Text('Error: $e')), + ); + } } void _onShareTextAsXFile(BuildContext context) async { diff --git a/packages/share_plus/share_plus/lib/src/share_plus_web.dart b/packages/share_plus/share_plus/lib/src/share_plus_web.dart index f4933873fb..d0456d327c 100644 --- a/packages/share_plus/share_plus/lib/src/share_plus_web.dart +++ b/packages/share_plus/share_plus/lib/src/share_plus_web.dart @@ -258,6 +258,7 @@ class SharePlusWebPlugin extends SharePlatform { List files, List? fileNameOverrides, ) async { + developer.log('Download files as fallback'); try { for (final (index, file) in files.indexed) { final bytes = await file.readAsBytes();