认识 Dart 的库概念
Dart 库就是一个 library,是一个模块化的、可共享的代码库。
Dart 库可以包含一组 import, export 和顶级声明。顶级声明可以是类、类型别名、函数或变量声明。
more >>No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
1 | Exit code 1 from: C:\Users\sawan\Documents\test-app\android\gradlew.bat app:properties: |
final 修饰一个编译时常量,final 修饰一个运行时常量。
final 变量指的是只能进行初始化而不能进行赋值操作的变量;
const 变量指的必须使用编译时常量进行初始化并且不能进行赋值操作的变量(因此 const 变量总是隐式地具有 final 属性);
为了更好的了解 Dart 的函数参数传递,不妨从 Functoin 类的静态方法入手。
1 | external static apply(Function function, List positionalArguments, |
Dynamically call function with the specified arguments.
Acts the same as calling function with positional arguments corresponding to the elements of [positionalArguments] and named arguments corresponding to the elements of [namedArguments].–https://api.dartlang.org/stable/2.3.0/dart-core/Function/apply.html
该方法是 Function 类提供的静态调用方法,可以直接以特定的参数直接调用一个函数。
more >>官方文档中提到 factory 关键字是用来修饰是构造函数的。
在一些特定的场景,类本身需要避免创建过多的实例,可以使用 factory 创建工厂构造函数。
官方提供了一个 Logger 的工厂构造函数从静态变量 _cache 中返回实例而无需重复创建类的实例。
1 | class Logger { |
特别的 factory 需要返回一个对象,并且不允许使用 this 关键字。
缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是yilia根目录)执行以下命令:
npm i hexo-generator-json-content --save
3、在根目录_config.yml里添加配置:
jsonContent: meta: false pages: false posts: title: true date: true path: true text: false raw: false content: false slug: false updated: false comments: false link: false permalink: false excerpt: false categories: false tags: true