Hello, this is raelly great what you have done. I cannot figure out how to invoke the native keyboard (the strip of letters). I tried some swift stuff but no luck. Any help greatly appreciated.
import Flutter
@main
@objc class AppDelegate: FlutterAppDelegate {
var textField: UITextField?
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
// Setup the method channel to communicate with Flutter
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
let channel = FlutterMethodChannel(name: "flutter_tv/input", binaryMessenger: controller.binaryMessenger)
channel.setMethodCallHandler { [weak self] (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
if call.method == "showNativeKeyboard" {
self?.showNativeTextField()
result(nil)
} else {
result(FlutterMethodNotImplemented)
}
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
func showNativeTextField() {
// Create and configure UITextField
let uiTextField = UITextField(frame: CGRect(x: 50, y: 100, width: 300, height: 50))
uiTextField.backgroundColor = .white
uiTextField.placeholder = "Enter your review"
uiTextField.borderStyle = .roundedRect
uiTextField.becomeFirstResponder() // Show the keyboard
// Add it to the root view
if let rootView = window?.rootViewController?.view {
rootView.addSubview(uiTextField)
}
// Store a reference to the text field so it can be dismissed later if needed
textField = uiTextField
}
}
class TvKeyboardHelper {
static const platform = MethodChannel('flutter_tv/input');
static Future<void> showNativeKeyboard() async {
try {
await platform.invokeMethod('showNativeKeyboard');
} on PlatformException catch (e) {
print("Failed to show native keyboard: ${e.message}");
}
}
}
Hello, this is raelly great what you have done. I cannot figure out how to invoke the native keyboard (the strip of letters). I tried some swift stuff but no luck. Any help greatly appreciated.