环境搭建完成以后,咱们来看看Flutter:New Project后生成的项目结构。
具体环境搭建能够参考:w7上使用VSCode配置Flutter开发环境web
与Node.js的package.json文件的类比
(由于我在web开发里是使用Node.js来作包管理的,因此类比nonde.js的package.json对于由web入门学习flutter的同窗会比较容易理解。)npm
简单而言,pubspec.yaml文件的做用就至关于Node.js的package.json文件,是用来进行包管理的;
二者都分离了两个环境,dependencies和dev_dependencies;
前者使用yaml语法来定义,后者使用json语法;
pubspec.yaml对版本的约束规则与package.json规则相似;json
Node.js | Flutter | |
安装依赖 | npm install | flutter package get |
升级依赖包版本 | npm update | flutter packages upgrade |
协同开发保证包版本一致 | package-lock.json | pubspec.lock |
关于此后续能够再丰富~~segmentfault
#包名 name: todo_app #描述信息 description: A new Flutter project. #版本号 version: 1.0.0+1 #指定环境 environment: sdk: ">=2.0.0-dev.68.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.0 #指定开发环境下的包依赖 dev_dependencies: flutter_test: sdk: flutter # For information on the generic Dart part of this file, see the # following page: https://www.dartlang.org/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