使用 Flutter New Gradient App Bar 包时出现错误

问题描述 投票:0回答:1

我想使用下面的代码在我的应用程序上使用新渐变应用程序栏包text。我之前在以前版本的 flutter 上使用过这段代码,没有任何问题。

      appBar: PreferredSize(
        preferredSize: const Size(85,85), // here the desired height
        child: NewGradientAppBar(
          title: const Text(
            'Project',
            style: TextStyle(
              fontStyle: FontStyle.italic,
              letterSpacing: 0.1,
              fontWeight: FontWeight.w800,
              fontFamily: 'Roboto',
              height: 1.3,
              fontSize: 50,
            ),
            textAlign: TextAlign.center,
          ),
          gradient: LinearGradient(colors: [Colors.teal.shade300, Colors.teal, Colors.teal.shade800]),

但是当我运行下面的项目时,我在控制台上收到错误。

运行 Gradle 任务“assembleDebug”... ../../AppData/Local/Pub/Cache/hosted/pub.dev/new_gradient_app_bar-0.2.0/lib/new_gradient_app_bar.dart:422:21:错误:没有为该类定义 getter 'textTheme' “应用栏主题”。

“AppBarTheme”来自“package:flutter/src/material/app_bar_theme.dart”(“/C:/flutter/packages/flutter/lib/src/material/app_bar_theme.dart”)。 尝试将名称更正为现有 getter 的名称,或定义名为“textTheme”的 getter 或字段。 appBarTheme.textTheme?.headline6 ?? ^^^^^^^^^ ../../AppData/Local/Pub/Cache/hosted/pub.dev/new_gradient_app_bar-0.2.0/lib/new_gradient_app_bar.dart:425:21:错误:没有为该类定义 getter 'textTheme' “应用栏主题”。

“AppBarTheme”来自“package:flutter/src/material/app_bar_theme.dart”(“/C:/flutter/packages/flutter/lib/src/material/app_bar_theme.dart”)。 尝试将名称更正为现有 getter 的名称,或定义名为“textTheme”的 getter 或字段。 appBarTheme.textTheme?.bodyText2 ?? ^^^^^^^^^ ../../AppData/Local/Pub/Cache/hosted/pub.dev/new_gradient_app_bar-0.2.0/lib/new_gradient_app_bar.dart:580:21:错误:没有为该类定义吸气剂“亮度” “应用栏主题”。

“AppBarTheme”来自“package:flutter/src/material/app_bar_theme.dart”(“/C:/flutter/packages/flutter/lib/src/material/app_bar_theme.dart”)。 尝试将名称更正为现有 getter 的名称,或定义名为“brightness”的 getter 或字段。 appBarTheme.brightness ?? ^^^^^^^^^^ ../../AppData/Local/Pub/Cache/hosted/pub.dev/new_gradient_app_bar-0.2.0/lib/new_gradient_app_bar.dart:581:19:错误:没有为该类定义 getter 'primaryColorBrightness' “主题数据”。

“ThemeData”来自“package:flutter/src/material/theme_data.dart”(“/C:/flutter/packages/flutter/lib/src/material/theme_data.dart”)。 尝试将名称更正为现有 getter 的名称,或定义名为“primaryColorBrightness”的 getter 或字段。 themeData.primaryColorBrightness; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../AppData/Local/Pub/Cache/hosted/pub.dev/new_gradient_app_bar-0.2.0/lib/new_gradient_app_bar.dart:591:32:错误:没有为该类定义吸气剂“颜色” “应用栏主题”。

“AppBarTheme”来自“package:flutter/src/material/app_bar_theme.dart”(“/C:/flutter/packages/flutter/lib/src/material/app_bar_theme.dart”)。 尝试将名称更正为现有 getter 的名称,或定义名为“color”的 getter 或字段。 颜色:appBarTheme.color ?? themeData.primaryColor, ^^^^^ 目标 kernel_snapshot 失败:异常

失败:构建失败并出现异常。

出了什么问题: 任务“:app:compileFlutterBuildDebug”执行失败。

处理'命令'C:lutter.bat中的lutter''以非零退出值1完成

尝试:

使用 --stacktrace 选项运行以获取堆栈跟踪。 使用 --info 或 --debug 选项运行以获得更多日志输出。 使用 --scan 运行以获得完整的见解。

我尝试

Pub get
Pub Upgrade
希望这是一个依赖项问题,但错误仍然不存在。

android flutter gradient
1个回答
0
投票

此包不再维护。然而,由于它是 UI,只有你自己可以拿一个叉子并纠正它。

但是已经有一个存储库已经完成了此操作,您可以参考它。 https://github.com/GUIKAR741/NewGradientAppBar

使用

  new_gradient_app_bar:
    git: https://github.com/GUIKAR741/NewGradientAppBar.git
© www.soinside.com 2019 - 2024. All rights reserved.