使用动态密钥的Flutter访问模型属性

时间:2019-05-10 06:20:57

标签: object dart flutter setter getter

例如在PHP中,

$key1 = 'name'; 
$key2 = 'mobile';

$person = new Person();
$person->{$key1} = 'Ahmad';
$person->{$mobile} = '60148220678';

如何用Flutter(Dart语言)实现?我尝试过

var key1 = 'name';
Person _person = new Person();

_person.{key1} = 'Ahmad';

但是它显示了错误

0 个答案:

没有答案