ย ยทย 6 years of No code development

File sharing script crashes on Flutter 3.27.3

Custom Code

I am using share_plus package and I used to be able to share pdf with ease. But since 3.27.3 flutter sdk update the Share file calls are getting crashed on all Android version except Android 15 emulator (Which hardly any of my app users currently use).

cartPdfShare custom action ->

import 'dart:io';

import 'package:path_provider/path_provider.dart';

import 'package:share_plus/share_plus.dart';

Future cartPdfShare(FFUploadedFile pdfDoc) async {

// Add your function code here!

// Get temporary directory

final directory = await getTemporaryDirectory();

String fileName = pdfDoc.name!;

// Create a temporary file

final tempFile = File('${directory.path}/$fileName');

// Write PDF data to the file

await tempFile.writeAsBytes(pdfDoc.bytes!);

// Share the file

await Share.shareXFiles([XFile(tempFile.path)], text: 'Invoice: $fileName');

}

What have you tried so far?

I used the latest version of share_plus package still it crashes, I also tried switching to share_extend, esys_flutter_share_plus, whatsapp_share packages but it seems like shareFile mechanism itself is affected.

All the packages when shareFile they crashed with: [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(Share failed, Class 'android.content.res.XmlBlock$Parser' does not implement interface 'dl.a' in call to 'int dl.a.next()' (declaration of 'd0.b' appears in /data/app/~~tveD1Z7J9DHjm2iSZXyPxA==/c

It's a platform bug because ever since Flutter 3.27.3 sdk got updated this incompatibility of sharingFile mechanism started occuring. Any sharing package which shares file is facing this crash on Android devices.

Did you check FlutterFlow's Documentation for this topic?
Yes
4
8 replies