颤振平滑的颜色过渡容器

时间:2020-09-04 06:18:08

标签: flutter dart colors transition

如何说出带有阴影的容器(如所附图片)?

我不只是使用图像,因为要对其进行微小的更改会更加困难,并且颜色有时需要是整个屏幕的宽度,也许我要对其进行动画处理。 / p>

https://i.stack.imgur.com/2QzXC.jpg

2 个答案:

答案 0 :(得分:3)

class Gradiant extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        decoration: new BoxDecoration(
          gradient: new LinearGradient(
              colors: [Colors.blue[800], Colors.purple, Colors.red],
              begin: Alignment.bottomCenter,
              end: Alignment.topCenter,
              stops: [0.2, 0.6, 1]),
        ),
      ),
    );
  }
}

答案 1 :(得分:1)

您可以使用gradient的{​​{1}}属性来获取所需的内容。

我添加了一个演示:

BoxDecoration

结果:

result