如何在颤振中绘制动态高度线?

时间:2021-07-05 11:51:20

标签: flutter dart flutter-layout

我想画一条动态高度线,如下图所示 as shown here, grey line

我使用带有一侧边框的容器做了一些事情

Container(
child:(content goes here....)
  margin: EdgeInsets.symmetric(horizontal:16+20.0),
   decoration: BoxDecoration(
          border: Border(
            left: BorderSide(width: 2.0, color: Colors.lightBlue.shade600),

                      ),
          color: Colors.white,
        ),
)

但问题是线的角(顶部和下方)没有圆角。
我想在帖子的左边画一条竖线,右边是内容。

1 个答案:

答案 0 :(得分:4)

你可以尝试这样的事情:

IntrinsicHeight(
  child: Row(
    children: [
      Container(
        width: 5,
        decoration: ShapeDecoration(
          shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)),
          color: const Color(0x7f9e9e9e),
        ),
      ),
      Expanded(child: **content goes here**),
    ],
  ),
)

这里有一个 DartPad 示例:Example

这会产生这样的结果:

enter image description here

左侧的栏将根据右侧的内容自动调整大小。