Reputation: 14878
In Dart I have a class:
class A implements Iterable<MyType>{
List<MyType> children;
//other members for A class
}
Is it possible, without using noSuchMethod
, to implicitly forward all of the Iterable<MyType>
methods to the List<MyType> children;
member?
Upvotes: 1
Views: 164
Reputation: 76213
AFAIK it's not possible to delegate without noSuchMethod
or without implementing all members.
An other way can be to use IterableBase and only implement Iterable.iterator like this :
import 'dart:collection';
class A extends IterableBase<MyType> {
List<MyType> children;
Iterator<MyType> get iterator => children.iterator;
}
Note that this could be less performant than implementing and delegating every members directly to children
.
Upvotes: 1