It's possible for the provider to get recreated when the button rebuilds. Since the authListener is set in initState it only happens the first time. Any auth methods called on the provider after the second rebuild will throw a late initialization error since the authListener will not be set. This PR adds code to store the provider in the state so that it cannot get reset externally.
I also set the isLoading to false in the onError callback otherwise the button will get stuck in a loading state when there is an error.
Related Issues
I don't see one
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.
[x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
[x] My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
[x] All existing and new tests are passing.
[x] I updated/added relevant documentation (doc comments with ///).
[x] The analyzer (melos run analyze) does not report any problems on my PR.
[x] All unit tests pass (melos run test:unit:all doesn't fail).
Description
It's possible for the provider to get recreated when the button rebuilds. Since the authListener is set in
initState
it only happens the first time. Any auth methods called on the provider after the second rebuild will throw a late initialization error since the authListener will not be set. This PR adds code to store the provider in the state so that it cannot get reset externally.I also set the
isLoading
to false in theonError
callback otherwise the button will get stuck in a loading state when there is an error.Related Issues
I don't see one
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process. Updating thepubspec.yaml
and changelogs is not required.///
).melos run analyze
) does not report any problems on my PR.melos run test:unit:all
doesn't fail).Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?