language icon indicating copy to clipboard operation
language copied to clipboard

Typed Maps - like interfaces in TypeScript

Open KoTTi97 opened this issue 5 years ago • 46 comments

I would love to see typed Maps in Dart like it is possible in TypeScript.

TypeScript example:

interface IPerson {
    name: string;
    age: number;
    height?: number;
}

const person: IPerson = {
    name: "Max",
    age: 26
}

I wish Dart would support something like that so i do not have to create a class for it. It could look something like this:

interface IPerson {
  String name;
  int age;
  height? double;
}

Map<IPerson> person = {
  name: "Max",
  age: 26,
} 

KoTTi97 avatar Jan 16 '20 19:01 KoTTi97