首页 > 解决方案 > Flutter 项目不接受 BoxDecoration 颜色

问题描述

我是 Flutter 的新手,我对参数有疑问。

我从教程中获得了以下代码:

Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
          gradient: LinearGradient(
              colors: [const Color(0xff3C8CE7), const Color(0xff00EAFF)])),

该项目在两个平台上都运行良好,但有一条警告:

colors: [const Color(0xff3C8CE7), const Color(0xff00EAFF)])),

这是 Dart Analysis 调试窗口中的警告输出:

在此处输入图像描述

我已经搜索了 BoxDecoration 和渐变颜色的正确实现,它说明了我正在这样做的方式。

代码有什么问题?

标签: flutter

解决方案


请确保您使用的是颤振的stablebeta通道。为此,请运行以下命令:

  1. flutter channel stable
  2. flutter upgrade
  3. flutter clean

重新启动 IDE 并尝试再次运行。


推荐阅读