pubspec.yaml

name: flutter_combat
description: A Flutter combat application. # The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1 environment:
sdk: ">=2.1.0 <3.0.0" dependencies:
flutter:
sdk: flutter # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
english_words: ^3.1.5 dev_dependencies:
flutter_test:
sdk: flutter # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter.
flutter: # The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true # To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware. # For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages # To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages

解读

  1. name:应用或包名称。
  2. description: 应用或包的描述、简介。
  3. version:应用或包的版本号。
  4. dependencies:应用或包依赖的其它包或插件。
  5. dev_dependencies:开发环境依赖的工具包(而不是flutter应用本身依赖的包)。
  6. flutter:flutter相关的配置选项。

使用

import 'package:english_words/english_words.dart';
import 'package:flutter/material.dart'; class RandomWordsWidget extends StatelessWidget {
Widget build(BuildContext context) {
// 生成随机字符串
final wordPair = WordPair.random();
return Padding(
padding: const EdgeInsets.all(8.0),
child: Text(wordPair.toString()),
);
}
}

其他依赖方法

除了可以依赖Pub仓库,还可以依赖本地包和git仓库。

  1. 依赖本地包
如果我们正在本地开发一个包,包名为pkg1,我们可以通过下面方式依赖:
dependencies:
pkg1:
path: ../../code/pkg1
路径可以是相对的,也可以是绝对的。
  1. 依赖Git
也可以依赖存储在Git仓库中的包。如果软件包位于仓库的根目录中,请使用以下语法
dependencies:
pkg1:
git:
url: git://github.com/xxx/pkg1.git
上面假定包位于Git存储库的根目录中。如果不是这种情况,可以使用path参数指定相对位置,例如:
dependencies:
package1:
git:
url: git://github.com/flutter/packages.git
path: packages/package1

Flutter 应用入门:包管理的更多相关文章

  1. VS2013中Nuget程序包管理器控制台使用入门(三)-项目实战(原创)

    VS2013中Nuget程序包管理器控制台使用入门(三)-项目实战 1.给指定项目安装Newtonsoft.Json ,Version 4.5.11 PM> Install-Package Ne ...

  2. Linux 入门记录:二十、Linux 包管理工具 YUM

    一.YUM(Yellowdog Updater, Modified) 1. YUM 简介 RPM 软件包形式管理软件虽然方便,但是需要手动解决软件包的依赖问题.很多时候安装一个软件首先需要安装 1 个 ...

  3. Flutter 应用入门:路由管理

    路由(Route)在移动开发中通常指页面(Page),这跟web开发中单页应用的Route概念意义是相同的,Route在Android中通常指一个Activity,在iOS中指一个ViewContro ...

  4. c++ cmake及包管理工具conan简单入门

    cmake是一个跨平台的c/c++工程管理工具,可以通过cmake轻松管理我们的项目 conan是一个包管理工具,能够自动帮助我们下载及管理依赖,可以配合cmake使用 这是一个入门教程,想深入了解的 ...

  5. Node.js包管理器Yarn的入门介绍与安装

    FAST, RELIABLE, AND SECURE DEPENDENCY MANAGEMENT. 就在昨天, Facebook 发布了新的 node.js 包管理器 Yarn 用以替代 npm .咱 ...

  6. NodeJS包管理工具——npm入门

    如今每个语言体系中都有一个包管理工具,PHP的Composer,Ruby的gem,Python的pip,Java的Maven……当然还有Node.js的npm.有的人会奇怪为何要引入又一个新东西来让我 ...

  7. Maven入门-依赖管理(Jar包管理)(二)

    1       依赖管理(Jar包管理) 1.添加依赖  

  8. VS2013中Nuget程序包管理器控制台使用入门(二)-如何使用Nuget提供的帮助(原创)

    如何使用Nuget提供的帮助? 1.从get-help Nuget开始,键入“get-help NuGet”以查看所有可用的 NuGet 命令. 用法: PM> get-help Nuget 主 ...

  9. VS2013中Nuget程序包管理器控制台使用入门(一)-准备环境(原创)

    准备环境: 1.打开VS2013IDE集成开发环境. 2.新建一个Asp.net Mvc的项目,比如命名为:MvcApplication1 3.打开 菜单"工具"->&quo ...

  10. Anaconda 包管理工具 conda 进行虚拟环境管理入门

    在基于 python 进行数据分析.机器学习等领域的实践和学习时,由于代码的更迭和更新,运行他人实现的代码或尝试安装新的工具库时往往需要指定特定版本的其他工具库,以满足特定环境的构建条件.而将同一工具 ...

随机推荐

  1. 数据库查询优化-20条必备sql优化技巧

    0.序言 本文我们来谈谈项目中常用的 20 条 MySQL 优化方法,效率至少提高 3倍! 具体如下: 1.使⽤ EXPLAIN 分析 SQL 语句是否合理 使⽤ EXPLAIN 判断 SQL 语句是 ...

  2. uniapp计算属性的使用

    计算属性,也可称为动态属性,在uniapp中有两种写法: 第一种:直接返回一个计算的值,该计算属性为函数类型 computed:{ kh_score(){ var list = this.taskLi ...

  3. Python 学习笔记 之 03 - 函数总结

    函数总结    最基本的一种代码抽象的方式.    定义函数    使用def语句进行定义, return进行函数返回.    一旦执行导return,函数就执行完毕.    即使函数未指定retur ...

  4. Java基础数据类型详解

    在Java中的数据类型一共有8种,大致分为整型(4个)浮点型(2个)布尔(1)字符(1个) 分类 类型 默认值 占用字节 范围 整型 byte 0 1 = 8 bit -2^7 - 2^7 short ...

  5. Spring Cloud Alibaba (一): SpringCloud与SpringBoot版本选型

    前言   近年SpringCloud与SpringBoot更新迭代非常频繁,导致我们对两者的版本选型非常的困难.若是版本选择有问题, 会导致开发中调试兼容性占用非常多的得必要时间. SpringClo ...

  6. Spring Data JPA的基本学习之了解

    Spring Data JPA 是 什 么 可以理解为JPA规范的再次封装抽象,底层还是使用了Hibernate的JPA技术实现,引用JPQL(Java Persistence Query Langu ...

  7. Web服务器-HTTP相关-快速整一个服务器响应浏览器(3.2.1)

    @ 目录 1.HTTP分析 2.简单服务器 关于作者 1.HTTP分析 当你去访问一个网址的时候,浏览器会发送而各种头信息给服务器 然后服务器根据信息,返回一定数据的格式 最简单的就是下面的代码 自己 ...

  8. DRF比Django的认证和权限高在哪里

    Django可以用LoginRequiredMixin和PermissionRequiredMixin给类视图添加认证和权限,DRF做了高级封装,提供了更简洁的实现方式.我们通过继续学习官网教程来进行 ...

  9. Redis 6.0 多线程性能测试结果及分析

      单线程的Redis一向以简洁高效著称,但也有其阿喀琉斯之踵:阻塞!单个线程在最容易产生瓶颈的网络读写(Redis大key)请求完成之前,其他所有请求都将会被阻塞,严重影响其效率,因此Redis的多 ...

  10. 3.自定义view-TextView变色

    1.效果 2.实现原理 自定义Textview,重写onDraw方法,将画布分成两部分,用不同颜色的画笔画 核心代码: @Override protected void onDraw(Canvas c ...