Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[path_provider] Error handle for WidgetsFlutterBinding added #4032

Closed
wants to merge 4 commits into from
Closed

[path_provider] Error handle for WidgetsFlutterBinding added #4032

wants to merge 4 commits into from

Conversation

evolvingkid
Copy link

@evolvingkid evolvingkid commented Jun 8, 2021

In the latest null safety path provider package for flutter, the getApplicationDocumentsDirectory() called on void main without WidgetsFlutterBinding.ensureInitialized() cause error as [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value.
The error actually occurs because of WidgetsFlutterBinding.ensureInitialized() not called .
So I added an error handler to check it. Error handler named as MissingFlutterWidgetInitialized Exception.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides. (Note that unlike the flutter/flutter repo, the flutter/plugins repo does use dart format. See plugin_tool format)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@stuartmorgan-g
Copy link
Contributor

Thanks for the contribution, however:

In the latest null safety path provider package for flutter, the getApplicationDocumentsDirectory() called on void main without WidgetsFlutterBinding.ensureInitialized()

This is true of literally every call in every plugin that uses method channels (which is essentially all of them). The solution to the error message not being clear isn't for every plugin to implement a workaround, it's flutter/flutter#78028

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants