键盘无法与TextField
一起正常工作。
下面的代码我放了14 TextField
,但是当在字段14中点击时,键盘没有出现,并且不在TextField
点击的下方。
你可以帮助我解决这个键盘问题没有出现并且没有让我在所选领域之下吗?
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(home: new HomePage()));
}
class HomePage extends StatefulWidget {
@override
HomePageState createState() => new HomePageState();
}
class HomePageState extends State<HomePage> {
final TextEditingController _controller = new TextEditingController();
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Stack(
children: <Widget>[
new ListView(
shrinkWrap: true,
children: <Widget>[
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 1',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 2',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 3',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 4',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 5',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 6',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 7',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 8',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 9',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 10',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 11',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 12',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 13',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 14',
),
),
],
)
]
)
);
}
}
答案 0 :(得分:4)
我遇到了同样的问题,但就我而言,它在Key对象中
x
通过设置键静态类字段来解决问题
BaseClass myclass = System.Activator.CreateInstance(Config.ClassToUse)
答案 1 :(得分:3)
您不应该让所有文本字段共享相同的TextEditingController
。每个都使用一个单独的控制器。
答案 2 :(得分:1)
修改Android 应用程序级别gradle 文件并将我的 compileSdkVersion 和 targetSdkVersion 都更新为 28 后,我遇到了这个问题默认值( 27 )。考虑将其保留为默认版本。我正在使用Google Play商店在android 9模拟器上进行测试。
答案 3 :(得分:1)
将Globalkey创建移出构建函数。
GlobalKey<ScaffoldState> _profileScaffoldKey = new GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
key: _profileScaffoldKey,
答案 4 :(得分:0)
我无法重现错误,一切似乎都能正常工作。检查您的 Flutter SDK 是否已更新(运行flutter doctor
)。您是否尝试将目标平台更改为IOS以查看错误是否仍然存在?
答案 5 :(得分:-3)
要使下面的键盘成为 textFormFeild 使用属性:
resizeToAvoidBottomInset: true ,在 Scaffold Widget 中。