在 flutter web 中添加依赖

add dependecies in flutter web

当我尝试在 flutter web 中的 pubspec.yaml 文件中添加依赖项时,我在尝试 pub get 命令时遇到错误:

[retgoo_internal] pub get
Resolving dependencies...
Because every version of aiframework depends on flutter any from sdk which is forbidden, aiframework is forbidden.
So, because retgoo_internal depends on aiframework ^1.0.7+12, version solving failed.

Flutter users should run `flutter packages get` instead of `pub get`.

和我的pubspec.yaml

name: retgoo_internal
description: An app built using Flutter for web

environment:
  # You must be using Flutter >=1.5.0 or Dart >=2.3.0
  sdk: '>=2.3.0 <3.0.0'

dependencies:
  aiframework: ^1.0.7+12
  flutter_web: any
  flutter_web_ui: any
  http: any

dev_dependencies:
  build_runner: ^1.4.0
  build_web_compilers: ^2.0.0
  pedantic: ^1.0.0

dependency_overrides:
  flutter_web:
    git:
      url: https://github.com/flutter/flutter_web
      path: packages/flutter_web
  flutter_web_ui:
    git:
      url: https://github.com/flutter/flutter_web
      path: packages/flutter_web_ui

尝试将依赖项更改为:

dependencies:
  aiframework: ^1.0.7+12
  flutter_web:
  flutter_web_ui:
  http:

在 flutter web 中还不支持它,就像一些包一样,但解决这个问题的唯一方法是从 github 中获取包的源代码,在包中的 lib 文件中获取代码,然后将其放入您的项目中通过更改路径导入来修复文件内部可能发生的错误:import 'package:flutter_web/material.dart';并且可能需要进行更多更改。

它 100% 有效而且非常简单:)