-
Notifications
You must be signed in to change notification settings - Fork 32
refactor(flutter_plugin): add pigeon for platform communication #386
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
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
6eceab7
feat: add pigeon and messages.dart
marcossevilla 753302b
refactor: use host api instead of method channel
marcossevilla f085015
refactor(android): use host api
marcossevilla eb90aa5
refactor(ios): use host api
marcossevilla 285d923
refactor(linux): use host api
marcossevilla e730b9e
refactor(macos): use host api
marcossevilla 189e41f
refactor(windows): use host api
marcossevilla fb2d2c2
refactor(android): implement host api in plugin
marcossevilla ba630c3
refactor(ios): implement host api in plugin
marcossevilla 8c7aa8b
refactor(macos): implement host api in plugin
marcossevilla fd200d1
refactor(linux): implement host api in plugin
marcossevilla 89c8724
refactor(hooks): update plugin's hook tests
marcossevilla a127ceb
Merge branch 'main' into feat/flutter_plugin/pigeon
marcossevilla da6f8ae
fix: linux and windows pigeon migration
marcossevilla 28220f6
chore: remove build files
marcossevilla 8150a59
chore: ignore generated files
marcossevilla da52155
Merge branch 'main' into feat/flutter_plugin/pigeon
marcossevilla f759288
fix: correct iOS doc macro reference from _android to _ios
marcossevilla 5620eeb
fix: conflicts
marcossevilla dc1bdfb
Merge branch 'main' into feat/flutter_plugin/pigeon
marcossevilla c5ecb59
Merge branch 'main' into feat/flutter_plugin/pigeon
marcossevilla d106e23
ci: add missing params
marcossevilla a413a92
Merge branch 'feat/flutter_plugin/pigeon' of github.com:VeryGoodOpenS…
marcossevilla 125af9f
Merge branch 'main' into feat/flutter_plugin/pigeon
marcossevilla 9a6ef7d
fix: skip running pigeon on web platform
marcossevilla d701f05
fix: dart format
marcossevilla 0b96001
fix: dart format
marcossevilla c650b7d
chore: update DartCli format
marcossevilla 21d99b1
feat: add path to DartCli.format
marcossevilla 06dd686
Merge branch 'main' into feat/flutter_plugin/pigeon
marcossevilla 8f15ece
fix: dart analyze
marcossevilla cd7e39e
Merge branch 'feat/flutter_plugin/pigeon' of github.com:VeryGoodOpenS…
marcossevilla 1d093ff
Merge branch 'main' into feat/flutter_plugin/pigeon
marcossevilla d24ea87
fix: tests
marcossevilla e68c780
Merge branch 'feat/flutter_plugin/pigeon' of github.com:VeryGoodOpenS…
marcossevilla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| .dart_tool/ | ||
| .packages | ||
| pubspec.lock | ||
| build/ | ||
|
|
||
| # Files and directories created by mason | ||
| .mason/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...rick__/{{#android}}{{project_name.snakeCase()}}_android{{/android}}/analysis_options.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| include: package:very_good_analysis/analysis_options.yaml | ||
| analyzer: | ||
| exclude: | ||
| - "**/*.g.dart" |
30 changes: 11 additions & 19 deletions
30
...}}/android/src/main/kotlin/{{org_name.pathCase()}}/{{project_name.pascalCase()}}Plugin.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,22 @@ | ||
| package {{org_name.dotCase()}} | ||
|
|
||
| import androidx.annotation.NonNull | ||
|
|
||
| import {{project_name.pascalCase()}}Api | ||
| import io.flutter.embedding.engine.plugins.FlutterPlugin | ||
| import io.flutter.plugin.common.MethodCall | ||
| import io.flutter.plugin.common.MethodChannel | ||
| import io.flutter.plugin.common.MethodChannel.MethodCallHandler | ||
| import io.flutter.plugin.common.MethodChannel.Result | ||
|
|
||
| class {{project_name.pascalCase()}}Plugin : FlutterPlugin, MethodCallHandler { | ||
| private lateinit var channel: MethodChannel | ||
| class {{project_name.pascalCase()}}Plugin : FlutterPlugin, {{project_name.pascalCase()}}Api { | ||
| companion object { | ||
| private const val TAG = "{{project_name.pascalCase()}}Plugin" | ||
| } | ||
|
|
||
| override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { | ||
| channel = MethodChannel(flutterPluginBinding.binaryMessenger, "{{project_name.snakeCase()}}_android") | ||
| channel.setMethodCallHandler(this) | ||
| override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) { | ||
| {{project_name.pascalCase()}}Api.setUp(binding.binaryMessenger, this) | ||
| } | ||
|
|
||
| override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { | ||
| if (call.method == "getPlatformName") { | ||
| result.success("Android ${android.os.Build.VERSION.RELEASE}") | ||
| } else { | ||
| result.notImplemented() | ||
| } | ||
| override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { | ||
| {{project_name.pascalCase()}}Api.setUp(binding.binaryMessenger, null) | ||
| } | ||
|
|
||
| override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { | ||
| channel.setMethodCallHandler(null) | ||
| override fun getPlatformName(callback: (Result<String?>) -> Unit) { | ||
| callback(Result.success("Android ${android.os.Build.VERSION.RELEASE}")) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...rick__/{{#android}}{{project_name.snakeCase()}}_android{{/android}}/pigeons/copyright.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Copyright (c) {{currentYear}}, {{org_name.titleCase()}} |
19 changes: 19 additions & 0 deletions
19
...rick__/{{#android}}{{project_name.snakeCase()}}_android{{/android}}/pigeons/messages.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // {{project_name.pascalCase()}}Api must be abstract. | ||
| // ignore_for_file: one_member_abstracts | ||
|
|
||
| import 'package:pigeon/pigeon.dart'; | ||
|
|
||
| @ConfigurePigeon( | ||
| PigeonOptions( | ||
| dartOut: 'lib/src/messages.g.dart', | ||
| dartPackageName: '{{project_name.snakeCase()}}', | ||
| kotlinOut: 'android/src/main/kotlin/{{org_name.pathCase()}}/Messages.g.kt', | ||
| kotlinOptions: KotlinOptions(), | ||
| copyrightHeader: 'pigeons/copyright.txt', | ||
| ), | ||
| ) | ||
| @HostApi() | ||
| abstract class {{project_name.pascalCase()}}Api { | ||
| @async | ||
| String? getPlatformName(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...r_plugin/__brick__/{{#ios}}{{project_name.snakeCase()}}_ios{{/ios}}/analysis_options.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| include: package:very_good_analysis/analysis_options.yaml | ||
| analyzer: | ||
| exclude: | ||
| - "**/*.g.dart" |
12 changes: 6 additions & 6 deletions
12
...}}_ios/Sources/{{project_name.snakeCase()}}_ios/{{project_name.pascalCase()}}Plugin.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| import Flutter | ||
| import UIKit | ||
|
|
||
| public class {{project_name.pascalCase()}}Plugin: NSObject, FlutterPlugin { | ||
| public class {{project_name.pascalCase()}}Plugin: NSObject, FlutterPlugin, {{project_name.pascalCase()}}Api { | ||
| public static func register(with registrar: FlutterPluginRegistrar) { | ||
| let channel = FlutterMethodChannel(name: "{{project_name.snakeCase()}}_ios", binaryMessenger: registrar.messenger()) | ||
| let binaryMessenger = registrar.messenger() | ||
| let instance = {{project_name.pascalCase()}}Plugin() | ||
| registrar.addMethodCallDelegate(instance, channel: channel) | ||
| {{project_name.pascalCase()}}ApiSetup.setUp(binaryMessenger: binaryMessenger, api: instance) | ||
| registrar.publish(instance) | ||
| } | ||
|
|
||
| public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { | ||
| result("iOS") | ||
| func getPlatformName(completion: @escaping (Result<String?, Error>) -> Void) { | ||
| completion(.success("iOS")) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...r_plugin/__brick__/{{#ios}}{{project_name.snakeCase()}}_ios{{/ios}}/pigeons/copyright.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Copyright (c) {{currentYear}}, {{org_name.sentenceCase()}} |
19 changes: 19 additions & 0 deletions
19
...r_plugin/__brick__/{{#ios}}{{project_name.snakeCase()}}_ios{{/ios}}/pigeons/messages.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // {{project_name.pascalCase()}}Api must be abstract. | ||
| // ignore_for_file: one_member_abstracts | ||
|
|
||
| import 'package:pigeon/pigeon.dart'; | ||
|
|
||
| @ConfigurePigeon( | ||
| PigeonOptions( | ||
| dartOut: 'lib/src/messages.g.dart', | ||
| dartPackageName: '{{project_name.snakeCase()}}', | ||
| swiftOut: 'ios/{{project_name.snakeCase()}}_ios/Sources/{{project_name.snakeCase()}}_ios/Messages.g.swift', | ||
| swiftOptions: SwiftOptions(), | ||
| copyrightHeader: 'pigeons/copyright.txt', | ||
| ), | ||
| ) | ||
| @HostApi() | ||
| abstract class {{project_name.pascalCase()}}Api { | ||
| @async | ||
| String? getPlatformName(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.