Answers for "dart inherit from generic"

0

dart inherit from generic

// available types
class BaseType {}
class DerivedType extends BaseType {}

class BaseClass<Type extends BaseType> {
  final Type prop;
  BaseClass(this.prop) {
    // can be either BaseType or DerivedType
    print(prop);
  }
}

class DerivedClass<Type extends BaseType> extends BaseClass<BaseType> {
  DerivedClass(BaseType prop) : super(prop);
}
Posted by: Guest on September-07-2020

Code answers related to "Dart"

Browse Popular Code Answers by Language