如何在Flutter布局中创建可编辑的输入字段?
我正在用flutter构建一个登录屏幕,并希望用字段替换下划线(“ ___________”),用户可以输入其电子邮件和密码。这是一个视觉表示:
预期的结果:
当前代码:
class LogInEnterEmailPassword extends StatefulWidget {
const LogInEnterEmailPassword({Key? key}) : super(key: key);
@override
State<LogInEnterEmailPassword> createState() => _LogInEnterEmailPasswordState();
}
class _LogInEnterEmailPasswordState extends State<LogInEnterEmailPassword> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xffF6F6F6),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text("Enter email",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xff3B3B3B),
),),
SizedBox(height: 20,),
Text("______________________________",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xffD7D7D7),
),),
SizedBox(height: 110,),
Text("Enter password",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xff3B3B3B),
),),
SizedBox(height: 25,),
Text("______________________________",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xffD7D7D7),
),),
SizedBox(height: 110,),
Icon(Icons.arrow_forward,
size: 40,
color: Color(0xff7E7E7E),)
],
),
)
);
}
}
其他注释:
- 我目前专注于前端设计。
- 我正在考虑稍后的后端node.js。
I'm building a login screen in Flutter and want to replace the underscores ("___________") with fields where users can enter their email and password. Here's a visual representation:
Desired Outcome:
Current Code:
class LogInEnterEmailPassword extends StatefulWidget {
const LogInEnterEmailPassword({Key? key}) : super(key: key);
@override
State<LogInEnterEmailPassword> createState() => _LogInEnterEmailPasswordState();
}
class _LogInEnterEmailPasswordState extends State<LogInEnterEmailPassword> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xffF6F6F6),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text("Enter email",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xff3B3B3B),
),),
SizedBox(height: 20,),
Text("______________________________",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xffD7D7D7),
),),
SizedBox(height: 110,),
Text("Enter password",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xff3B3B3B),
),),
SizedBox(height: 25,),
Text("______________________________",
style: TextStyle(
fontSize: 20,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
color: Color(0xffD7D7D7),
),),
SizedBox(height: 110,),
Icon(Icons.arrow_forward,
size: 40,
color: Color(0xff7E7E7E),)
],
),
)
);
}
}
Additional Notes:
- I'm currently focused on the frontend design.
- I'm considering Node.js for the backend later.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
大小尺寸大小(高度:110)
之间的小部件之间。这就是为什么要获得较大空间的原因,可以降低高度值,并使用高度播放:x
值。还使用
crossaxisalignment:crossaxisalignment.start,
在column()
更新:更新:进行用户输入,使用
textfield
还有其他装饰可以像
utlineInputborder
一样使用。您可以查看有关
textfield
You are having large-sized of
SizedBox(height:110)
between widgets. that's why you are getting large spaces, you can reduce the height value, and play with theheight:x
value.Also use
crossAxisAlignment: CrossAxisAlignment.start,
on theColumn()
Update: to take user input, use
TextField
There are others decoration can be used like
OutlineInputBorder
.You can check more about
InputDecoration
TextField