Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ExampleHostApi
import FlutterError
import MessageData
import MessageFlutterApi
import androidx.annotation.NonNull
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.embedding.engine.plugins.FlutterPlugin
Expand Down Expand Up @@ -37,22 +36,21 @@ private class PigeonApiImplementation : ExampleHostApi {
// #enddocregion kotlin-class

// #docregion kotlin-class-flutter
private class PigeonFlutterApi {

private class PigeonFlutterApi(binding: FlutterPlugin.FlutterPluginBinding) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This and the constructor->init change were an Android Studio-suggested refactor; I figured I might as well update it to follow recommendations while I was there, but I can back this part out if we don't want it.

var flutterApi: MessageFlutterApi? = null

constructor(binding: FlutterPlugin.FlutterPluginBinding) {
flutterApi = MessageFlutterApi(binding.getBinaryMessenger())
init {
flutterApi = MessageFlutterApi(binding.binaryMessenger)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was a Kotlin style suggestion from AS.

}

fun callFlutterMethod(aString: String, callback: (Result<String>) -> Unit) {
flutterApi!!.flutterMethod(aString) { echo -> callback(Result.success(echo)) }
flutterApi!!.flutterMethod(aString) { echo -> callback(echo) }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Per discussion in another PR, this code is wrong, and we just hadn't noticed because it wasn't building.

}
}
// #enddocregion kotlin-class-flutter

class MainActivity : FlutterActivity() {
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AS flagged that we shouldn't be using nullability annotations in Kotlin.

super.configureFlutterEngine(flutterEngine)

val api = PigeonApiImplementation()
Expand Down
6 changes: 3 additions & 3 deletions packages/pigeon/example/app/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ private class PigeonFlutterApi {
}

func callFlutterMethod(
aString aStringArg: String?, completion: @escaping (Result<String, Error>) -> Void
aString aStringArg: String?, completion: @escaping (Result<String, PigeonError>) -> Void
) {
flutterAPI.flutterMethod(aString: aStringArg) {
completion(.success($0))
completion($0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As with the Kotlin file, this was wrong and didn't compile.

}
}
}
// #enddocregion swift-class-flutter

@UIApplicationMain
@main
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was a Flutter tool auto-migration; I didn't see any reason to undo it.

@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
11 changes: 0 additions & 11 deletions packages/pigeon/example/pubspec.yaml

This file was deleted.