【问题标题】:How do I add a gradient background in my flutter app?如何在我的 Flutter 应用中添加渐变背景?
【发布时间】:2021-02-27 19:58:15
【问题描述】:

我想要在我的 Flutter 应用背景中使用 Liner 渐变颜色样式,如何在我的 Flutter 应用中实现它?

【问题讨论】:

    标签: flutter user-interface dart background flutter-layout


    【解决方案1】:

    你可以简单地在BoxDecoration中使用正确的参数

    https://api.flutter.dev/flutter/painting/LinearGradient-class.html

    Container(
          decoration: BoxDecoration(
            gradient: LinearGradient(
              begin: Alignment.topLeft,
              end:
                  Alignment(0.8, 0.0), // 10% of the width, so there are ten blinds.
              colors: [
                const Color(0xffee0000),
                const Color(0xffeeee00)
              ], // red to yellow
              tileMode: TileMode.repeated, // repeats the gradient over the canvas
            ),
          ),
        );
    

    【讨论】:

      猜你喜欢
      • 2020-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多