简体   繁体   English

TextFormField 颤动中提示和错误文本的单独 contentPadding

[英]Separate contentPadding for Hint and Error text in TextFormField flutter

Is there any way in flutter to control the padding of error text and hint text separately in TextFormField? Flutter中有什么方法可以分别控制TextFormField中错误文本和提示文本的填充? if not how can we make a custom and separate error text widget below TextFormField.如果不是,我们如何在 TextFormField 下方制作自定义和单独的错误文本小部件。

Try this if could be help for you试试这个如果对你有帮助

class CustomTextFormFiled extends StatefulWidget {
  const CustomTextFormFiled({Key key}) : super(key: key);

  @override
  _CustomTextFormFiledState createState() => _CustomTextFormFiledState();
}

class _CustomTextFormFiledState extends State<CustomTextFormFiled> {

  bool isError = false;
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        TextFormField(
          onSaved: (value){
            
            if(value.isEmpty){
              isError=true;
              
            }
    },
          
          
        ),
        if(isError)...{
          const Padding(
            padding: EdgeInsets.all(10),
            child: Text("Error Details"),
          )
        }
      ],
    );
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM