【问题标题】:Gradient with effect of 3d Container in FlutterFlutter 中具有 3d 容器效果的渐变
【发布时间】:2019-09-28 16:06:49
【问题描述】:

如何将容器装饰成这样的效果。我尝试使用渐变,但我不知道如何制作图片中的水平渐变。 非常感谢任何帮助或资源。

【问题讨论】:

    标签: flutter flutter-layout


    【解决方案1】:

    试试这个:

    Container(
            height: 100,
            decoration: BoxDecoration(
              gradient: LinearGradient(
                colors: [
                  Colors.black,
                  Colors.purple,
                  Colors.blue,
                  Colors.green,
                  Colors.brown,
                ],
                begin: Alignment.topCenter,
                end: Alignment.bottomCenter,
                stops: [0.01, 0.3, 0.4, 0.8, 1],
              ),
            ),
          )
    

    您已经有了颜色,您必须创建 stops,这在我的示例中是不言自明的,并且必须与颜色具有相同的长度。

    如果要使其水平,请调整 beginend 参数。

    【讨论】:

      猜你喜欢
      • 2021-08-09
      • 1970-01-01
      • 1970-01-01
      • 2022-01-25
      • 2021-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-29
      相关资源
      最近更新 更多