如何在Flutter中为分割线添加渐变颜色

5
我有一个实心颜色的分隔线小部件,但我想将其设置为渐变颜色。 有什么方法可以做到这一点吗?
Divider(
    height: 20,
    thickness: 2.5,
    indent: 0,
    endIndent: 100,
)
2个回答

6

1
在数字 4 后面缺少逗号,无法编辑它,因为对帖子的编辑必须是 6 个或更多字符。 - David Chopin

0

如果您希望使用与官方Divider完全相同的参数,但又想要渐变和圆角这些讨厌的正方形边缘,您可以使用这个ds是我的DividerStyle包含的参数:

    return SizedBox(
    height: ds.heigth,
    child: Center(
      child: Container(
        height: ds.thickness,
        margin: EdgeInsetsDirectional.only(start: ds.indent, end: ds.endIndent),
        decoration: BoxDecoration(
          color: ds.color.getColor(),
          gradient: ds.color.getGradient(),
          borderRadius: ds.roundEdge
              ? BorderRadius.all(Radius.circular(ds.thickness))
              : null,
          border: Border.all(color: Colors.transparent, width: 1),
        ),
      ),
    ),
  );

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接