Flutter crashes when using AudioPlayers and Future.wait to play a list of sound effects simultaneously - flutter

I'd like to create a list of List<Future<void>> that represent executions of sound effects.
I therefore iterate through a list of event types/formats (ie. "sword") and map each to a sound effect play execution.
I wrap these Futures in a Future.delayed for each with a random number of milliseconds from 30 to 100 just to have a little random occurance of when the sound effects are played in order (to add a pause between two sound effects).
The list of those sound effect Futures is then called by Future.wait where I expected the list to be resolved and the Future.delay might take effect.
This is my code
_playActionEventSounds() async {
if (widget.log.isNotEmpty) {
final lastRound = widget.log.map((e) => e.round).reduce(max);
final lastActionEvents = widget.log.where((actionEvent) => actionEvent.round == lastRound);
final List<Future<void>> eventSounds = lastActionEvents.map((actionEvent) async {
if (actionEvent.format == "sword") {
return Future.delayed(Duration(milliseconds: next(30, 100)), () => _soundPlayer.punch());
}
if (actionEvent.format == "damage") {
return Future.delayed(Duration(milliseconds: next(30, 100)), () => _soundPlayer.pain());
}
return Future.value(null);
}).toList();
await Future.wait(eventSounds);
}
}
SoundPlayer class:
import 'package:audioplayers/audioplayers.dart';
class SoundPlayer {
Future<void> punch() async {
final player = AudioPlayer();
player.setReleaseMode(ReleaseMode.stop);
return await player.play(AssetSource("sounds/punch.wav"));
}
Future<void> pain() async {
final player = AudioPlayer();
player.setReleaseMode(ReleaseMode.stop);
return await player.play(AssetSource("sounds/pain.wav"));
}
}
I now can run the process multiple times. I do hear the sounds appear as expected. But after the 4th execution the app crashes.
This is the error:
I/flutter (28346): Unexpected platform error: MediaPlayer error with what:MEDIA_ERROR_UNKNOWN {what:1} extra:MEDIA_ERROR_UNKNOWN {extra:-19}
E/MediaPlayerNative(28346): pause called in state 0, mPlayer(0xb400007a92646810)
E/MediaPlayerNative(28346): error (-38, 0)
E/MediaPlayerNative(28346): Attempt to call getDuration in wrong state: mPlayer=0xb400007a92646810, mCurrentState=0
E/MediaPlayerNative(28346): error (-38, 0)
E/MediaPlayerNative(28346): stop called in state 0, mPlayer(0xb400007a92646810)
E/MediaPlayerNative(28346): error (-38, 0)
E/MediaPlayerNative(28346): prepareAsync called in state 0, mPlayer(0xb400007a92646810)
D/AndroidRuntime(28346): Shutting down VM
E/AndroidRuntime(28346): FATAL EXCEPTION: main
E/AndroidRuntime(28346): Process: com.example.app, PID: 28346
E/AndroidRuntime(28346): java.lang.IllegalStateException
E/AndroidRuntime(28346): at android.media.MediaPlayer._prepare(Native Method)
E/AndroidRuntime(28346): at android.media.MediaPlayer.prepare(MediaPlayer.java:1313)
E/AndroidRuntime(28346): at xyz.luan.audioplayers.player.MediaPlayerPlayer.prepare(MediaPlayerPlayer.kt:89)
E/AndroidRuntime(28346): at xyz.luan.audioplayers.player.WrappedPlayer.stop(WrappedPlayer.kt:185)
E/AndroidRuntime(28346): at xyz.luan.audioplayers.player.WrappedPlayer.onCompletion(WrappedPlayer.kt:248)
E/AndroidRuntime(28346): at xyz.luan.audioplayers.player.MediaPlayerPlayer.createMediaPlayer$lambda-5$lambda-1(MediaPlayerPlayer.kt:17)
E/AndroidRuntime(28346): at xyz.luan.audioplayers.player.MediaPlayerPlayer.$r8$lambda$3fK1i48Yert5dbg2Q8ZiB5tiKHg(Unknown Source:0)
E/AndroidRuntime(28346): at xyz.luan.audioplayers.player.MediaPlayerPlayer$$ExternalSyntheticLambda1.onCompletion(Unknown Source:2)
E/AndroidRuntime(28346): at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:3559)
E/AndroidRuntime(28346): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(28346): at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(28346): at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(28346): at android.app.ActivityThread.main(ActivityThread.java:7842)
E/AndroidRuntime(28346): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(28346): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(28346): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
I/Process (28346): Sending signal. PID: 28346 SIG: 9
Lost connection to device.
I guess I somewhat messed up the resource management due the repeated execution. Therefore I guess the error lies somewhat in the API usage of audioplayers.dart?

