标签: pubspec

pub get failed :包可能不会将自身列为依赖项

我在pubspec.yaml中遇到此问题:

\n

这里是pubspec.yaml

\n
 dependencies:\n  flutter:\n    sdk: flutter\n  cupertino_icons: ^1.0.2\n  pluto_grid: ^2.9.3\n
Run Code Online (Sandbox Code Playgroud)\n

这是错误:

\n
[pluto_grid] flutter pub get\nRunning "flutter pub get" in pluto_grid...                      \nError on line 37, column 3 of pubspec.yaml: A package may not list itself as a dependency.\n   \xe2\x95\xb7\n37 \xe2\x94\x82   pluto_grid: ^2.9.3\n   \xe2\x94\x82   ^^^^^^^^^^\n   \xe2\x95\xb5\npub get failed (65;    \xe2\x95\xb5)\nexit code 65\n
Run Code Online (Sandbox Code Playgroud)\n

需要知道出了什么问题,在其他项目中使用了相同的并且工作完美。

\n

grid dart flutter flutter-dependencies pubspec

15
推荐指数
2
解决办法
2万
查看次数

如何在 Flutter 中引用存储库中的包?

我正在尝试修改 pub.dev 上的现有包。我需要更新包中的依赖项之一。我已经从这里看到了如何做到这一点

dependencies:
  flutter:
    sdk: flutter
  graphql_flutter:
    git:
      url: https://github.com/username/graphql-flutter.git
Run Code Online (Sandbox Code Playgroud)

