Dart 当某些项目不符合';我没有引导对象
以下是我在屏幕上看到的内容: 如何将姓氏对齐,使其位于名下? 我不想在姓氏旁边放一个图标,只想在名字旁边放一个图标 这是我的密码。谢谢Dart 当某些项目不符合';我没有引导对象,dart,flutter,flutter-layout,Dart,Flutter,Flutter Layout,以下是我在屏幕上看到的内容: 如何将姓氏对齐,使其位于名下? 我不想在姓氏旁边放一个图标,只想在名字旁边放一个图标 这是我的密码。谢谢 body: Center( child: Form( key: _formKey, child: Column( children: <Widget>[
body: Center(
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
ListTile(
leading: const Icon(Icons.person),
title: new TextField(
decoration: new InputDecoration(
hintText: "First name",
),
),
),
ListTile(
title: new TextField(
decoration: new InputDecoration(
hintText: "Last name",
),
),
),
],
),
)
)
主体:中心(
孩子:表格(
键:_formKey,
子:列(
儿童:[
列表砖(
前导:常量图标(Icons.person),
标题:新文本字段(
装饰:新的输入装饰(
hintText:“名字”,
),
),
),
列表砖(
标题:新文本字段(
装饰:新的输入装饰(
hintText:“姓氏”,
),
),
),
],
),
)
)
您可以在姓氏文本字段
中添加一个固定宽度的空容器
,或将您的姓氏文本字段
包装在填充
内,并从左侧提供一些填充
例如:
ListTile(
leading: Container(
width: 200.0, //You can adjust the width as required
),
title: new TextField(
decoration: new InputDecoration(
hintText: "Last name",
),
),
),
或
您可以将一个固定宽度的空
容器
添加到姓氏文本字段
,也可以将您的姓氏文本字段
包装在填充
内,并从左侧提供一些填充
例如:
ListTile(
leading: Container(
width: 200.0, //You can adjust the width as required
),
title: new TextField(
decoration: new InputDecoration(
hintText: "Last name",
),
),
),
或
通过将图标颜色更改为colors.transparent,可以快速破解。我不知道这是不是合适的方式
body: Center(
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
ListTile(
leading: const Icon(Icons.person),
title: new TextField(
decoration: new InputDecoration(
hintText: "First name",
),
),
),
ListTile(
leading: const Icon(Icons.person,color: Colors.transparent),
title: new TextField(
decoration: new InputDecoration(
hintText: "Last name",
),
),
),
],
),
)
)
主体:中心(
孩子:表格(
键:_formKey,
子:列(
儿童:[
列表砖(
前导:常量图标(Icons.person),
标题:新文本字段(
装饰:新的输入装饰(
hintText:“名字”,
),
),
),
列表砖(
前导:常量图标(图标。人物,颜色:颜色。透明),
标题:新文本字段(
装饰:新的输入装饰(
hintText:“姓氏”,
),
),
),
],
),
)
)
通过将图标颜色更改为colors.transparent,可以快速破解。我不知道这是不是合适的方式
body: Center(
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
ListTile(
leading: const Icon(Icons.person),
title: new TextField(
decoration: new InputDecoration(
hintText: "First name",
),
),
),
ListTile(
leading: const Icon(Icons.person,color: Colors.transparent),
title: new TextField(
decoration: new InputDecoration(
hintText: "Last name",
),
),
),
],
),
)
)
主体:中心(
孩子:表格(
键:_formKey,
子:列(
儿童:[
列表砖(
前导:常量图标(Icons.person),
标题:新文本字段(
装饰:新的输入装饰(
hintText:“名字”,
),
),
),
列表砖(
前导:常量图标(图标。人物,颜色:颜色。透明),
标题:新文本字段(
装饰:新的输入装饰(
hintText:“姓氏”,
),
),
),
],
),
)
)
简单而优雅的方法是使用填充
小部件
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Form(
// key: _formKey,
child: Column(
children: <Widget>[
ListTile(
leading: const Icon(Icons.person),
title: new TextField(
decoration: new InputDecoration(
hintText: "First name",
),
),
),
ListTile(
leading: Padding(padding: EdgeInsets.all(16.0)),
title: new TextField(
decoration: new InputDecoration(
hintText: "Last name",
),
),
),
],
),
)),
);
}
@覆盖
小部件构建(构建上下文){
返回脚手架(
正文:中(
孩子:表格(
//键:_formKey,
子:列(
儿童:[
列表砖(
前导:常量图标(Icons.person),
标题:新文本字段(
装饰:新的输入装饰(
hintText:“名字”,
),
),
),
列表砖(
前导:填充(填充:EdgeInsets.all(16.0)),
标题:新文本字段(
装饰:新的输入装饰(
hintText:“姓氏”,
),
),
),
],
),
)),
);
}
简单而优雅的方法是使用填充
小部件
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Form(
// key: _formKey,
child: Column(
children: <Widget>[
ListTile(
leading: const Icon(Icons.person),
title: new TextField(
decoration: new InputDecoration(
hintText: "First name",
),
),
),
ListTile(
leading: Padding(padding: EdgeInsets.all(16.0)),
title: new TextField(
decoration: new InputDecoration(
hintText: "Last name",
),
),
),
],
),
)),
);
}
@覆盖
小部件构建(构建上下文){
返回脚手架(
正文:中(
孩子:表格(
//键:_formKey,
子:列(
儿童:[
列表砖(
前导:常量图标(Icons.person),
标题:新文本字段(
装饰:新的输入装饰(
hintText:“名字”,
),
),
),
列表砖(
前导:填充(填充:EdgeInsets.all(16.0)),
标题:新文本字段(
装饰:新的输入装饰(
hintText:“姓氏”,
),
),
),
],
),
)),
);
}
谢谢您的回复。如果我理解正确,EdgeInsets填充是以像素为单位测量的。无论设备/分辨率如何,都能正常工作吗?字段是否保持对齐?图标的大小是否固定?如果在不同的设备/分辨率上看起来不一样,我如何实现这一点?我是一个新手,已经有几年没有使用安卓了,所以感谢大家的耐心。我们实际上是在给标题所占的空间:
以防出现图标
。因此,是的,它将在不同的设备和分辨率上正常工作。就好像我们有看不见的智慧