I had to change the ReleaseMode to release. What I did was using stop that kept the resources in memory I guess and therefore cluttered the memory?

Related

flutter camera: Error clearing streaming request: Function not implemented

I am working on an app in flutter that uses the camera.
I have followed the basic flutter tutorial
https://flutter.dev/docs/cookbook/plugins/picture-using-camera
However, when I am on a screen using the CameraPreview widget, and I navigate to another app that uses the camera, like snapchat, I see the following error when opening snapchat (the error comes from my app), has anyone else seen this before?
Returning to my app shows the camera in a frozen/paused state.
I/CameraManagerGlobal(30470): Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_IDLE for client com.my.cliet API Level 2
I/CameraManagerGlobal(30470): Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.my.cliet API Level 2
E/CameraCaptureSession(30470): Session 0: Exception while stopping repeating:
E/CameraCaptureSession(30470): android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): cancelRequest:547: Camera 0: Error clearing streaming request: Function not implemented (-38)
E/CameraCaptureSession(30470): at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:1340)
E/CameraCaptureSession(30470): at android.hardware.camera2.impl.ICameraDeviceUserWrapper.cancelRequest(ICameraDeviceUserWrapper.java:99)
E/CameraCaptureSession(30470): at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:1259)
E/CameraCaptureSession(30470): at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:578)
E/CameraCaptureSession(30470): at android.hardware.camera2.impl.CameraCaptureSessionImpl$2.onDisconnected(CameraCaptureSessionImpl.java:789)
E/CameraCaptureSession(30470): at android.hardware.camera2.impl.CameraDeviceImpl$7.run(CameraDeviceImpl.java:245)
E/CameraCaptureSession(30470): at android.os.Handler.handleCallback(Handler.java:938)
E/CameraCaptureSession(30470): at android.os.Handler.dispatchMessage(Handler.java:99)
E/CameraCaptureSession(30470): at android.os.Looper.loop(Looper.java:246)
E/CameraCaptureSession(30470): at android.app.ActivityThread.main(ActivityThread.java:8506)
E/CameraCaptureSession(30470): at java.lang.reflect.Method.invoke(Native Method)
E/CameraCaptureSession(30470): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
E/CameraCaptureSession(30470): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
E/CameraCaptureSession(30470): Caused by: android.os.ServiceSpecificException: cancelRequest:547: Camera 0: Error clearing streaming request: Function not implemented (-38) (code 10)
E/CameraCaptureSession(30470): at android.os.Parcel.createExceptionOrNull(Parcel.java:2399)
E/CameraCaptureSession(30470): at android.os.Parcel.createException(Parcel.java:2369)
E/CameraCaptureSession(30470): at android.os.Parcel.readException(Parcel.java:2352)
E/CameraCaptureSession(30470): at android.os.Parcel.readException(Parcel.java:2294)
E/CameraCaptureSession(30470): at android.hardware.camera2.ICameraDeviceUser$Stub$Proxy.cancelRequest(ICameraDeviceUser.java:750)
E/CameraCaptureSession(30470): at android.hardware.camera2.impl.ICameraDeviceUserWrapper.cancelRequest(ICameraDeviceUserWrapper.java:97)
E/CameraCaptureSession(30470): ... 11 more
So I have resolved the issue by adding the following which aren't included in the link that I posted.
in the initState() method I had to manually add the observer
WidgetsBinding.instance!.addObserver(this);
I had to define/modify the didChangeAppLifecycleState(...) function as follows
#override
void didChangeAppLifecycleState(AppLifecycleState state) {
final CameraController? cameraController = _controller;
// App state changed before we got the chance to initialize.
if (cameraController == null || !cameraController.value.isInitialized) {
return;
}
if (state == AppLifecycleState.inactive) {
cameraController.dispose();
} else if (state == AppLifecycleState.resumed) {
this._controller = CameraController(
widget.camera,
ResolutionPreset.medium,
);
if (mounted) {
setState(() {
this._initializeControllerFuture = this._controller.initialize();
});
}
}
}