当我跑步时flutter pub get
我得到pub get failed (1; Could not find a file named "pubspec.yaml"

查看存储库

pubspec.yaml根里没有

我想我需要引用pubspec.yaml包文件夹中的?那里有 2 个...不知道该怎么做?

该包是graphql_flutter

git package flutter pubspec

10
推荐指数
1
解决办法
4637
查看次数

如何在 Android Studio Quick Fix 菜单中获取 AppLocalizations 导入建议

问题陈述

目前,在 AppLocalizations 上调出 Android Studio 快速修复菜单(Opt/Alt+Enter 键盘快捷键)并不建议导入生成的文件。

AppLocalizations 类位于.dart_tool/flutter_gen/gen_l10n/app_localizations.dart,这也是一个 Git 忽略的目录。

结果我必须手动输入导入语句。其他 Flutter 类名称通常建议通过“快速修复”菜单导入相关文件。

预期是什么

我期待“快速修复”菜单建议导入生成的 AppLocalizations 文件。当我单击导入建议时,它应该将其与其他导入语句一起插入到文件顶部。

问题

如何让导入建议出现在 AppLocalizations 的“快速修复”菜单中?我是否需要帮助 Dart 分析器“了解”目录中生成的文件.dart_tool?我可以将生成的文件包含在我的“项目”中,同时仍然 Git 忽略它吗?我是否需要在我的 pubspec 文件中链接到它?

“快速修复”菜单缺少导入建议的屏幕截图

“快速修复”菜单的屏幕截图不建议使用 AppLocalizations 导入

android-studio dart-analyzer flutter pubspec flutter-localizations

10
推荐指数
1
解决办法
1169
查看次数

与多个本地 flutter 和 dart 包共享 pubspec.yaml 包依赖项版本

我的 flutter 项目依赖于几个本地 flutter 和 dart 包来保持分离和干净。\n我的文件夹结构如下:

\n
main-flutter-project\n\xe2\x94\x82  lib\n|  test\n\xe2\x94\x82  pubspec.yaml\n\xe2\x94\x82\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 local-packages\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 dart-package-1\n\xe2\x94\x82   \xe2\x94\x82     pubspec.yaml\n\xe2\x94\x82   \xe2\x94\x82\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 flutter-package-1\n\xe2\x94\x82   \xe2\x94\x82     pubspec.yaml\n\xe2\x94\x82   \xe2\x94\x82\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 flutter-package-2\n\xe2\x94\x82         pubspec.yaml\n...\n
Run Code Online (Sandbox Code Playgroud)\n

每个本地包都是独立的,可以在不接触主项目的情况下进行维护。

\n

这种结构意味着我有很多pubspec.yaml文件,我必须在其中保持依赖项的更新。\n当我在 5 个包中使用 libaray 时bloc,当新版本发布时,bloc: ^7.2.1我必须分别更新每个文件中的版本。pubspec

\n

是否可以仅在其他pubspec.yaml文件引用的一个位置指定这些共享包依赖项版本?

\n

我已经在 Maven 中看到了这一点,您可以在其中指定一个属性<junit.version>4.12</junit.version>并从其他地方访问它<version>${junit.version}</version>

\n

dependency-management dart flutter pubspec

9
推荐指数
1
解决办法
2205
查看次数

Flutter flutter_launcher_icons 错误:pub 已完成,退出代码为 255

我想为 flutter 创建启动器图标。我的配置(pubspec.yaml)如下所示。

\n
...\n  # The following adds the Cupertino Icons font to your application.\n  # Use with the CupertinoIcons class for iOS style icons.\n  cupertino_icons: ^1.0.2\n  flutter_spinkit: ^5.1.0\n  url_launcher: ^6.0.17\n  http: ^0.13.4\n  intl: ^0.17.0\n  flutter_launcher_icons: ^0.9.2\n\nflutter_icons:\n  android: true\n  ios: true\n  image_path: "assets/logo_blue.png"\n...\n
Run Code Online (Sandbox Code Playgroud)\n

我通过控制台安装了 flutter_launcher_icon ( flutter pub add flutter_launcher_icons)。之后,我将配置(见上文)添加到 pubspec.yaml 文件中,并在控制台中输入以下两个命令:

\n
flutter pub get\nflutter pub run flutter_launcher_icons:main\n
Run Code Online (Sandbox Code Playgroud)\n

如文档中所述(https://pub.dev/packages/flutter_launcher_icons)。但在第二个命令之后,我收到以下错误消息,并且 pub 已完成,退出代码为 255。

\n
  \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\n     FLUTTER LAUNCHER ICONS (v0.9.1)\n  \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\n\n\n\xe2\x9c\x93 Successfully generated launcher icons\nUnhandled …
Run Code Online (Sandbox Code Playgroud)

dart dart-pub flutter flutter-dependencies pubspec

8
推荐指数
3
解决办法
1万
查看次数

FlutterActivity 与 FlutterFragmentActivity

我试图将local_auth包实现到我的 Flutter 应用程序中。

在文档中,提到它必须在我的 MainActivity 类中使​​用FlutterFragmentActivity而不是使用。FlutterActivity

所以我想知道什么是主要的differences between FlutterFragmentActivity以及FlutterActivity两者如何影响应用程序performance

:) 因为我不想在生产中进行更改并破坏应用程序。

authentication android flutter flutter-dependencies pubspec

8
推荐指数
1
解决办法
3770
查看次数

我可以在 pubspec.yaml 中使用环境变量吗?

我的 Flutter 移动应用项目中有来自 GitLab 的私有依赖项。它是在 git 存储库链接中指定的,如果我使用 ssh,pubspec.yaml我可以成功运行(我已经生成了 ssh 密钥并将其添加到我的 gitlab 帐户)pub get

  my_private_package:
    git:
      url: ssh://git@************/my_private_package.git
Run Code Online (Sandbox Code Playgroud)

现在我想使用 AppCenter 构建我的应用程序并部署到商店。在 AppCenter 构建阶段不可能使用 ssh 密钥,因此我看到的唯一可行的解​​决方案是使用GitLab 部署令牌作为环境变量来从 AppCenter 计算机访问我的私有包。访问存储库的 Git 链接变为:

  my_private_package:
    git:
      url: https://gitlab+deploy-token-1:${DEPLOY_TOKEN}@************/my_private_package.git
Run Code Online (Sandbox Code Playgroud)

现在,据我了解, pubspec 无法以DEPLOY_TOKEN这种方式解析环境变量。pub get完成时出现错误:

Git error. Command: `git clone --mirror https://gitlab+deploy-token-1:******@*******/my_private_package.git /Users/***/Library/flutter/.pub-cache/git/cache/my_private_package***`
stdout:                                                                 
stderr: Cloning into bare repository '/Users/***/Library/flutter/.pub-cache/git/cache/my_private_package***'...
remote: HTTP Basic: Access denied                                       
remote: You must use a personal access token with 'read_repository' or 'write_repository' scope for …
Run Code Online (Sandbox Code Playgroud)

continuous-integration environment-variables dart flutter pubspec

7
推荐指数
1
解决办法
2026
查看次数

如何在flutter中构建应用程序储物柜应用程序

我想创建一个允许锁定设备中其他应用程序的应用程序。它就像育儿控制应用程序。如果父母锁定设备中的某些应用程序。孩子不会访问或删除它。对于与应用程序的任何交互,它都会要求输入密码。是否可以在 flutter 中构建这样的应用程序。如果是这样,插件是什么?我只需要一个想法。

dart flutter flutter-dependencies pubspec

7
推荐指数
0
解决办法
795
查看次数

升级flutter后是否需要更新pubspec.yaml文件中的sdk版本?

升级flutter后是否需要更新pubspec.yaml文件中的sdk版本?在这种情况下,我需要将 <3.0.0 更改为 <3.1.0 吗?

\n

这是我当前的版本

\n
environment:\n  sdk: ">=2.12.0 <3.0.0"\n
Run Code Online (Sandbox Code Playgroud)\n
\n

Flutter 3.1.0-0.0.pre.1266 \xe2\x80\xa2 通道主控 \xe2\x80\xa2\n https://github.com/flutter/flutter.git框架 \xe2\x80\xa2 修订版 e1d9adf483\n (9 小时前) \xe2\x80\xa2 2022-06-15 21:56:04 -0700 Engine \xe2\x80\xa2 修订版 f8c0dc87bc\nTools \xe2\x80\xa2 Dart 2.18.0 (build 2.18.0- 189.0.dev)\xe2\x80\xa2 开发工具 2.14.0

\n
\n

flutter pubspec

7
推荐指数
2
解决办法
5789
查看次数

“资产不存在或数据为空”,但资产存在且有数据

我放入 pubspec.yaml 并运行 flutter pub get。我什至可以在内置文件资源管理器中查看 VS 代码上的文件,但它仍然给出相同的错误。

class OnloginScreen extends StatefulWidget {
  const OnloginScreen({super.key});

  @override
  State<OnloginScreen> createState() => _OnloginScreenState();
}

class _OnloginScreenState extends State<OnloginScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(children: [
        RiveAnimation.asset('assets\RiveAssets\shapes.riv'),
      ]),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

错误:

E/flutter ( 4055): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Unable to load asset: "assetsRiveAssetsshapes.riv".
E/flutter ( 4055): The asset does not exist or has empty data.
E/flutter ( 4055): #0      PlatformAssetBundle.load.<anonymous closure> (package:flutter/src/services/asset_bundle.dart:254:9)
E/flutter ( 4055): <asynchronous suspension>
E/flutter ( 4055): …
Run Code Online (Sandbox Code Playgroud)

dart flutter pubspec

7
推荐指数
1
解决办法
8076
查看次数