如何降低文本表单字段的边界宽度?

发布于 2025-01-24 11:44:51 字数 1970 浏览 0 评论 0原文

”在此处输入图像说明“

我需要减少Textfield边界侧的宽度。我该怎么做?

final emailNameField = TextFormField(
      autofocus: false,
      controller: emailEditingController,
      keyboardType: TextInputType.emailAddress,
      validator: (email) => email != null && !EmailValidator.validate(email)
          ? "Enter a valid Email"
          : null,
      onSaved: (email) {
        emailEditingController.text = '$email';
      },
      textInputAction: TextInputAction.next,
      decoration: const InputDecoration(
          prefixIcon: Icon(Icons.mail),
          contentPadding: EdgeInsets.fromLTRB(20, 15, 20, 15),
          prefixIconColor: Colors.red,
          border: OutlineInputBorder(
              borderRadius: BorderRadius.only(),
              borderSide: BorderSide(width: 1)),
          hintText: 'Email '),
    );

    //password field
    final passwordNameField = TextFormField(
        autofocus: false,
        controller: passwordEditingController,
        obscureText: true,
        onSaved: (value) {
          passwordEditingController.text = 'value';
        },
        textInputAction: TextInputAction.done,
        decoration: const InputDecoration(
            prefixIcon: Icon(Icons.vpn_key),
            contentPadding: EdgeInsets.fromLTRB(200, 15, 20, 15),
            prefixIconColor: Colors.red,
            border: OutlineInputBorder(
                borderSide: const BorderSide(
                    width: 2, color: Color.fromARGB(26, 204, 32, 32))),
            hintText: 'Password ',
            suffixIcon: Icon(Icons.remove_red_eye_rounded)));

enter image description here

enter image description here

I need to reduce the width of my border side in TextField. How can I do that?

final emailNameField = TextFormField(
      autofocus: false,
      controller: emailEditingController,
      keyboardType: TextInputType.emailAddress,
      validator: (email) => email != null && !EmailValidator.validate(email)
          ? "Enter a valid Email"
          : null,
      onSaved: (email) {
        emailEditingController.text = '$email';
      },
      textInputAction: TextInputAction.next,
      decoration: const InputDecoration(
          prefixIcon: Icon(Icons.mail),
          contentPadding: EdgeInsets.fromLTRB(20, 15, 20, 15),
          prefixIconColor: Colors.red,
          border: OutlineInputBorder(
              borderRadius: BorderRadius.only(),
              borderSide: BorderSide(width: 1)),
          hintText: 'Email '),
    );

    //password field
    final passwordNameField = TextFormField(
        autofocus: false,
        controller: passwordEditingController,
        obscureText: true,
        onSaved: (value) {
          passwordEditingController.text = 'value';
        },
        textInputAction: TextInputAction.done,
        decoration: const InputDecoration(
            prefixIcon: Icon(Icons.vpn_key),
            contentPadding: EdgeInsets.fromLTRB(200, 15, 20, 15),
            prefixIconColor: Colors.red,
            border: OutlineInputBorder(
                borderSide: const BorderSide(
                    width: 2, color: Color.fromARGB(26, 204, 32, 32))),
            hintText: 'Password ',
            suffixIcon: Icon(Icons.remove_red_eye_rounded)));

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心安伴我暖 2025-01-31 11:44:51

您可以包装父card窗口小部件填充物,或者只需使用Margin外部间距的属性,然后用填充物包装column用填充物来提供内部间距。

Card(
  //for out side or wrap with padding widget
  margin: const EdgeInsets.all(8.0), 
  color: Colors.cyanAccent,

  // for inner spaciing
  child: Padding(
    // replace 16 with your desire padding value
    // padding: const EdgeInsets.all(16.0),
    padding:
        EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 16),
    child: Column(
      children: [
        TextField(),
        //...
      ],
    ),
  ),
)

有关 card> card

You can wrap parent Card widget padding or just use margin property for outside spacing, and wrap Column widget with padding to provide inner spacing.

Card(
  //for out side or wrap with padding widget
  margin: const EdgeInsets.all(8.0), 
  color: Colors.cyanAccent,

  // for inner spaciing
  child: Padding(
    // replace 16 with your desire padding value
    // padding: const EdgeInsets.all(16.0),
    padding:
        EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 16),
    child: Column(
      children: [
        TextField(),
        //...
      ],
    ),
  ),
)

More about Padding and Card.

凉薄对峙 2025-01-31 11:44:51

您可以通过装饰属性来实现这一目标,这是一个示例。
请注意,您可以使用多种类型的边界样式。

You can achieve that through decoration property, here is a sample.
Pay attention that there is more than one type of borders styling you can apply.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文