flutter 如何给予自定义分隔符在容器?

sgtfey8w  于 2022-12-05  发布在  Flutter
关注(0)|答案(4)|浏览(107)

我需要给予这个除法器,但我不知道如何编码它。

我试过了,但我不知道怎么把薄的变成厚的。

2w3kk1z5

2w3kk1z51#

您可以使用flutter小部件

Container(
        child: Column(children: [
          Text('Title'),
          Divider(thickness: 5,color: Colors.black,),
          Text('Description'),
        ],),
e4eetjau

e4eetjau2#

使用带渐变的容器而不是分隔线。

Container(
 height: 2,
 width: 100,
 decoration: BoxDecoration(
      gradient: LinearGradient(
            begin: Alignment.centerLeft,
            end: Alignment.centerRight,
            colors: <Color>[
              Color.green.withOpacity(0.1),
              Color.green,
              Color.green.withOpacity(0.1),
            ], 
          ),
        ),
    ),

这仅适用于具有该效果分隔符对于上面和下面内容,您可以使用列小部件

Column (
 children: [
  widget1,
  divider,
  widget2,
 ]
)

根据需要更改高度、宽度、颜色和不透明度

kr98yfug

kr98yfug3#

这是您应该用来解决问题

Divider(thickness: 2,color:Colors.grey)
avwztpqn

avwztpqn4#

你可以使用渐变容器代替分隔器。就像这样:

SizedBox(
  width: 200,
  height: 4,
 child: Container(
      decoration: BoxDecoration(
        gradient: LinearGradient(
          begin: Alignment.topRight,
          end: Alignment.bottomLeft,
          colors: [
            Colors.blue,
            Colors.red,
          ],
        )
      ),
  ),
),

相关问题