【问题标题】:How to add a library to flutter dependencies如何将库添加到颤振依赖项
【发布时间】:2020-01-26 05:29:41
【问题描述】:

我是flutter的新手,我想将Fast Android网络库添加到flutter依赖项中,但我不知道如何添加,请帮助我。

【问题讨论】:

  • 查看官方文档中的this
  • 你可以去 pubspec.yaml 文件并添加依赖项,在依赖项下,然后包获取将完成工作。或者你可以在终端运行flutter pub get。

标签: flutter


【解决方案1】:

在flutter依赖中添加一个包非常简单。您需要做的是将其放在 pubspec.yaml 文件内的dependencies: 下。

所以打开 pubspec.yaml。您将在 Flutter 应用程序的根项目文件夹中找到此文件。并执行以下操作以添加新的依赖项/库:

dependencies:
  flutter:
    sdk: flutter
  # dependencies come below here
  example_dependency: ^3.2.0+1 // at the end is the version of the depenency
  second_example_dependecy: any // 'any' for any version of the dependecy

要查找或发现新的 Flutter 和 dart 库以帮助您构建应用程序,您可以找到 Flutter 和 dart 包here

【讨论】:

    【解决方案2】:

    要将 http 包添加到您的 Flutter 项目中,在项目根目录的终端中,只需键入:

    flutter pub add http
    

    将使用最新的稳定版本。

    有关选项的信息,请查看https://dart.dev/tools/pub/cmd/pub-add

    【讨论】:

      猜你喜欢
      • 2022-01-14
      • 2020-05-03
      • 2021-02-25
      • 2021-12-26
      • 2016-06-03
      • 2016-08-23
      • 1970-01-01
      • 2013-12-06
      • 2015-07-27
      相关资源
      最近更新 更多