Skip to content

First pass at using platform abstraction for plugins#92672

Merged
fluttergithubbot merged 6 commits intoflutter:masterfrom
fuzzybinary:feature/plugin_platform_interface_template
Mar 9, 2022
Merged

First pass at using platform abstraction for plugins#92672
fluttergithubbot merged 6 commits intoflutter:masterfrom
fuzzybinary:feature/plugin_platform_interface_template

Conversation

@fuzzybinary
Copy link
Contributor

@fuzzybinary fuzzybinary commented Oct 28, 2021

Change the flutter create --template plugin command to create a PlatformInterface as an abstraction for plugins.

Work to fix #92279

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], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 28, 2021
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@google-cla google-cla bot added the cla: yes label Oct 28, 2021
@fuzzybinary
Copy link
Contributor Author

fuzzybinary commented Oct 28, 2021

This is a first pass at the template updates for the PlatformInterface abstraction. This doesn't hit some of the requests of the ticket including showing an FFI implementation or any documentation updates on PlatformInterface.

But, I would love some guidance on whether that should be part of this PR or part of a different one, and what we might want to update.

Also, I did not add any tests for this, but all current tests pass. I'll double-check to see if any tests need to change or if I need to add one. Otherwise, I'll ask for a test exemption. Would love guidance on that as well.

@fuzzybinary
Copy link
Contributor Author

I've looked through current tests and it looks like none look for specific files, only ensuring that the _web file doesn't show when the web platform is asked for, so I think no new tests are needed.

@stuartmorgan-g
Copy link
Contributor

This doesn't hit some of the requests of the ticket including showing an FFI implementation

I think you misread the issue slightly. I wasn't saying that the template should demonstrate using FFI, but that using a platform interface in the template makes it easier for people developing plugins to adopt non-platform-channel implementations (such as FFI) on some platforms.

@stuartmorgan-g stuartmorgan-g self-requested a review October 29, 2021 18:07
@Hixie
Copy link
Contributor

Hixie commented Oct 29, 2021

This kind of change should be tested (even though similar code currently lacks tests).

@fuzzybinary
Copy link
Contributor Author

I've added a test to check that we create the plugin platform interface file, and added lines that check that the generated projects and examples pass analysis and unit tests. Since the internal test uses the platform channel, I think this covers the functionality I'm looking to test.

@fuzzybinary fuzzybinary force-pushed the feature/plugin_platform_interface_template branch 2 times, most recently from b60198d to bfd368c Compare November 1, 2021 15:04
@flutter-dashboard flutter-dashboard bot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Nov 1, 2021
@christopherfujino
Copy link
Contributor

@stuartmorgan can you take another look at this one?

@christopherfujino
Copy link
Contributor

@fuzzybinary it looks like you have merge conflicts, can you resolve them by rebasing upstream?

@stuartmorgan-g
Copy link
Contributor

stuartmorgan-g commented Feb 3, 2022

This is near the top of my review queue BTW; sorry it has taken so long to get back to.

@fuzzybinary fuzzybinary force-pushed the feature/plugin_platform_interface_template branch from 5152bc0 to bb8c079 Compare February 6, 2022 05:07
@google-cla google-cla bot added cla: no and removed cla: yes labels Feb 6, 2022
@skia-gold
Copy link

Gold has detected about 59 new digest(s) on patchset 4.
View them at https://flutter-gold.skia.org/cl/github/92672

@fuzzybinary fuzzybinary force-pushed the feature/plugin_platform_interface_template branch from bb8c079 to b0fd7b7 Compare February 6, 2022 05:19
@google-cla google-cla bot added cla: yes and removed cla: no labels Feb 6, 2022
@fuzzybinary
Copy link
Contributor Author

Rebased but it looks like some tests are failing on Mac. I'll come back and take a look Monday when I have some time.

Change the flutter create --template plugin command to create a PlatformInterface as an abstraction for plugins.
dart_plugin_registry_test creates a plugin called plugin_platform_interface, which conflicts with an actual plugin now used for platform abstractions. Renamed to plugin_platform_base.
@fuzzybinary fuzzybinary force-pushed the feature/plugin_platform_interface_template branch from b0fd7b7 to a86c806 Compare February 16, 2022 22:27
@fuzzybinary
Copy link
Contributor Author

Okay! Re-rebased and looks like tests are passing (no changes) so must have been an infra thing. Sorry for the delay in checking.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry again for the delay. Overall this looks great, but some specific comments.

@ditman should look at the web template changes.

pluginImplPubspecContent = pluginImplPubspecContent.replaceFirst(
' platforms:\n',
' implements: plugin_platform_interface\n'
' implements: plugin_platform_base\n'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really confusing name. The better fix here would be to change plugin to aplugin or someplugin everywhere in this test, and keep the standard suffixes.

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The web implementation looks correct. This should be easier to demonstrate by creating a plugin with this template and ensuring that the example app works correctly with flutter run -d chrome

Also: do we want to update the plugin template, or create a new template for this example, @stuartmorgan ?

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add platform interface to plugin template

7 participants