## Dart编程实例 - 更新一个列表```dartvoid main() { List l = [1, 2, 3,4,5,6,7,8,9]; print(The value of list before replacing ${l}); l.replaceRange(0,3,[11,23,24]); print(The
## Dart编程实例 - 位运算符```dartvoid main() { var a = 2; // Bit presentation 10 var b = 3; // Bit presentation 11 var result = (a b); print((a b) = ${result});
## Dart编程实例 - null值```dartvoid main() { int num; print(num);}```
## Dart编程实例 - 条件表达式```dartvoid main() { var a = 10; var res = a 12 ? value greater than 10:value lesser than or equal to 10; print(res);}```
## Dart编程实例 - 同步```dartimport dart:isolate; void foo(var message){ print(execution from foo ... the message is :${message});} void main(){ Isolate.spawn(foo,Hello
## Dart编程实例 - 异步```dartimport dart:io;void main() { print(Enter your name :); // prompt for user input String name = stdin.readLineSync(); // this i
## Dart编程实例 - 封装错误```dartlibrary loggerlib; void _log(msg) { print(Log method called in loggerlib msg:$msg); }```
## Dart编程实例 - 导入和使用库```dartimport dart:math;void main() { print(Square root of 36 is: ${sqrt(36)});}```
## Dart编程实例 - Typedefs 类型定义```darttypedef ManyOperation(int firstNo , int secondNo); //function signatureAdd(int firstNo,int second){ print(Add result is ${firstNo+second});}
## Dart编程实例 - Typedef 类型定义```darttypedef ManyOperation(int firstNo , int secondNo); //function signature Add(int firstNo,int second){ print(Add result is ${firstNo+second});}
## Dart编程实例 - 添加断点```dartvoid main() { int a = 10, b = 20, c = 5; c = c * c * c; print($a + $b = ${a+b}); print($a%$b = ${a%b}); // Add a break point here prin
## Dart编程实例 - 自定义异常```dartclass AmtException implements Exception { String errMsg() = Amount should be greater than zero;} void main() { try { withdraw_amt(-1);
## Dart编程实例 - 抛出异常```dartmain() { try { test_age(-2); } catch(e) { print(Age cannot be negative); }} void test_age(int age) { if(ag
## Dart编程实例 - 异常处理Finally 块 ```dartmain() { int x = 12; int y = 0; int res; try { res = x ~/ y; } on IntegerDivisionByZeroException { prin
## Dart编程实例 - on…catch```dartmain() { int x = 12; int y = 0; int res; try { res = x ~/ y; } on IntegerDivisionByZeroException catch(e) {
## Dart编程实例 - 异常处理 使用catch块```dartmain() { int x = 12; int y = 0; int res; try { res = x ~/ y; } catch(e) { print(e); }}``
## Dart编程实例 - 异常处理 使用 ON 块```dartmain() { int x = 12; int y = 0; int res; try { res = x ~/ y; } on IntegerDivisionByZeroException { print(
## Dart编程实例 - 泛型 Map```dartvoid main() { Map String,Stringm={name:Tom,Id:E1001}; print(Map :${m}); }```
## Dart编程实例 - 泛型 Queue```dartimport dart:collection;void main() { Queueint queue = new Queueint(); print(Default implementation ${queue.runtimeType}); queue.addLa
## Dart编程实例 - 泛型 Set```dartvoid main() { Set intnumberSet = new Setint(); numberSet.add(100); numberSet.add(20); numberSet.add(5); numberSet.add(60); num
## Dart编程实例 - 泛型列表实例```dartvoid main() { List String logTypes = new List String(); logTypes.add(1); logTypes.add(ERROR); logTypes.add(INFO); //iterating acr
## Dart编程实例 - 泛型列表```dartvoid main() { List String logTypes = new List String(); logTypes.add(WARNING); logTypes.add(ERROR); logTypes.add(INFO); // iter
## Dart编程实例 - addLast()```dartimport dart:collection; void main() { Queue numQ = new Queue(); numQ.addAll([100,200,300]); print(Printing Q.. ${numQ}); numQ.a
## Dart编程实例 - addFirst()```dartimport dart:collection; void main() { Queue numQ = new Queue(); numQ.addAll([100,200,300]); print(Printing Q.. ${numQ}); numQ.ad
## Dart编程实例 - 添加多个值到Queue```dartimport dart:collection;void main() { Queue queue = new Queue(); print(Default implementation ${queue.runtimeType}); queue.addAll([10,12,
## Dart编程实例 - 集合 Queue```dartimport dart:collection;void main() { Queue queue = new Queue(); print(Default implementation ${queue.runtimeType}); queue.add(10); qu
## Dart编程实例 - 集合 Maps```dartvoid main() { var details=new Map(); details[Usrname]=admin; details[Password]=admin@123; print(details);}```
## Dart编程实例 - 从HashSet删除值```dartimport dart:collection;void main() { Set numberSet = new HashSet(); numberSet.addAll([100,200,300]); print(Printing hashet.. ${numberSet
## Dart编程实例 - 添加多个值到HashSet```dartimport dart:collection;void main() { Set numberSet = new HashSet(); numberSet.addAll([100,200,300]); print(Default implementation :${n
## Dart编程实例 - HashSet```dartimport dart:collection; void main() { Set numberSet = new HashSet(); numberSet.add(100); numberSet.add(20); numberSet.add(5);
## Dart编程实例 - 从HashMap删除值```dartimport dart:collection;main() { var accounts = new HashMap(); accounts[dept] = HR; accounts[name] = Tom; accounts[email] =
## Dart编程实例 - 添加多个值到HashMap```dartimport dart:collection;main() { var accounts = new HashMap(); accounts.addAll({dept:HR,email:tom@xyz.com}); print(Map after add
## Dart编程实例 - HashMap```dartimport dart:collection;main() { var accounts = new HashMap(); accounts[dept]=HR; accounts[name]=Tom; accounts[email]=tom@xyz.
## Dart编程实例 - Set.from()```dartvoid main() { Set numberSet = new Set.from([12,13,14]); print(Default implementation :${numberSet.runtimeType}); // all elements are retriev
## Dart编程实例 - 集合 Set```dartvoid main() { Set numberSet = new Set(); numberSet.add(100); numberSet.add(20); numberSet.add(5); numberSet.add(60); numberSet.add
## Dart编程实例 - 集合列表```dartvoid main() { List logTypes = new List(); logTypes.add(WARNING); logTypes.add(ERROR); logTypes.add(INFO); // iterating across list
## Dart编程实例 - 迭代集合```dartimport dart:collection;void main() { Queue numQ = new Queue(); numQ.addAll([100,200,300]); Iterator i= numQ.iterator; while(i.moveNext())
## Dart编程实例 - toString() 方法```dartvoid main() { int n = 12; print(n.toString());}```
## Dart编程实例 - 级联操作符 (..)```dartclass Student { void test_method() { print(This is a test method); } void test_method1() { print(This is a test method
## Dart编程实例 - Object```dartclass Student { void test_method() { print(This is a test method); } void test_method1() { print(This is a test me
## Dart编程实例 - Super 关键字```dartvoid main() { Child c = new Child(); c.m1(12);}class Parent { String msg = message variable from the parent class; void m1(int a){
## Dart编程实例 - Static 关键字```dartclass StaticMem { static int num; static disp() { print(The value of num is ${StaticMem.num}) ; }} void main() { Sta
## Dart编程实例 - 方法覆盖```dartimport dart:io;void main() { Child c = new Child(); c.m1(12);}class Parent { void m1(int a){ print(value of a ${a});}}class Chi
## Dart编程实例 - 类继承```dartvoid main() { Child c = new Child(); c.m1(12);}class Parent { void m1(int a){ print(value of a ${a});}} class Child extends Parent {
## Dart编程实例 - 继承的类型```dartvoid main() { var obj = new Leaf(); obj.str = hello; print(obj.str);} class Root { String str;} class Child extends Root {}
## Dart编程实例 - dart getters 和 setters```dartclass Student { String name; int age; String get stud_name { return name; } void set stud_name(String na
## Dart编程实例 - This 关键字```dartvoid main() { Car c1 = new Car(E1001);} class Car { String engine; Car(String engine) { this.engine = engine; print(T
## Dart编程实例 - 命名构造函数```dartvoid main() { Car c1 = new Car.namedConst(E1001); Car c2 = new Car();} class Car {
## Dart编程实例 - 构造函数```dartvoid main() { Car c = new Car(E1001);}class Car { Car(String engine) { print(engine); }}```
## Dart编程实例 - 访问属性和函数```dartvoid main() { Car c= new Car(); c.disp();} class Car { // field String engine = E1001; // function void disp()
## Dart编程实例 - 实现多个接口```dartvoid main() { Calculator c = new Calculator(); print(The gross total : ${c.ret_tot()}); print(Discount :${c.ret_dis()});} class Calculat
## Dart编程实例 - 实现一个接口```dartvoid main() { ConsolePrinter cp= new ConsolePrinter(); cp.print_data();} class Printer { void print_data() { print(__________Print
## Dart编程实例 - Lambda 表达式```dartvoid main() { printMsg(); print(test());} printMsg()=print(hello);int test()=123; // returning function
## Dart编程实例 -递归函数```dartvoid main() { print(factorial(6));} factorial(number) { if (number = 0) { // termination case return 1; } else {
## Dart编程实例 - 可选参数和默认值```dartvoid main() { test_param(123);} void test_param(n1,{s1:12}) { print(n1); print(s1);}```
## Dart编程实例 - 可选命名参数```dartvoid main() { test_param(123); test_param(123,s1:hello); test_param(123,s2:hello,s1:world);} test_param(n1,{s1,s2}) { print(n1);
## Dart编程实例 - 可选位置参数```dartvoid main() { test_param(123);} test_param(n1,[s1]) { print(n1); print(s1);}```
## Dart编程实例 - 函数参数```dartvoid main() { test_param(123,this is a string);} test_param(int n1,String s1) { print(n1); print(s1);}```
## Dart编程实例 - 返回函数```dartvoid main() { print(test());} String test() { // function definition return hello world;}```
## Dart编程实例 - 调用函数```dartvoid main() { test();} test() { //function definition print(function called);}```
## Dart编程实例 - 枚举```dartenum Status { none, running, stopped, paused} void main() { print(Status.values); Status.values.forEach((v) = print(value: $
## Dart编程实例 - Runes类构造函数```dartmain() { Runes input = new Runes( \u{1f605} ); print(new String.fromCharCodes(input));} ```
## Dart编程实例 - String runes 属性```dartvoid main(){ A string.runes.forEach((int rune) { var character=new String.fromCharCode(rune); print(character); }); }``
## Dart编程实例 - String codeUnits 属性```dartimport dart:core; void main(){ f1();} f1() { String x = Runes; print(x.codeUnits);}```
## Dart编程实例 - String codeUnitAt() 方法```dartimport dart:core;void main(){ f1();}f1() { String x = Runes; print(x.codeUnitAt(0));}```
## Dart编程实例 - Symbol```dartimport dart:mirrors;void main(){ Symbol lib = new Symbol(foo_lib); String name_of_lib = MirrorSystem.getName(lib); print(lib); print(na
## Dart编程实例 - Map forEach() 方法```dartvoid main() { var usrMap = {name: Tom, Email: tom@xyz.com}; usrMap.forEach((k,v) = print(${k}: ${v}));}```
## Dart编程实例 - Map remove() 方法```dartvoid main() { Map m = {name:Tom,Id:E1001}; print(Map :${m}); dynamic res = m.remove(name); print(Value popped from the Ma
## Dart编程实例 - Map clear() 方法```dartvoid main() { Map m = {name:Tom,Id:E1001}; print(Map :${m}); m.clear(); print(Map after invoking clear() :${m});}```
## Dart编程实例 - Map addAll() 方法```dartvoid main() { Map m = {name:Tom,Id:E1001}; print(Map :${m}); m.addAll({dept:HR,email:tom@xyz.com}); print(Map after
## Dart编程实例 - Map isNotEmpty属性```dartvoid main() { var details = {Usrname:tom,Password:pass@123}; print(details.isNotEmpty); var hosts = {}; print(hosts.isNotEmpt
## Dart编程实例 - Map isEmpty属性```dartvoid main() { var details = {Usrname:tom,Password:pass@123}; print(details.isEmpty); var hosts = {}; print(hosts.isEmpty);}
## Dart编程实例 - Map Length属性```dartvoid main() { var details = {Usrname:tom,Password:pass@123}; print(details.length);}```
## Dart编程实例 - Map Values属性```dartvoid main() { var details = {Usrname:tom,Password:pass@123}; print(details.values);}```
## Dart编程实例 - Map Keys属性```dartvoid main() { var details = {Usrname:tom,Password:pass@123}; print(details.keys);}```
## Dart编程实例 - Map 构造方法```dartvoid main() { var details = new Map(); details[Usrname] = admin; details[Password] = admin@123; print(details);}```
## Dart编程实例 - 添加值到map```dartvoid main() { var details = {Usrname:tom,Password:pass@123}; details[Uid] = U1oo1; print(details);}```
## Dart编程实例 - Dart Map ```dartvoid main() { var details = {Usrname:tom,Password:pass@123}; print(details);}```
## Dart编程实例 - 列表removeLast()方法```dartvoid main() { List l = [1, 2, 3,4,5,6,7,8,9]; print(The value of list before removing the list element ${l}); dynamic res = l.removeLas
## Dart编程实例 - 列表removeAt()方法```dartvoid main() { List l = [1, 2, 3,4,5,6,7,8,9]; print(The value of list before removing the list element ${l}); dynamic res = l.removeAt(1);
## Dart编程实例 - 列表 remove() 方法```dartvoid main() { List l = [1, 2, 3,4,5,6,7,8,9]; print(The value of list before removing the list element ${l}); bool res = l.remove(1);
## Dart编程实例 - 列表insertAll()方法```dartvoid main() { List l = [1,2,3]; l.insertAll(0,[120,130]); print(l);}```
## Dart编程实例 - 列表insert()方法```dartvoid main() { List l = [1,2,3]; l.insert(0,4); print(l);}```
## Dart编程实例 - 列表 addAll() 方法```dartvoid main() { List l = [1,2,3]; l.addAll([12,13]); print(l);}```
## Dart编程实例 - 插入元素到列表```dartvoid main() { List l = [1,2,3]; l.add(12); print(l);}```
## Dart编程实例 - 列表 single 方法```dartvoid main() { var lst = new List(); lst.add(12); lst.add(10); print(lst.single);}```
## Dart编程实例 - 列表 reversed 方法```dartvoid main() { var lst = new List(); lst.add(12); lst.add(13); print(The list values in reverse order: ${lst.reversed});} ```
## Dart编程实例 - 列表 last 方法 ```dartvoid main() { var lst = new List(); lst.add(12); lst.add(13); print(The last element of the list is: ${lst.last});}```
## Dart编程实例 - 列表 length 方法```dartvoid main() { var lst = new List(); lst.add(12); lst.add(13); print(The length of the list is : ${lst.length});}```
## Dart编程实例 - 列表 isNotEmpty 方法```dartvoid main() { var lst = new List(); lst.add(12); lst.add(13); print(lst.isNotEmpty);}```
## Dart编程实例 - 列表 isEmpty 方法```dartvoid main() { var lst = new List(); lst.add(12); lst.add(13); print(lst.isEmpty);} ```
## Dart编程实例 - 列表first方法```dartvoid main() { var lst = new List(); lst.add(12); lst.add(13); print(The first element of the list is: ${lst.first});} ```
## Dart编程实例 - dart变长列表实例```dartvoid main() { var lst = new List(); lst.add(12); lst.add(13); print(lst);}```
## Dart编程实例 - dart变长列表```dartvoid main() { var num_list = [1,2,3]; print(num_list);}```
## Dart编程实例 - dart固定长度列表```dartvoid main() { var lst = new List(3); lst[0] = 12; lst[1] = 13; lst[2] = 11; print(lst);}```
## Dart编程实例 - Boolean 实例```dartvoid main() { var str = abc; if(str) { print(String is not empty); } else { print(Empty String); }}```
## Dart编程实例 - 在Dart中声明布尔变量```dartvoid main() { bool test; test=12 5; print(test);}```
## Dart编程实例 - 字符串 codeUnitAt 方法```dartvoid main() { var res = Good Day; print(Code Unit of index 0 (G): ${res.codeUnitAt(0)}); }```
## Dart编程实例 - 字符串 toString 方法```dartvoid main() { int n = 12; var res = n.toString(); print(New String: ${res});}```
## Dart编程实例 - 字符串substring 方法```dartvoid main() { String str1 = Hello World; print(New String: ${str1.substring(6)}); // from index 6 to the last index print(New Str
## Dart编程实例 - 字符串 split() 方法```dartvoid main() { String str1 = Today, is, Thursday; print(New String: ${str1.split(,)});}```
## Dart编程实例 - 字符串 replaceAll() 方法```dartvoid main() { String str1 = Hello World; print(New String: ${str1.replaceAll(World,ALL)});}```
## Dart编程实例 - 字符串 compareTo() 方法```dartvoid main() { String str1 = A; String str2 = A; String str3 = B; print(str1.compareTo(str2): ${str1.compareTo(str2)});
## Dart编程实例 - 字符串 trim() 方法```dartvoid main() { String str1 = hello; String str2 = hello world; String str3 = hello; print(str1.trim()); print(str2.trim());
## Dart编程实例 - 字符串 toUpperCase() 方法```dartvoid main() { String uStr = ABC; String lStr = hello; print(uStr.toLowerCase()); print(lStr.toLowerCase());}```
## Dart编程实例 - 字符串 toLowerCase() 方法```dartvoid main() { String uStr = ABC; String lStr = hello; print(uStr.toLowerCase()); print(lStr.toLowerCase());}```
## Dart编程实例 - dart字符串属性 length```dartvoid main() { String str = Hello All; print(The length of the string is: ${str.length});}```
## Dart编程实例 - dart字符串属性 isEmpty```dartvoid main() { String str = Hello; print(str.isEmpty);}```
## Dart编程实例 - dart字符串属性 codeUnits```dartvoid main() { String str = Hello; print(str.codeUnits);}```
## Dart编程实例 - dart字符串插值```dartvoid main() { int n=1+1; String str1 = The sum of 1 and 1 is ${n}; print(str1); String str2 = The sum of 2 and 2 is ${2+2}; print(
## Dart编程实例 - dart字符串```dartvoid main() { String str1 = this is a single line string; String str2 = this is a single line string; String str3 = this is a multiline line
## Dart编程实例 - Truncate 方法```dartvoid main() { double n1 = 2.123; var value = n1.truncate(); print(The truncated value of 2.123 = ${value});}```
## Dart编程实例 - toString 方法```dartvoid main() { int n1 = 2; var value = n1.toString(); print( value is String );}```
## Dart编程实例 - toInt 方法```dartvoid main() { double n1 = 2.0; var value = n1.toInt(); print(Output = ${value});}```
## Dart编程实例 - toDouble 方法```dartvoid main() { int n1 = 2; var value = n1.toDouble(); print(Output = ${value});}```
## Dart编程实例 - round 方法```dartvoid main() { double n1 = 12.023; double n2 = 12.89; var value = n1.round(); print( value ); value = n2.round(); print( value );
## Dart编程实例 - Remainder 方法 ```dartvoid main() { var a = 10; var b = 17; print(a.remainder(2)); print(b.remainder(2));}```
## Dart编程实例 - Floor 方法```dartvoid main() { var a = 2.9; print(The floor value of 2.9 = ${a.floor()});}```
## Dart编程实例 - CompareTo 方法```dartvoid main() { var a = 2.4; print(a.compareTo(12)); print(a.compareTo(2.4)); print(a.compareTo(0));}```
## Dart编程实例 - Ceil 方法```dartvoid main() { var a = 2.4; print(The ceiling value of 2.4 = ${a.ceil()});} ```
## Dart编程实例 - Abs 方法```dartvoid main() { var a = -2; print(a.abs());}```
## Dart编程实例 - 数字 isOdd 属性```dartvoid main() { int posNum = 10; print(posNum.isOdd);}```
## Dart编程实例 - 数字 isEven 属性```dartvoid main() { int posNum = 10; print(posNum.isEven);}```
## Dart编程实例 - 数字 sign 属性```dartvoid main() { int posNum = 10; int negNum = -12; int valZero = 0; print(posNum.sign); print(negNum.sign); print(valZero.sign)
## Dart编程实例 - 数字 isNegative 属性```dartvoid main() { int posNum = 10; int negNum = -10; print(posNum.isNegative); print(negNum.isNegative);}```
## Dart编程实例 - 数字 isInFinite 属性```dartvoid main() { int n = 5000; print(n.isInfinite);} ```
## Dart编程实例 - 数字 isFinite 属性```dartvoid main() { int n = 5000; print(n.isFinite);}```
## Dart编程实例 - 数字 hashcode 属性```dartvoid main() { int n = 5000; print(n.hashCode);}```
## Dart编程实例 - parse函数```dartvoid main() { print(num.parse(12A)); print(num.parse(AAAA));}```
## Dart编程实例 - 数字实例```dartvoid main() { int num1 = 10; // declare an integer double num2 = 10.50; // declare a double value print(num1); pr
## Dart编程实例 - Dart Switch Case 语句```dartvoid main() { var grade = A; switch(grade) { case A: { print(Excellent); } break; case B: { print(Go
## Dart编程实例 - else if```dartvoid main() { var num = 2; if(num 0) { print(${num} is positive); } else if(num 0) { print(${num} is negative);
## Dart编程实例 - 简单 if else 语句```dartvoid main() { var num = 12; if (num % 2==0) { print(Even); } else { print(Odd); }}```
## Dart编程实例 - If 语句```dartvoid main() { var num=5; if (num0) { print(number is positive); } }```
## Dart编程实例 - continue 和 Label```dartvoid main() { outerloop: // This is the label name for (var i = 0; i 3; i++) { print(Outerloop:${i}); for (var j = 0; j
## Dart编程实例 - break和label```dartvoid main() { outerloop: // This is the label name for (var i = 0; i 5; i++) { print(Innerloop: ${i}); innerloop: for (
## Dart编程实例 - Continue 语句```dartvoid main() { var num = 0; var count = 0; for(num = 0;num=20;num++) { if (num % 2==0) { continue; } coun
## Dart编程实例 - Break 语句```dartvoid main() { var i = 1; while(i=10) { if (i % 5 == 0) { print(The first multiple of 5 between 1 and 10 is : ${i});
## Dart编程实例 - do while 循环```dartvoid main() { var n = 10; do { print(n); n--; } while(n=0);}```
## Dart编程实例 - dart while 循环```dartvoid main() { var num = 5; var factorial = 1; while(num =1) { factorial = factorial * num; num--; } print(The
## Dart编程实例 - dart for-in 循环 ```dartvoid main() { var obj = [12,13,14]; for (var prop in obj) { print(prop); }}```
## Dart编程实例 - Dart for循环```dartvoid main() { for(var temp, i = 0, j = 1; j30; temp = i, i = j, j = i + temp) { print(${j}); }}```
## Dart编程实例 - 逻辑操作符```dartvoid main() { var a = 10; var b = 12; var res = (ab)||(b10); print(res); var res1 =!(a==b); print(res1);} ```
## Dart编程实例 - 赋值操作符```dartvoid main() { var a = 12; var b = 3; a+=b; print(a+=b : ${a}); a = 12; b = 13; a-=b; print(a-=b : ${a});
## Dart编程实例 - 类型测试操作符 is! ```dartvoid main() { double n = 2.20; var num = n is! int; print(num);}```
## Dart编程实例 - 类型测试操作符is```dartvoid main() { int n = 2; print(n is int);}```
## Dart编程实例 - 相等和关系操作符```dartvoid main() { var num1 = 5; var num2 = 9; var res = num1num2; print(num1 greater than num2 :: +res.toString()); res = num1num2;
## Dart编程实例 算术操作符```dartvoid main() { var num1 = 101; var num2 = 2; var res = 0; res = num1+num2; print(Addition: ${res}); res = num1-num2; print(Sub
## Dart编程实例 - Const 关键字```dartvoid main() { final v1 = 12; const v2 = 13; v2 = 12;}```
## Dart编程实例 - Final 关键字```dartvoid main() { final val1 = 12; print(val1);}```
## Dart编程实例 - Dynamic 关键字```dartvoid main() { dynamic x = tom; print(x); }```
## Dart编程实例 - Dart 面向对象编程```dartclass TestClass { void disp() { print(Hello World); }} void main() { TestClass c = new TestClass(); c.d
## Dart编程实例 - Enabling Checked Mode```dartvoid main() { int n=hello; print(n); } ```
## Dart编程实例 - 第一个Dart程序```dartmain() { print(Hello World!);}```
## Dart编程实例 - HelloWorld```dartvoid main() { print(hello world);}```