-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[macOS] Add platform_channel sample/test #123141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
examples/platform_channel/macos/Runner/BatteryLevelPlugin.swift
Outdated
Show resolved
Hide resolved
9db4ce0 to
f0c4e9a
Compare
loic-sharma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but consider getting approval from someone with more Swift expertise.
|
Do you know why the |
|
This code serves two primary purposes:
To the first point, having a separate Swift example made sense when the iOS default was Obj-C but we were migrating towards a Swift-based future. Now that the default for iOS plugins is Swift, it makes sense to simply replace the Obj-C example with the Swift code and delete the extra Swift example. To the second point, the goal is an integration test verifying method and event channels; the language is irrelevant, so Swift-only should be sufficient. /cc @jmagman for thoughts on that end. If you think it makes sense to keep an Obj-C version around, I'd suggest the Swift implementation be moved to the main |
01b28ae to
a8669a6
Compare
yaakovschectman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I am not very familiar with Swift or MacOS
+1 to doing this if we keep both. (I should probably do the same with Android, moving Java out and making the primary example Kotlin.)
We also link to this as the runnable version of https://docs.flutter.dev/development/platform-integration/platform-channels#example (updating that page was the initial motivation for me wanting the macOS version of this code). If we remove the Obj-C example here we'll need to at least update the text in that info box; we could also re-evaluate whether we still also want the Obj-C example on that page. |
examples/platform_channel/macos/Runner/BatteryLevelPlugin.swift
Outdated
Show resolved
Hide resolved
Adds a macOS implementation of the platform_channel example, demonstrating method channels and event channels with a battery power plugin. Adds platform_channel_sample_test_macos macOS host test to verify the sample works. Issue: flutter#79204
a8669a6 to
1ed8098
Compare
For consistency with rest of examples.
1ed8098 to
fd0591b
Compare
|
@hellohuanlin would you mind reviewing this post-merge? @cbracken can follow up with changes you suggest. |
* cbdee52 Roll Flutter Engine from 59acb5362098 to 12c822327825 (3 revisions) (flutter/flutter#123330) * 897e3db Inject the gstatic CanvasKit CDN URL by default in `flutter build web` (flutter/flutter#122772) * 5a36bdd Stop serving Observatory by default (flutter/flutter#122419) * b212e7b implement Iterator and Comparable instead of extending them (flutter/flutter#123282) * af6029c c0fbe5a53 Roll Dart SDK from 9256fffbd5af to e8e045620234 (1 revision) (flutter/engine#40561) (flutter/flutter#123336) * 9dec4fb FIX: NavigationDrawer hover/focus/pressed does not use indicatorShape (flutter/flutter#123325) * 4907464 20ab040cd Roll Skia from ce5ff5cc03ce to c42320d53714 (2 revisions) (flutter/engine#40565) (flutter/flutter#123340) * 28d40a4 Roll Packages from 75491e9 to 0826798 (5 revisions) (flutter/flutter#123342) * 674ff15 [macOS] Add platform_channel sample/test (flutter/flutter#123141) * 7b7af9f roll packages (flutter/flutter#123339) * 3179875 replace some ._() constructors with class modifiers (flutter/flutter#122765) * 7f41ab2 Fix (insert|move|remove)RenderObjectChild methods in base class (flutter/flutter#123276) * fccca49 Refactor buildOverscrollIndicator (flutter/flutter#123246) * 11bbce1 6b0933e74 [web] Add `dart:js_interop` to `_embedder.yaml`. (flutter/engine#40545) (flutter/flutter#123347) * 716d252 Remove prefer_const_constructors ignores (flutter/flutter#123284) * 100cf21 Prefer enum over class. (flutter/flutter#123312) * 5ef9b84 Expose toggle to textfield's opacity animation. (flutter/flutter#122474) * d79f3aa Roll Flutter Engine from 6b0933e74965 to bdce896fb64f (2 revisions) (flutter/flutter#123351)
hellohuanlin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments. Let me know if any questions and I'm more than happy to assist (anything Swift related is my favorite!)
Some comments might be outdated since you may have fixed it in separate PRs
This adds a macOS section to the example implementation instructions, following the same structure as the existing examples, and using the code from flutter/flutter#123141 This is the macOS equivalent of #7328 and #8127 Fixes flutter/flutter#79204
This adds a macOS section to the example implementation instructions, following the same structure as the existing examples, and using the code from flutter/flutter#123141 This is the macOS equivalent of #7328 and #8127 Fixes flutter/flutter#79204 ## Presubmit checklist - [x] This PR doesn’t contain automatically generated corrections (Grammarly or similar). - [x] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style) — for example, it doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person). - [x] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/master/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer.
) * cbdee52 Roll Flutter Engine from 59acb5362098 to 12c822327825 (3 revisions) (flutter/flutter#123330) * 897e3db Inject the gstatic CanvasKit CDN URL by default in `flutter build web` (flutter/flutter#122772) * 5a36bdd Stop serving Observatory by default (flutter/flutter#122419) * b212e7b implement Iterator and Comparable instead of extending them (flutter/flutter#123282) * af6029c c0fbe5a53 Roll Dart SDK from 9256fffbd5af to e8e045620234 (1 revision) (flutter/engine#40561) (flutter/flutter#123336) * 9dec4fb FIX: NavigationDrawer hover/focus/pressed does not use indicatorShape (flutter/flutter#123325) * 4907464 20ab040cd Roll Skia from ce5ff5cc03ce to c42320d53714 (2 revisions) (flutter/engine#40565) (flutter/flutter#123340) * 28d40a4 Roll Packages from 75491e9 to 0826798 (5 revisions) (flutter/flutter#123342) * 674ff15 [macOS] Add platform_channel sample/test (flutter/flutter#123141) * 7b7af9f roll packages (flutter/flutter#123339) * 3179875 replace some ._() constructors with class modifiers (flutter/flutter#122765) * 7f41ab2 Fix (insert|move|remove)RenderObjectChild methods in base class (flutter/flutter#123276) * fccca49 Refactor buildOverscrollIndicator (flutter/flutter#123246) * 11bbce1 6b0933e74 [web] Add `dart:js_interop` to `_embedder.yaml`. (flutter/engine#40545) (flutter/flutter#123347) * 716d252 Remove prefer_const_constructors ignores (flutter/flutter#123284) * 100cf21 Prefer enum over class. (flutter/flutter#123312) * 5ef9b84 Expose toggle to textfield's opacity animation. (flutter/flutter#122474) * d79f3aa Roll Flutter Engine from 6b0933e74965 to bdce896fb64f (2 revisions) (flutter/flutter#123351)
Adds a macOS implementation of the platform_channel example, demonstrating method channels and event channels with a battery power plugin.
Adds platform_channel_sample_test_macos macOS host test to verify the sample works.
Issue: #79204
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.