Input 颤振输入符号不出现,但始终显示十字符号
我有以下示例代码。我现在已经成功地安装了prefixicon,效果很好。我想把同一个图标移到右边后缀的意思,但它只是不起作用,但X符号显示的是什么。 这是一个屏幕截图。 我已经添加了以下几行:IconButton(但它似乎没有出现,但左侧的前缀看起来非常好。我无法获得右侧的一行。是什么阻止它出现 下面是我的代码Input 颤振输入符号不出现,但始终显示十字符号,input,flutter,Input,Flutter,我有以下示例代码。我现在已经成功地安装了prefixicon,效果很好。我想把同一个图标移到右边后缀的意思,但它只是不起作用,但X符号显示的是什么。 这是一个屏幕截图。 我已经添加了以下几行:IconButton(但它似乎没有出现,但左侧的前缀看起来非常好。我无法获得右侧的一行。是什么阻止它出现 下面是我的代码 class MyHomePageState extends State<MyHomePage> { // Show some different formats.
class MyHomePageState extends State<MyHomePage> {
// Show some different formats.
final formats = {
//InputType.both: DateFormat("EEEE, MMMM d, yyyy 'at' h:mma"),
//InputType.date: DateFormat('dd/MM/yyyy'),
//InputType.time: DateFormat("HH:mm"),
InputType.date: DateFormat("d MMMM yyyy"),
};
//InputType.date: DateFormat('yyyy-MM-dd'),
// Changeable in demo
InputType inputType = InputType.date;
bool editable = true;
DateTime date;
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: Text(appName)),
body: Padding(
padding: EdgeInsets.all(16.0),
child: ListView(
children: <Widget>[
Form(
//key: _myKey,
child: Column(
children : [
new Container(
width: 200.0,
child:new DateTimePickerFormField(
dateOnly: true,
format: formats[inputType],
editable: false,
validator: (val) {
if (val != null) {
return null;
} else {
return 'Date Field is Empty';
}
},
/*decoration: InputDecoration(
border: InputBorder.none,
labelText: 'From',contentPadding: const EdgeInsets.symmetric(horizontal: 20.0)),*/
decoration: InputDecoration(
hintText: 'To',
border: InputBorder.none,
filled: false,
prefixIcon: Icon(
Icons.arrow_drop_down,
color: Colors.blue,
size: 28.0,
),
suffixIcon: IconButton(
icon: Icon(Icons.arrow_drop_down,size: 28),
onPressed: () {
debugPrint('222');
})),
initialValue: DateTime.now().subtract(new Duration(days: 7)), //Add this in your Code.
),
)
]
),
),
RaisedButton(
onPressed: () {
/*if (_myKey.currentState.validate()) {
_myKey.currentState.save();
} else {
}*/ print("check;");
if(emailController.text.isEmpty){
print("TEST;");
//valid = false;
//emailError = "Email can't be blank!";
//openAlertBox();
Toast.show("Empty Date From", context, backgroundColor: Colors.red );
}
else{
print("not empty;");
final f = new DateFormat('yyyy-MM-dd');
final original = new DateFormat('d MMMM yyyy');
print("Format datre is"+emailController.text);
print("Formate date :"+original.parse(emailController.text).toString());
}
},
child: Text('Submit'),
)
],
),
));
类MyHomePageState扩展状态{
//显示一些不同的格式。
最终格式={
//InputType.both:DateFormat(“EEEE,MMMM d,yyyy”在“h:mma”),
//InputType.date:DateFormat('dd/MM/yyyy'),
//InputType.time:DateFormat(“HH:mm”),
InputType.date:DateFormat(“d MMMM yyyy”),
};
//InputType.date:DateFormat('yyyy-MM-dd'),
//可在演示中更改
InputType InputType=InputType.date;
bool=true;
日期时间日期;
@凌驾
小部件构建(构建上下文)=>Scaffold(
appBar:appBar(标题:文本(appName)),
主体:填充物(
填充:所有边缘设置(16.0),
子:ListView(
儿童:[
形式(
//钥匙:我的钥匙,
子:列(
儿童:[
新货柜(
宽度:200.0,
子项:新日期时间字段(
dateOnly:对,
格式:格式[inputType],
可编辑:false,
验证器:(val){
如果(val!=null){
返回null;
}否则{
返回“日期字段为空”;
}
},
/*装饰:输入装饰(
边框:InputBorder.none,
labelText:'From',contentPadding:const EdgeInsets.symmetric(水平:20.0))*/
装饰:输入装饰(
hintText:'到',
边框:InputBorder.none,
填充:假,
前缀:图标(
Icons.arrow\u下拉菜单,
颜色:颜色,蓝色,
尺寸:28.0,
),
后缀:图标按钮(
图标:图标(图标。箭头下拉,大小:28),
已按下:(){
debugPrint('222');
})),
initialValue:DateTime.now().subtract(新的持续时间(天:7)),//将其添加到代码中。
),
)
]
),
),
升起的按钮(
已按下:(){
/*if(_myKey.currentState.validate()){
_myKey.currentState.save();
}否则{
}*/打印(“支票;”;
if(emailController.text.isEmpty){
打印(“测试;”;
//有效=错误;
//emailError=“电子邮件不能为空!”;
//openAlertBox();
Toast.show(“空日期开始”,上下文,背景颜色:Colors.red);
}
否则{
打印(“非空;”;
最终f=新的日期格式(“yyyy-MM-dd”);
最终原件=新的日期格式('d MMMM yyyy');
打印(“格式数据为”+emailController.text);
打印(“格式化日期:+original.parse(emailController.text).toString());
}
},
子项:文本('Submit'),
)
],
),
));
我重新创建了您的案例,只选择了您提供的TextFormField
代码,并且能够将下拉箭头
视为后缀
我看到您使用了
填充作为主体
返回脚手架
。尝试将其替换为中心
或容器
我通过仅挑出您提供的文本表单字段
代码重新创建了您的案例,并且能够将下拉箭头
视为后缀
我看到您使用了填充作为主体
返回脚手架
。尝试将其替换为中心
或容器
您可能发现了以下内容,但只是为了以防万一
显示的“X”是日期字段的重置图标,即。您可以使用该图标清除该字段。您可以使用DateTimePickPerformField属性“resetIcon:null;”将其关闭,但从字段中删除日期的唯一方法是确保“editable:true”为默认值,但您已在代码中覆盖它。
希望能有所帮助。你可能已经发现了以下内容,但只是为了以防万一
显示的“X”是日期字段的重置图标,即。您可以使用该图标清除该字段。您可以使用DateTimePickPerformField属性“resetIcon:null;”将其关闭,但从字段中删除日期的唯一方法是确保“editable:true”为默认值,但您已在代码中覆盖它。
希望这能有所帮助。我不明白填充是什么意思?您在构建函数中使用了body:padding
。尝试将其替换为Container
。因为填充似乎有问题,您无法在后缀位置看到图标。我看到您将填充替换为右中。我还有什么其他选择吗除此之外,我不明白填充是什么意思?您在构建函数中有body:padding
。请尝试将其替换为Container
。因为填充似乎有问题,您无法在后缀位置看到图标。
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
height: MediaQuery
.of(context)
.size
.height,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children : [
new Container(
color: Colors.yellow,
width: 200.0,
child: TextFormField(
decoration: InputDecoration(
hintText: 'To',
border: InputBorder.none,
filled: false,
prefixIcon: Icon(
Icons.arrow_drop_down,
color: Colors.blue,
size: 28.0,
),
suffixIcon: IconButton(
icon: Icon(Icons.arrow_drop_down,size: 28),
onPressed: () {
debugPrint('222');
})),
),
)
]
)
),
)
);
}
}