Flutter app login Exception has occurred. PlatformException error

I have a flutter app but every time I login I get an exception error and I have to press f5 to ensure the process is completed. This is the error
Exception has occurred.
PlatformException (PlatformException(error, Task io.flutter.plugins.sharedpreferences.MethodCallHandlerImpl$1#f33e5c6 rejected from java.util.concurrent.ThreadPoolExecutor#63f5987[Running, pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 0], null, java.util.concurrent.RejectedExecutionException: Task io.flutter.plugins.sharedpreferences.MethodCallHandlerImpl$1#f33e5c6 rejected from java.util.concurrent.ThreadPoolExecutor#63f5987[Running, pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 0]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2085)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:848)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1394)
at io.flutter.plugins.sharedpreferences.MethodCallHandlerImpl.commitAsync(MethodCallHandlerImpl.java:137)
at io.flutter.plugins.sharedpreferences.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:96)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6820)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:922)
))
It seems the bug is fixed in shared_preferences 2.0.4 (at least for me it worked)
you should downgrade to
shared_preferences: 2.0.1
not
shared_preferences: ^2.0.1
if you used the beta version or use the stable version
shared_preferences: ^0.5.12+4

Flutter audioplayers stop playing after multiple play events

i'm using this code to play sound whenever I click on a widget.
Future<void> playMySound(String who) async{
AudioPlayer advancedPlayer = new AudioPlayer();
audioCache = new AudioCache(fixedPlayer: advancedPlayer);
audioCache.clearCache();
String localFilePath;
audioCache.play('roomSounds/$who', mode: PlayerMode.LOW_LATENCY);
}
Problem:
Whenever I tap for example 15 times on a widget that would play the sound, it would stop playing and throw the following stack:
E/MediaPlayer( 5793): Error (-38,0)
I/flutter ( 5793): hello 0.0
E/MediaPlayerNative( 5793): error (1, -19)
E/MediaPlayer( 5793): Error (1,-19)
E/MediaPlayerNative( 5793): pause called in state 0, mPlayer(0x77ceaa80)
E/MediaPlayerNative( 5793): error (-38, 0)
E/MediaPlayerNative( 5793): Attempt to perform seekTo in wrong state: mPlayer=0x77ceaa80, mCurrentState=0
E/MediaPlayerNative( 5793): error (-38, 0)
E/MediaPlayer( 5793): Error (-38,0)
E/MediaPlayer( 5793): Error (-38,0)
I've tried to use audioCache.clearCache() but with no effect. Only after reloading the application it is possible to play any sound at all.

contact picker causing app crash after I am selecting contact from contact list

