Flutter iOS-如何隐藏iOS键盘顶部的完成按钮?
“完成”按钮在 Flutter Web(Safari、Chrome)上不起作用。
我刚刚将一个 Textformfield 小部件添加到“计数器示例项目”中,并在 Chrome 上构建它。
我在 iOS 模拟器上访问相同的本地主机 URL。
正如你在 GIF 中看到的,当我按下完成按钮时,键盘并没有消失,而是继续重新出现。
有什么办法可以隐藏这个“完成”按钮吗? 或者有什么好的方法可以解决这个问题吗?
我很抱歉我的英语不好...... 请回答我。 谢谢。
下面是我的整个颤振代码。
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextFormField(
autofocus: false,
enableSuggestions: false,
toolbarOptions: null,
keyboardType: TextInputType.visiblePassword),
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
The DONE button doesn't work on Flutter Web (Safari, Chrome).
I just added a Textformfield Widget to 'Counter Example Project' and built it on Chrome.
And I access the same Localhost URL on the iOS simulator.
As you can see in the GIF, when I press the done button, the keyboard does not disappear and continues to reappear.
Is there any way to hide this 'DONE' button?
Or is there any good way to solve this problem?
I'm sorry about my poor English...
Please answer me.
Thank you.
Here is my whole flutter code below.
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextFormField(
autofocus: false,
enableSuggestions: false,
toolbarOptions: null,
keyboardType: TextInputType.visiblePassword),
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论