I want to add my own methods to a few Dart Classes

醉酒当歌 提交于 2019-12-06 05:09:34

I've hit this problem too. The best workaround at the moment is to create a class that forwards all of the method calls. Something like: https://github.com/dart-lang/html5lib/blob/master/lib/src/list_proxy.dart

Then you can inherit from ListProxy and override or add whatever methods you need.

If people find this useful enough, maybe we can put it in its own pub package. I'm hoping we can get dart:core fixed, though, so it supports inheritance from all of the core collection classes.

By the way, if you're trying to override a method in Map it's much easier: you can import 'dart:coreimpl'; and extend HashMapImplementation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!