当前位置:网站首页>【Flutter 實戰】pubspec.yaml 配置檔案詳解
【Flutter 實戰】pubspec.yaml 配置檔案詳解
2020-11-06 01:23:28 【itread01】
 > **老孟導讀**:**pubspec.yaml** 檔案是 Flutter 中非常重要的配置檔案,下面就讓我們看看裡面各個配置的含義。 pubspec.yaml 是 Flutter 專案的配置檔案,類似於 Android 中的 Gradle 配置檔案,下面我們就看看 pubspec.yaml 中各個屬性的配置。 建立一個新的專案(Flutter Application),pubspec.yaml 位於根目錄,如圖:  專案中預設配置,去掉註釋部分,剩下如下: ```dart name: flutter_app description: A new Flutter application. publish_to: 'none' version: 1.0.0+1 environment: sdk: ">=2.7.0 <3.0.0" dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.0 dev_dependencies: flutter_test: sdk: flutter flutter: uses-material-design: true ``` 下面我們一個一個的詳細介紹下。 ### name 此屬性表示包名(package name),此屬性是非常重要的,引入其他檔案時需要使用此包名: ```dart import 'package:flutter_app/home_page.dart'; ``` 如果你修改包名為 ,那麼相應的引入也需要修改: ```dart import 'package:flutter_app_demo/home_page.dart'; ``` 如果你建立了一個 Flutter 外掛併發布到 [pub.dev](https://pub.dev/),那麼此屬性將會作為標題顯示,同時其他人引用也需要使用此屬性。  ### description **description** 屬性是一個**可選**配置屬性,是對當前專案的介紹。如果作為外掛釋出到 pub.dev 上,此值顯示在如下位置:  ### version 此屬性應用程式的版本和內部版本號,格式為 **x.x.x+x**,例如:**1.0.0+1**,這個版本號稱為 **語義版本號(semantic versioning )**,semantic versioning 相關知識請[參考此處](https://semver.org/spec/v2.0.0-rc.1.html)。 版本號 **+** 前面到部分,叫做 **version number**,由 2 個小點隔開,後面的部分叫做 **build number**。 在 Android 中 version number 對應 **versionName**,build number 對應 **versionCode**,在 android/build.gradle 下有相關配置,  早期的版本 build.gradle 中 versionName 和 versionCode 是直接寫死的數字,如下:  此時修改版本號只能通過修改 build.gradle 。而現在可以直接通過 pubspec.yaml 進行修改。 如果是外掛,那麼使用者可以通過此版本號指定使用哪個版本, ```dart path_provider: ^1.6.22 ``` 版本的指定有多種形式: #### 不指定或者 any ```dart path_provider: path_provider: any ``` 此種格式預設載入 **最新的版本**,但強烈不推薦使用此方式,因為版本的變化會導致介面發生變化,專案出現編譯異常。 #### x.y.z 明確指定版本 ```dart path_provider: 1.6.22 ``` 指定依賴的版本。 #### <=x.y.
版权声明
本文为[itread01]所创,转载请带上原文链接,感谢
https://www.itread01.com/content/1604511122.html
边栏推荐
- C++ 数字、string和char*的转换
- C++学习——centos7上部署C++开发环境
- C++学习——一步步学会写Makefile
- C++学习——临时对象的产生与优化
- C++学习——对象的引用的用法
- C++编程经验(6):使用C++风格的类型转换
- Won the CKA + CKS certificate with the highest gold content in kubernetes in 31 days!
- C + + number, string and char * conversion
- C + + Learning -- capacity() and resize() in C + +
- C + + Learning -- about code performance optimization
猜你喜欢
-
C + + programming experience (6): using C + + style type conversion
-
Latest party and government work report ppt - Park ppt
-
在线身份证号码提取生日工具
-
Online ID number extraction birthday tool
-
️野指针?悬空指针?️ 一文带你搞懂!
-
Field pointer? Dangling pointer? This article will help you understand!
-
HCNA Routing&Switching之GVRP
-
GVRP of hcna Routing & Switching
-
Seq2Seq实现闲聊机器人
-
【闲聊机器人】seq2seq模型的原理
随机推荐
- LeetCode 91. 解码方法
- Seq2seq implements chat robot
- [chat robot] principle of seq2seq model
- Leetcode 91. Decoding method
- HCNA Routing&Switching之GVRP
- GVRP of hcna Routing & Switching
- HDU7016 Random Walk 2
- [Code+#1]Yazid 的新生舞会
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- HDU7016 Random Walk 2
- [code + 1] Yazid's freshman ball
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- Qt Creator 自动补齐变慢的解决
- HALCON 20.11:如何处理标定助手品质问题
- HALCON 20.11:标定助手使用注意事项
- Solution of QT creator's automatic replenishment slowing down
- Halcon 20.11: how to deal with the quality problem of calibration assistant
- Halcon 20.11: precautions for use of calibration assistant
- “十大科学技术问题”揭晓!|青年科学家50²论坛
- "Top ten scientific and technological issues" announced| Young scientists 50 ² forum
- 求反转链表
- Reverse linked list
- js的数据类型
- JS data type
- 记一次文件读写遇到的bug
- Remember the bug encountered in reading and writing a file
- 单例模式
- Singleton mode
- 在这个 N 多编程语言争霸的世界,C++ 究竟还有没有未来?
- In this world of N programming languages, is there a future for C + +?
- es6模板字符
- js Promise
- js 数组方法 回顾
- ES6 template characters
- js Promise
- JS array method review
- 【Golang】️走进 Go 语言️ 第一课 Hello World
- [golang] go into go language lesson 1 Hello World