減少null判斷情況
https://stackoverflow.com/questions/51036758/flutter-the-method-map-was-called-on-null
https://juejin.im/post/5c6d38b1f265da2dcc7feb69
https://cloud.tencent.com/developer/article/1370380
?? => if null
https://blog.csdn.net/ffa_ijj/article/details/85051156
return qres?.map((value) { LinkedHashMap result = json.decode(value["jsonitem"]); return result; })?.first ?? new LinkedHashMap(); 這個判斷方式有個問題,當查詢回來為[],不是null情況下,在.first會出錯,因為 “No element"會出錯,但.toList()會正確,故改回
if (qres == null || qres.isEmpty) return new Member(); // 待確定是否出錯 var resmap = qres.first; return new Member.fromJson(json.decode(resmap["jsonitem"]));
https://github.com/drails-dart/dart-serialise
https://github.com/parnham/dart-serialise
https://github.com/dart-league/dson
https://javiercbk.github.io/json_to_dart/
https://ashamp.github.io/jsonToDartModel/
Very Important!
{"107年工作":{"zhangqi":[{"name":"王大明1"},{"name":"孫小明1"}],"chaojiangeren":[{"name":"nnn1","addr":"aaa1"},{"name":"nnn2","addr":"aaa2"}]},"108年法會":{"zhangqi":[{"name":"王大明1"},{"name":"孫小明1"}]}} zhangqi : [ …. ]
chaojiangeren: [ …. ]
zhangqi : [ {….}, {….} ]
chaojiangeren: [ {….}, {….} ]
Can’t have \' or \" If have this, json.decode can’t List List=> ListList=> List List<ItemName> zhangqi = List<ItemName>(); zhangqi.add(new ItemName(name:"王大明1")); zhangqi.add(new ItemName(name:"孫小明1")); List<ItemNameAddr> chaojiangeren = List<ItemNameAddr>(); chaojiangeren.add(new ItemNameAddr(name:"nnn1", addr:"aaa1")); chaojiangeren.add(new ItemNameAddr(name:"nnn2", addr:"aaa2")); class ItemName { String name; ItemName({ this.name }) ; ItemName.fromJson(Map<String, dynamic> json) : name = json['name']; Map toJson() => {"name": name }; //給json.
Jonny Huang
https://book.flutterchina.club/
https://www.appcoda.com.tw/flutter-introduction/
Dart 內建支援 Streams 及 Future。我的 RxJava 經驗有助我了解 Streams,而在 ES6 Promise 方面的經驗則有助我理解 Futures 和 Async/Await 的概念