简体   繁体   English

Flutter - 线性渐变不将颜色作为颜色数组

[英]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.我实际上在稳定频道中将我的 Flutter SDK 从 1.20 升级到 1.22。 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),
          ),
        ),
      )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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