我想定义一个可以 Select 接受参数的getter.我成功地做到了这一点,但只有在通话后加上必须的()
才行.以下是代码:
get children => ([role=null]) {
if(role == null || role == 'any') { return _children; }
else { return _children_by_role[role]; }
};
所以现在我可以说
obj.children('something').length;
或
obj.children().length;
但我不能说
obj.children; // this doesn't w或k
because it results in the following err或:
Caught Closure call with mismatched arguments: function 'length' NoSuchMethodErr或 : method not found: 'length' Receiver: Closure: ([dynamic])