{"id":102757,"date":"2020-05-09T03:04:34","date_gmt":"2020-05-08T19:04:34","guid":{"rendered":"http:\/\/4563.org\/?p=102757"},"modified":"2020-05-09T03:04:34","modified_gmt":"2020-05-08T19:04:34","slug":"%e5%85%b3%e4%ba%8e-dart-%e7%9a%84%e9%87%8d%e5%ae%9a%e5%90%91%e6%9e%84%e9%80%a0%e5%87%bd%e6%95%b0%e7%9a%84%e7%96%91%e9%97%ae","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=102757","title":{"rendered":"\u5173\u4e8e Dart \u7684\u91cd\u5b9a\u5411\u6784\u9020\u51fd\u6570\u7684\u7591\u95ee"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5173\u4e8e Dart \u7684\u91cd\u5b9a\u5411\u6784\u9020\u51fd\u6570\u7684\u7591\u95ee               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : version0 <\/span>  <span><i><\/i> 46<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h3>\u4e0a\u4ee3\u7801<\/h3>\n<pre><code>class Point extends Test {   num x;   num y;   num z;   num get a {     return this.x + this.y;   }    set a(num v) {     x = v - y;   }    Point.fromJson(Map jsonMap)       : this.x = jsonMap['x'],         y = jsonMap['y'],         super.fromJson({}) {     print(this.x);     print('In Point.fromJson(): ($x, $y, $z)');   }    Point.aliasB(Map jsonMap, num z)       : this.z = z,         super.fromJson({}) {     Point.fromJson(jsonMap);   }    Point(Map jsonMap, this.z) : super(jsonMap) {     print('In Point(): ($x, $y, $z)');     x = jsonMap['x'];     y = jsonMap['y'];     print('In Point(): ($x, $y, $z)');   } }  class Test {   num x;   num y;   Test(Map map)       : x = map['x'],         y = map['y'] {     print('In Parent.Test(): ($x, $y)');   }   Test.fromJson(Map map) : this(map); }  main(List&lt;String&gt; args) {   new Point({'x': 1, 'y': 2}, 3);   new Test({'x': 1, 'y': 2}); }  <\/code><\/pre>\n<h3>\u6267\u884c\u7ed3\u679c<\/h3>\n<pre><code>In Parent.Test(): (null, null) In Point(): (null, null, 3) In Point(): (1, 2, 3) In Parent.Test(): (1, 2) <\/code><\/pre>\n<h3>\u7591\u95ee\uff1a<\/h3>\n<h4>1\uff1aTest \u6784\u9020\u51fd\u6570\u5192\u53f7\u53f3\u8fb9\u4e0d\u662f\u8d4b\u503c\u4e86\u5417 \u4e3a\u5565\u662f null \uff1f\u63a5\u53d7\u7684\u53c2\u6570\u6253\u5370\u51fa\u6765\u662f\u6709\u503c\u7684<\/h4>\n<h4>2\uff1a\u5982\u679c\u6211\u628a Test \u7c7b\u7684\u6210\u5458\u53d8\u91cf x,y \u6539\u540d\u5b57\u4e0d\u8ddf\u5b50\u7c7b\u4e00\u6837\uff0c\u5c31\u80fd\u6253\u5370\u51fa\u6765\uff0c\u8fd9\u53c8\u662f\u4e3a\u5565\uff1f<\/h4>\n<p>\u5e0c\u671b\u6709\u5927\u4f6c\u80fd\u89e3\u7b54\u4e00\u4e0b\u83dc\u9e1f\u7684\u7591\u95ee<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"692544\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : IGJacklove <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7236\u7c7b\u548c\u5b50\u7c7b\u90fd\u6709\u76f8\u540c\u540d\u5b57\u7684\u53c2\u6570\uff0cPoint \u7684 x \u5c31\u662f\u4ed6\u81ea\u5df1\u7684 x\uff0c\u5982\u679c\u60f3\u8bbf\u95ee\u7236\u7c7b Test \u7684 x\uff0c\u7528 super.x                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"692545\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : version0 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @IGJacklove \u989d\uff0c\u4f60\u8bf4\u7684\u6211\u77e5\u9053\u554a\uff0c\u4f46\u662f\u6ca1\u89e3\u51b3\u6211\u7684\u95ee\u9898\u554a\uff0cTest \u7c7b\u7684\u6784\u9020\u65b9\u6cd5\u6ca1\u6709\u7ed9\u5b83\u7684\u5c5e\u6027 x,y \u8d4b\u503c\u5462\uff0c\u662f\u56e0\u4e3a\u5b50\u7c7b\u8c03\u7528\u7236\u7c7b\u7684\u6784\u9020\u65b9\u6cd5\u65f6\uff0c\u4e0d\u4f1a\u6267\u884c\u7236\u7c7b\u6784\u9020\u65b9\u6cd5 \u5192\u53f7\u540e\u9762\u7684\u8d4b\u503c\u8bed\u53e5\u5417\uff1f\u6211\u628a\u8d4b\u503c\u8bed\u53e5\u653e\u5230{}\u91cc\u5c31\u80fd\u8d4b\u503c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"692546\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : bytelee <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u6837\u770b Point \u521d\u59cb\u5316\u7684\u65f6\u5019 \u7236\u7c7b\u7684 Test \u7684\u521d\u59cb\u5316\u91cc\u8fb9\u6253\u5370\u7684\u5e94\u8be5\u662f point.x point.y \u6240\u4ee5\u6ca1\u6709\u8d4b\u503c\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"692547\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : version0 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @bytelee \u6211\u7ed9 Point \u7684 x\u3001y \u8bbe\u7f6e\u9ed8\u8ba4\u503c\u540e\u6765\u770b \u786e\u5b9e\u662f\u8fd9\u6837\u7684\uff0c\u90a3\u662f\u4e0d\u662f\u7236\u7c7b\u548c\u5b50\u7c7b\u53d8\u91cf\u540c\u540d\u7684\u6e05\u7a7a\u4e0b\uff0c\u5728\u7236\u7c7b\u7684\u6784\u9020\u65b9\u6cd5\u91cc\u6ca1\u6cd5\u8bbf\u95ee\u5b83\u672c\u8eab\u7684\u53d8\u91cf\u4e86\uff1f\u5982\u679c\u80fd\uff0c\u8be5\u548b\u8bbf\u95ee\uff08\u52a0 this \u8fd8\u662f\u8bbf\u95ee\u7684\u5b50\u7c7b\u7684\uff09\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"692548\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : bytelee <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @version0 #4 \u90a3\u4e2a\u91cc\u8fb9\u7684 this \u5e94\u8be5\u4e5f\u662f\u5b50\u7c7b\u7684\u4e86 \u6211\u5176\u5b9e\u611f\u89c9\u5e94\u8be5\u907f\u514d\u8fd9\u79cd\u505a\u6cd5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5173\u4e8e Dart \u7684\u91cd\u5b9a\u5411\u6784\u9020\u51fd\u6570\u7684&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/102757"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=102757"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/102757\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=102757"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=102757"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=102757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}