Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

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);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dart #inherit #generic
ADD COMMENT
Topic
Name
1+2 =