I am using Flutter contact picker 0.0.2. But it is giving some weird error. It shows the contact list when I call selectContact Future, however, after selecting a particular contact from the list, the app crashes, and it gives me the below-mentioned error on console.
I have also tried with adding permission in android, even though it is not required, still, it does not work.
Code :
class _MobileNumberWidgetState extends State<MobileNumberWidget> {
final TextEditingController _phoneNumberController = TextEditingController();
final ContactPicker _contactPicker = new ContactPicker();
Contact _contact;
#override
Widget build(BuildContext context) {
return AppWidgets.shadowContainerComplete(
child:Row(
children: <Widget>[
Expanded(
child: TextField(
controller: _phoneNumberController,
decoration: AppStyles.textField(hint: "Enter Phone Number", iconData: Icons.phone_iphone),
),
),
IconButton(
icon: Icon(Icons.format_list_numbered),
onPressed: () async{
Contact contact = await _contactPicker.selectContact();
setState(() {
_contact = contact;
});
},
)
],
)
);
}
}
Console :
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk...
D/FlutterActivity(17398): Using the launch theme as normal theme.
D/FlutterActivityAndFragmentDelegate(17398): Setting up FlutterEngine.
D/FlutterActivityAndFragmentDelegate(17398): No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.
D/FlutterActivityAndFragmentDelegate(17398): Attaching FlutterEngine to the Activity that owns this Fragment.
D/FlutterView(17398): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine#43c3a74
D/FlutterActivityAndFragmentDelegate(17398): Executing Dart entrypoint: main, and sending initial route: /
Debug service listening on ws://127.0.0.1:28145/jPIcHt_yF9E=/ws
Syncing files to device Android SDK built for x86...
D/EGL_emulation(17398): eglMakeCurrent: 0xe121a6c0: ver 3 1 (tinfo 0xe120f8a0)
D/eglCodecCommon(17398): setVertexArrayObject: set vao to 0 (0) 1 0
D/EGL_emulation(17398): eglMakeCurrent: 0xe121a180: ver 3 1 (tinfo 0xe120fa70)
D/FlutterView(17398): Detaching from a FlutterEngine: io.flutter.embedding.engine.FlutterEngine#43c3a74
D/AndroidRuntime(17398): Shutting down VM
E/AndroidRuntime(17398): FATAL EXCEPTION: main
E/AndroidRuntime(17398): Process: maaz.easyapproach.kashbak, PID: 17398
E/AndroidRuntime(17398): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2015, result=-1, data=Intent { dat=content://com.android.contacts/data/1 flg=0x1 }} to activity {maaz.easyapproach.kashbak/maaz.easyapproach.kashbak.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.ContentResolver android.app.Activity.getContentResolver()' on a null object reference
E/AndroidRuntime(17398): at android.app.ActivityThread.deliverResults(ActivityThread.java:4845)
E/AndroidRuntime(17398): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4886)
E/AndroidRuntime(17398): at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
E/AndroidRuntime(17398): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime(17398): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime(17398): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
E/AndroidRuntime(17398): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(17398): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(17398): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/AndroidRuntime(17398): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(17398): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime(17398): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/AndroidRuntime(17398): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.ContentResolver android.app.Activity.getContentResolver()' on a null object reference
E/AndroidRuntime(17398): at net.goderbauer.flutter.contactpicker.ContactPickerPlugin.onActivityResult(ContactPickerPlugin.java:68)
E/AndroidRuntime(17398): at io.flutter.embedding.engine.FlutterEnginePluginRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEnginePluginRegistry.java:634)
E/AndroidRuntime(17398): at io.flutter.embedding.engine.FlutterEnginePluginRegistry.onActivityResult(FlutterEnginePluginRegistry.java:367)
E/AndroidRuntime(17398): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:546)
E/AndroidRuntime(17398): at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:594)
E/AndroidRuntime(17398): at android.app.Activity.dispatchActivityResult(Activity.java:8110)
E/AndroidRuntime(17398): at android.app.ActivityThread.deliverResults(ActivityThread.java:4838)
E/AndroidRuntime(17398): ... 11 more
I/Process (17398): Sending signal. PID: 17398 SIG: 9
Lost connection to device.

Sending email with attachments via flutter_email_sender is not working on Android

