当前位置:网站首页>Dart series: metaworld pubspec Yaml file details

Dart series: metaworld pubspec Yaml file details

2022-06-24 01:20:00 Procedural stuff

brief introduction

pubspec.yaml It's all dart The soul of the project , It contains all dart Project dependency information and other meta information , therefore pubspec.yaml Namely dart Project meta!

pubspec.yaml Supported fields

according to dart The definition of ,pubspec.yaml You can include the following fields :

Field name

Is a field required

describe

name

yes

package Name

version

If released to pub.dev, You need to

package Version number of

description

If released to pub.dev, You need to

package Description information of

homepage

no

package The home page of

repository

no

package Source code address of

issue_tracker

no

package Problem tracking address

documentation

no

package Documentation information for

dependencies

no

package Of information

dev_dependencies

no

pacakge Of dev Dependent information

dependency_overrides

no

What do you want to cover package

environment

dart2 need

executables

no

package The executable path of

publish_to

no

package How to publish

Be careful , Above is dart in pubspec.yaml Supported fields , If it's in flutter Environment , There will be some additional supported fields .

# An example

Let's take a concrete example :

 name: my_app
version: 11.15
description: >-
  this is a new app
homepage: http://www.flydean.com
documentation: http://www.flydean.com
environment:
  sdk: '>=2.10.0 <3.0.0'
dependencies:
  efts: ^2.0.4
  transmogrify: ^0.4.0
dev_dependencies:
  test: '>=1.15.0 <2.0.0'

Field details

Let's take a look at the details and restrictions of each field :

  1. Name

name Indicates the name of the package ,name It must be all lowercase , If there are more than one word , Underline can be used to distinguish , Such as :my_app.

And can only use a combination of lowercase letters and numbers , And it can't start with a number , And don't use dart Reserved word in .

  1. Version

Version It means the version number , The version number is three numbers separated by dots , Such as :11.15.0. You can keep up with build Version number :+1, +2, +hotfix.oopsie, Or pre release version, etc :-dev.4, -alpha.12, -beta.7, -rc.5.

  1. Description

package It is best to use English to describe , The length is 60 To 180 Characters , Indicates the function of this package .

  1. Dependencies

There are two kinds of dependent information , One is that all use this packages All people need to rely on , This dependence is placed on dependencies in .

Another is only used in the current pacakge Package under development , This dependence is placed on dev_dependencies in .

In some cases , We may need to override some dependent packages , Can be placed in :dependency_overrides in .

  1. Executables

There are some pacakges Tools are provided for everyone to use , These tools may be command line tools , So you need to be in executables Specifies the path of the command that can be executed .

For example, the following configuration :

executables:
  slidy: main
  fvm:

Then in execution pub global activate after , You can execute... Globally slidy To execute bin/main.dart, and fvm To execute binfvm.dart.

  1. environment

because Dart It's a new language , So at present, the change is still very big . So some applications can depend on different dart edition , And that's where it comes in environment:

environment:
  sdk: '>=2.10.0 <3.0.0'

In the above code , We have designated dart sdk Version range of .

from dart1.19 after ,environment: Specifying... Is also supported in flutter Version of :

environment:
  sdk: '>=1.19.0 <3.0.0'
  flutter: ^0.1.2

summary

That's all dart Meta world of pubspec.yaml Detailed explanation .

This article has been included in http://www.flydean.com/10-dart-pubspec/

原网站

版权声明
本文为[Procedural stuff]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/11/20211119083252182Y.html

随机推荐