有没有一种方法可以在flutter中的WebView TextInput字段中自动对焦键盘?
我正在使用 inappwebview 在颤音应用程序中显示该网页。仅当我点击输入字段时,仅显示键盘。有没有办法在攻击输入字段之前可见键盘?键盘应在导航到此屏幕后立即出现。这是代码:
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
class WebViewScreen extends StatefulWidget {
const WebViewScreen({Key? key}) : super(key: key);
@override
State<WebViewScreen> createState() => _WebViewScreenState();
}
class _WebViewScreenState extends State<WebViewScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: InAppWebView(
initialUrlRequest:
URLRequest(url: Uri.parse('https://www.google.com')),
onWebViewCreated: (InAppWebViewController controller) {
print('onWebViewCreated');
},
onProgressChanged:
(InAppWebViewController controller, int progress) {
print('onProgressChanged: $progress');
},
),
),
),
);
}
}
I am using InAppWebView to show the webpage in a flutter app. Here keyboard is shown only when I tap on the input field. Is there a way that the keyboard is visible before tapping on the input field? The keyboard should appear right after navigating to this screen. Here is the code:
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
class WebViewScreen extends StatefulWidget {
const WebViewScreen({Key? key}) : super(key: key);
@override
State<WebViewScreen> createState() => _WebViewScreenState();
}
class _WebViewScreenState extends State<WebViewScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: InAppWebView(
initialUrlRequest:
URLRequest(url: Uri.parse('https://www.google.com')),
onWebViewCreated: (InAppWebViewController controller) {
print('onWebViewCreated');
},
onProgressChanged:
(InAppWebViewController controller, int progress) {
print('onProgressChanged: $progress');
},
),
),
),
);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
并使用
webview_flutter
插件,它可以使用:Using
addUserScript
method gives method implementation error.And using
webview_flutter
plugin, it works: