dart 扩展方法

使用extension  on 关键字

main(List<String> args) {
  String a = 'tom';
  print(a.hello());
}

extension NumberParsing on String {
  String hello() {
    return 'hello ' + this;
  }
}

 

posted @ 2020-01-27 11:50  富坚老贼  阅读(760)  评论(0)    收藏  举报