简体   繁体   中英

How do I add a gradient background in my flutter app?

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

You can simply use the right parameter in 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
        ),
      ),
    );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM