class ArticlesModel{ final int id; final String clave; final String nombre; final int categoriaId; final List precios; final bool activo; ArticlesModel({ required this.id, required this.clave, required this.nombre, required this.categoriaId, required this.precios, required this.activo, }); factory ArticlesModel.fromJson(Map json) { var list = json['precios'] as List; List preciosList = list.map((i) => Price.fromJson(i)).toList(); return ArticlesModel( id: json['id'], clave: json['clave'], nombre: json['nombre'], categoriaId: json['categoria']['id'], precios: preciosList, activo: json['activo'], ); } static List fromJsonArray(List jsonArray) { return jsonArray.map((json) => ArticlesModel.fromJson(json)).toList(); } } class Price { final int id; final double precio; Price({ required this.id, required this.precio, }); factory Price.fromJson(Map json) { return Price( id: json['id'], precio: json['precio'].toDouble(), ); } }