在我的应用中,我正在从JSON API中读取数据。我希望在选中复选框后更新一个值。
下面是我的model.dart文件。我正在尝试使用JSON API中的值初始化我的checkbox.dart文件中的变量。有人可以帮忙吗?
class Package {
String title;
num price;
List<ServiceTask> services;
String id;
Package({this.title, this.price, this.services, this.id});
Package.fromJson(Map<String, dynamic> json) {
title = json['title'];
// price = (json['price']).toDouble();
price = (json['price']).toDouble();
if (json['services'] != null) {
services = List<ServiceTask>();
json['services'].forEach((v) {
services.add(new ServiceTask.fromJson(v));
});
}
id = json['id'];
}