table of Contents
- Dart development environment installation
- Dart basic concepts
- Dart built-in type
- Dart method
- Dart operator
Dart development environment installation
Dart Installation Overview
Mac installation DartSdk
Update dart
brew update dart
Dar check whether the installation was successful
dart --version
Set dart environment variable environment
vim .bash_profile
export PATH = ${PATH}:dartSdk的bin路劲
VSCode Dart environment installation
DartPad
Dart basic concepts
Dart sample program
Keyword
variable
Dart built-in type
int type
double type
String
Boolean
List
//支持...和...?
var list = [1,2,3];
var list = null;
var newList = [0,...list];
var newList = [0,...?list2]; //如果list2不为空,则插入元素到新数组
//collection if 和 collection for
var newList = [0,if(1<2) 3]; //根据条件 ,将结果插入到新数组
var newList = [0,for(int i: list) $i ] //将list中的元素依次插入到新数组
Set (2.3 incorporation)
//两种初始化空set的方式
Set<int> set = <int>{};
set = dynamic{}
Map
var a = {a:'1',b:'2'}
//空Map
var a = {}
Runes
Symbols
Dart method
parameter
Optional parameters
Named parameters
positional parameters
The method is first-class objects
void log (e){
println(e)
}
//方法可以当做参数
list.forEach(log);
//方法可以赋值
var print = (e) => "xxxx ${e}";
main method
Scope
The method of determining whether the same
Method returns a value
Dart operator
Priority operator is from top to bottom, left to right (in the order of the figure above)