I get framework from external. so I want to use native code in flutter. If user click button, it shows new page.
error message
Swift Compiler Error (Xcode): Editor placeholder in source file AppDelegate.swift:18:48
No-usage (Xcode): Function is unused AppDelegate.swift:18:10
Uncategorized (Xcode): Command EmitSwiftModule failed with a nonzero exit code
If I change ViewController.openNewPage(<#T##self: ViewController##ViewController#>) to result(100). it works very well.
Flutter code
ElevatedButton(onPressed: _openNewpage, child: Text("button"))
Future _openNewpage() async {
await MethodChannel("io").invokeMethod("openNewPage");
}
AppDelegate.swift
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
let openChannel = FlutterMethodChannel(name:"io", binaryMessenger: controller.binaryMessenger)
openChannel.setMethodCallHandler({
(call:FlutterMethodCall, result:@escaping FlutterResult)->Void in
guard call.method == "openNewPage" else{
result(FlutterMethodNotImplemented)
return
}
ViewController.openNewPage(<#T##self: ViewController##ViewController#>)
})
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
ViewController.swift
class ViewController: FlutterViewController {
var openScreen: FinpongPlusScreen!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
func openNewPage(_ sender:Any) {
finpongPlus = FinpongPlusScreen()
finpongPlus.finpongPlusDelegate = self
finpongPlus.modalPresentationStyle = .fullScreen
finpongPlus.mode = FinpongPlusScreen.Mode.SAMPLE
finpongPlus.entry = "0"
finpongPlus.log = true
present(finpongPlus, animated: true, completion: nil)
}