feat(amplify_flutter): allow customers to override AmplifyClass methods #1325
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available: n/a
Goal:
Issue description:
AmplifyClass
has a setter for the private_instance
field. This allows a customer to pass in their own AmplifyClass implementation. However, the instance they pass in isn't used (except in one location, where a private method is invoked, and private methods can't be overridden from outside the lib anyway). This means that customers can technically create their own AmplifyClass implementation, but they can't override any of the methods, which defeats the whole point.Description of changes:
Example:
Here is an example where AmplifyClass is stubbed for the purpose of running a (mocked) demo of the Amplify Authenticator in the browser. The implementation here is similar to the implementation in the real class. The key difference is that the method channel is never invoked. This is important because the method channel will not be available in the browser.
A similar stub could be used to allow Amplify.configure() and Amplify.addPlugin() to be called from within a widget/unit tests. Right now those methods can only be called from within integ tests. We had an issue opened in the past related to this.
This also would in theory allow a custom to write their own implementation for a platform we don't currently support, although I think that is an unlikely use case.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.