You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MissingPluginException "No implementation found for method" in path_provider when called from isolate #99155
But I'm not willing to share my complete program publicly. And I have no time to produce a dummy with the same issue.
I just did a full flutter pub upgrade. These are the packages I use:
We have automated tests that use path_provider, and they pass. Your use case is clearly different in some way; without knowing how, we can't investigate.
The stack trace with filenames and line numbers should provide enough insight for the experts to find where the issue is
It isn't, because we don't know anything about what szwmobiletracker/main.dart:135 is doing. For instance, whether or not it is running in an isolate is likely important here, and we have absolutely no way to determine that from the information you have provided.
The call to path_provider ( Directory dir = await getApplicationDocumentsDirectory(); ) is indeed done from a background process, started using the flutter_background_service package.
By the way, I used shared_preferences before, but that gave the same problems in combination with the background service. I really do need to store info in a file in the background, also when the foreground is not running (could use the background sendData method, but where does that go when the foreground is not active?)
changed the title [-]Method not implemented in path_provider... ?[/-][+]MissingPluginException "No implementation found for method" in path_provider when called from isolate[/+]on Feb 26, 2022
The longer-term solution is that anything setting up an isolate where plugins are expected to work should call DartPluginRegistrant.ensureInitialized(), which will run all Dart plugin registration (similar to how they already need to call WidgetsFlutterBinding.ensureInitialized() to make platform message work in the first place). That's not currently on stable yet though, as it only just landed on master.
To summarize the solution: at the start of the entry point for any isolate that needs to use plugins (where you are presumably already calling WidgetsFlutterBinding.ensureInitialized()):
For Flutter 2.11+ (currently master), call DartPluginRegistrant.ensureInitialized(), which will run the Dart plugin registration for all plugins that need it.
For older versions of Flutter, manually call the registerWith of any plugin implementations you use that have Dart registration. For path_provider, see above for details.
Since the plan going forward is to require DartPluginRegistrant.ensureInitialized() in isolates, closing as fixed.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
stuartmorgan-g commentedon Feb 25, 2022
Please use the issue template when filing issues; your report is missing a lot of information that is requested in the template.
What version of Flutter are you using? What platform is this on? What is the complete reproducible test case?
Henk-Keijzer commentedon Feb 25, 2022
Henk-Keijzer commentedon Feb 25, 2022
And it worked before............
stuartmorgan-g commentedon Feb 25, 2022
We still need a reproducible case.
There was a recent change to
path_provider_android, but to understand what the issue with that change is we need a reproducible test case.Henk-Keijzer commentedon Feb 25, 2022
But I'm not willing to share my complete program publicly. And I have no time to produce a dummy with the same issue.
I just did a full flutter pub upgrade. These are the packages I use:
The stack trace with filenames and line numbers should provide enough insight for the experts to find where the issue is:
stuartmorgan-g commentedon Feb 25, 2022
We need reproducible test cases to investigate issues. See https://github.com/flutter/flutter/wiki/Issue-hygiene#issues-should-have-clear-steps-to-reproduce and https://github.com/flutter/flutter/wiki/Issue-hygiene#issues-should-have-clear-steps-to-reproduce
We have automated tests that use
path_provider, and they pass. Your use case is clearly different in some way; without knowing how, we can't investigate.It isn't, because we don't know anything about what
szwmobiletracker/main.dart:135is doing. For instance, whether or not it is running in an isolate is likely important here, and we have absolutely no way to determine that from the information you have provided.Henk-Keijzer commentedon Feb 26, 2022
The call to path_provider ( Directory dir = await getApplicationDocumentsDirectory(); ) is indeed done from a background process, started using the flutter_background_service package.
Henk-Keijzer commentedon Feb 26, 2022
Here is the code of an app giving exactly the same result when calling the path_provider from the background process.
Details
Henk-Keijzer commentedon Feb 26, 2022
By the way, I used shared_preferences before, but that gave the same problems in combination with the background service. I really do need to store info in a file in the background, also when the foreground is not running (could use the background sendData method, but where does that go when the foreground is not active?)
stuartmorgan-g commentedon Feb 26, 2022
This is due to #98591 then, and is the
path_providerversion of #98473.The workaround described there will work for
path_provideras well:path_provider_androidandpath_provider_ios.[-]Method not implemented in path_provider... ?[/-][+]MissingPluginException "No implementation found for method" in path_provider when called from isolate[/+]Henk-Keijzer commentedon Feb 26, 2022
Ok, that works! Thanks!!
Henk-Keijzer commentedon Mar 1, 2022
stuartmorgan-g commentedon Mar 1, 2022
Henk-Keijzer commentedon Mar 1, 2022
stuartmorgan-g commentedon Mar 1, 2022
stuartmorgan-g commentedon Mar 3, 2022
The longer-term solution is that anything setting up an isolate where plugins are expected to work should call
DartPluginRegistrant.ensureInitialized(), which will run all Dart plugin registration (similar to how they already need to callWidgetsFlutterBinding.ensureInitialized()to make platform message work in the first place). That's not currently onstableyet though, as it only just landed onmaster.stuartmorgan-g commentedon Mar 7, 2022
To summarize the solution: at the start of the entry point for any isolate that needs to use plugins (where you are presumably already calling
WidgetsFlutterBinding.ensureInitialized()):master), callDartPluginRegistrant.ensureInitialized(), which will run the Dart plugin registration for all plugins that need it.registerWithof any plugin implementations you use that have Dart registration. Forpath_provider, see above for details.Since the plan going forward is to require
DartPluginRegistrant.ensureInitialized()in isolates, closing as fixed.Henk-Keijzer commentedon Mar 7, 2022
subhashish-bacancy commentedon Mar 15, 2022
github-actions commentedon Mar 29, 2022
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.