I'm trying to send an email with a pdf attachment using flutter_email_sender, it works fine on iOS but throws Failed to find configured root error on Android. Below is the code.
Future<void> _downloadFile(String url, String filename) async {
var request = await httpClient.getUrl(Uri.parse(url));
var response = await request.close();
var bytes = await consolidateHttpClientResponseBytes(response);
String dir = (await getApplicationDocumentsDirectory()).path;
File file = new File('$dir/$filename');
await file.writeAsBytes(bytes);
setState(() {
_file = file;
});
}
final Email email = Email(
body: 'Email body',
subject: 'Email subject',
recipients: ['email#gmail.com'],
attachmentPath: _file.path,
);
await FlutterEmailSender.send(email);
and the stack trace:
E/MethodChannel#flutter_email_sender: Failed to handle method call
java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/com.xxx.xx/app_flutter/account_opening.pdf at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:739)
at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:418)
at com.sidlatau.flutteremailsender.FlutterEmailSenderPlugin.sendEmail(FlutterEmailSenderPlugin.kt:95)
at com.sidlatau.flutteremailsender.FlutterEmailSenderPlugin.onMethodCall(FlutterEmailSenderPlugin.kt:38)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:160)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2019-09-11 13:44:42.484 26003-26003/com.xxx.xx W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy#98fb11f
2019-09-11 13:44:42.505 26003-26003/com.xxx.xx D/AndroidRuntime: Shutting down VM
2019-09-11 13:44:42.512 26003-26003/com.xxx.xx E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxx.xx, PID: 26003
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.xx/com.kiwi.fluttercrashlytics.CrashActivity}: com.kiwi.fluttercrashlytics.FlutterException: PlatformException(error, Failed to find configured root that contains /data/data/com.xxx.xx/app_flutter/account_opening.pdf, null)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: com.kiwi.fluttercrashlytics.FlutterException: PlatformException(error, Failed to find configured root that contains /data/data/com.xxx.xx/app_flutter/account_opening.pdf, null)
at StandardMethodCodec.decodeEnvelope(package:flutter/src/services/message_codecs.dart:564)
at MethodChannel.invokeMethod(package:flutter/src/services/platform_channel.dart:316)
at FlutterEmailSender.send(package:flutter_email_sender/flutter_email_sender.dart:10)
at _EmailWidgetState.build.<fn>(package:gsec/shared/widgets/manualPDFWidget/email_widget.dart:136)
at OnboardingNextButtonWidget.build.<fn>(package:gsec/onboardingScreen/onboard_next_button_widget.dart:84)
at GestureRecognizer.invokeCallback(package:flutter/src/gestures/recognizer.dart:182)
at TapGestureRecognizer._checkUp(package:flutter/src/gestures/tap.dart:365)
at TapGestureRecognizer.acceptGesture(package:flutter/src/gestures/tap.dart:312)
at GestureArenaManager.sweep(package:flutter/src/gestures/arena.dart:156)
at _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent(package:flutter/src/gestures/binding.dart:222)
at _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent(package:flutter/src/gestures/binding.dart:198)
at _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent(package:flutter/src/gestures/binding.dart:156)
at _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue(package:flutter/src/gestures/binding.dart:102)
at _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket(package:flutter/src/gestures/binding.dart:86)
at ._rootRunUnary(dart:async/zone.dart:1136)
at _CustomZone.runUnary(dart:async/zone.dart:1029)
at _CustomZone.runUnaryGuarded(dart:async/zone.dart:931)
at ._invoke1(dart:ui/hooks.dart:250)
at ._dispatchPointerDataPacket(dart:ui/hooks.dart:159)
It is not possible to attach files from ApplicationDocumentsDirectory since this directory is only accessible from your app. You have to use a directory like ExternalStorageDirectory to be able to send from it. If you do so don't forget to add WRITE_EXTERNAL_STORAGE permission to your app before release.
Cheers.