How do I create a type alias

You can't define alias. For your case you can use DelegatingList from quiver to define Directives :

import 'package:quiver/collection.dart';

class Directives extends DelegatingList<String> {
  final List<String> delegate = [];
}

It is possible now via an empty mixin

mixin ToAlias{}

class Stuff<T> {
  T value;
  Stuff(this.value);
}

class StuffInt = Stuff<int> with ToAlias;

main() {
  var stuffInt = StuffInt(3);
}

EDIT 2.13

It looks likely that unreleased 2.13 will contain proper type aliasing without the need of a mixin.

typedef IntList = List<int>;
IntList il = [1,2,3];

https://github.com/dart-lang/language/issues/65#issuecomment-809900008 https://medium.com/dartlang/announcing-dart-2-12-499a6e689c87

Tags:

Types

Dart