老师好,这章讲的初始化列表中,如何调用初始化的值。
void main() { Map map = {"address": "beijing", "name": "devil"}; var person = Person.withName(map); print(person.name); print(person.address); } class Person { String name; int age; final String address; // 初始化列表 Person.withName(Map map) : address = map["address"] { this.name = map["name"]; } }
非常感谢。