flutter与pubspec.yaml

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_31057219/article/details/90053722

main.dart 和 pubspec.yaml。可以将它们比做 index.js 与 package.json

main.dart

每一个Flutter项目的/lib目录下都有一个main.dart文件,打开该文件,里面应该有一个main()函数。
Flutter使用Dart语言开发,而在Dart语言中,main()函数是Dart程序的入口,
也就是说,Flutter程序在运行的时候,第一个执行的函数就是main()函数。

pubspec.yaml

flutter的pub仓库

package.json中版本号详解

pubspec.yaml:

#######################################################
# app的名字为flutter_app
#######################################################
name: flutter_app
description: A new Flutter 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.
# Read more about versioning at semver.org.
#################################
# app的版本
#################################
version: 1.0.0+1

#################################
# 环境,dart的sdk版本
#################################
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

########################################################
# 测试环境的依赖库
########################################################
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的配置项
#########################################################
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.
  # 使用Material图标
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  # assets文件
  # images是个和pubspec.yaml配置文件同级的目录,如果不同级,需要添加..
  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.io/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.io/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.io/custom-fonts/#from-packages

猜你喜欢

转载自blog.csdn.net/sinat_31057219/article/details/90053722