繁体   English   中英

在flutter中,如何添加一个看起来像带有下划线的文本字段的大纲按钮?

[英]In flutter, how to add an outline button that look like a text field with underline?

在flutter中,如何添加一个看起来像带有下划线的文本字段的大纲按钮? 我只需要一个底部下划线。

           OutlineButton(
              color: Theme.of(context).buttonColor,
              textColor: Theme.of(context).textTheme.bodyText1.color,
              // disabledColor: Colors.grey,
              disabledTextColor: Colors.black,
              borderSide: (),
              onPressed: () {

              },
          child: Center(
            child: Text(
              "No Reminder",
              textAlign: TextAlign.center,
              style: TextStyle(fontSize: 18.0),
            ),
          ),
            )
GestureDetector(
  onTap: () => print('tapped'),
  child: Container(
    // optional
    padding: const EdgeInsets.only(bottom: 1.0),
      decoration: BoxDecoration(
        border: Border(
          bottom: BorderSide(
            width: 2.0, color: Colors.lightBlue.shade900))),
    child: Text('button')),
)

我不知道结果会如何,但我希望它有助于给你想法来满足你的需要

您可以使用 BoxDecoration 作为按钮的父级。 OutlineButton 勾勒出所有 4 个边或没有。 在此处查看他们的文档https://api.flutter.dev/flutter/painting/BorderSide-class.html

如果我正确理解你的问题,你只需要添加文本的decoration属性并将TextDecoration.underline传递给它,以实现底部下划线。 下面的工作示例代码:

body: Center(
        child: OutlineButton(
              color: Theme.of(context).buttonColor,
              textColor: Theme.of(context).textTheme.bodyText1.color,
              // disabledColor: Colors.grey,
              disabledTextColor: Colors.black,
            //  borderSide: (),
              onPressed: () {

              },
          child: Center(
            child: Text(
              "No Reminder",
              textAlign: TextAlign.center,
              style: TextStyle(fontSize: 18.0, decoration: TextDecoration.underline),
            ),
          ),
            )
      ),

在此处输入图片说明

希望这能回答你的问题。

暂无
暂无

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

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