Flutter中如何给Divider添加渐变颜色

Eli*_*san 5 dart flutter

我有一个带有纯色的分隔器小部件,但我想将其设置为渐变颜色。有没有办法做到这一点?

Divider(
    height: 20,
    thickness: 2.5,
    indent: 0,
    endIndent: 100,
)
Run Code Online (Sandbox Code Playgroud)

C4s*_*s4r 6

只需使用Container()[BoxDecoration][1] 来创建渐变。

SizedBox(
  width: 200,
  height: 4,
  child: Container(
    decoration: BoxDecoration(
      gradient: //...
    ),
  ),
),
Run Code Online (Sandbox Code Playgroud)

预定义的分隔线很好,但在定制方面并不强大。[1]:https://api.flutter.dev/flutter/painting/BoxDecoration-class.html