简体   繁体   中英

Flutter - Linear Gradient not taking colors as a array of colors

I was actually preparing a login screen and decided to use a linear gradient as a background. I actually upgraded my Flutter SDK from 1.20 to 1.22 in the stable channel. Please click on the below links to check the problem

The code

The error shown

Show what should I do.

Thank you.

在命令行中使用flutter cleanflutter pub cache repair ,然后重新启动ide

you can try this one probably there could be some version mismatch.


Container(
        decoration: BoxDecoration(
            gradient: LinearGradient(
              begin: Alignment.topRight,
              end: Alignment.bottomLeft,
              colors: [Colors.blue, Colors.red])),
        child: Center(
          child: Text(
            'Hello Gradient!',
            style: TextStyle(
              fontSize: 48.0,
              fontWeight: FontWeight.bold,
              color: Colors.white),
          ),
        ),
      )

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