问题描述
我在滚动时遇到这个问题,当我聚焦文本字段时,红色容器覆盖了我要写的文本字段。 如何控制滚动,以使文本字段显示在红色容器上方?
我想在keabord上方显示红色的Container,当用户在Textfield中书写时,我要激活nect按钮。
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
FocusNode _focusNode = new FocusNode();
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Focus Example"),),body: Stack(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,crossAxisAlignment: CrossAxisAlignment.center,children: <Widget>[
Expanded(
flex: 9,// 90% of space => (6/(6 + 4))
child: LayoutBuilder(
builder: (context,constraint) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints:
BoxConstraints(minHeight: constraint.maxHeight),child: IntrinsicHeight(
child: Column(
children: <Widget>[
new Container(
height: 800.0,color: Colors.blue.shade200),new TextFormField(
focusNode: _focusNode,decoration: new InputDecoration(
hintText: 'Focus me!',new Container(
height: 800.0,],);
},)),Expanded(
flex: 1,// 10% of space
child: Container(
color: Colors.purple,alignment: Alignment.center,Align(
alignment: Alignment.bottomCenter,child: Container(
padding: EdgeInsets.only(left: 10.0,right: 10.0),height: 60,color: Colors.red,child: Row(
crossAxisAlignment: CrossAxisAlignment.center,mainAxisAlignment: MainAxisAlignment.spaceBetween,children: [
GestureDetector(
child: Text("Back",style:
TextStyle(color: Colors.white,fontSize: 18.0)),onTap: () {}),Container(
width: 40,height: 40,child: FlatButton(
textColor: Colors.white,disabledColor: Colors.grey,disabledTextColor: Colors.white70,padding: EdgeInsets.only(top: 0.0,bottom: 0.0),splashColor: Colors.white,onPressed: () {},child: Icon(
Icons.navigate_next,size: 35,)
],)
],));
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)