Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create an alias for a Map specialization in Dart

Tags:

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.

like image 922
datto Avatar asked Nov 07 '22 17:11

datto


1 Answers

Dart 2.13

  1. Update analysis_options.yaml
analyzer:
  enable-experiment:
    - nonfunction-type-aliases
  1. Run
flutter run --enable-experiment=nonfunction-type-aliases
like image 175
Petrus Nguyễn Thái Học Avatar answered Dec 21 '22 06:12

Petrus Nguyễn Thái Học