datto
datto

Reputation: 411

Create an alias for a Map specialization in Dart

Ideally I'm looking for something like :

typedef Json = Map<String, dynamic>;

From what I understand, this language feature is under review typedef for simple type aliases with ETA Q1'19

But for a immediate alternative, what would be the simplest way to "extend" a Map in Dart ? All the solutions I could find are quite old and look overkill. At the end I just want an alias for my Map.

Thanks in advance.

Upvotes: 6

Views: 2149

Answers (1)

Dart 2.13

  1. Update analysis_options.yaml
analyzer:
  enable-experiment:
    - nonfunction-type-aliases
  1. Run
flutter run --enable-experiment=nonfunction-type-aliases

Upvotes: 1

Related Questions