i want save list of object in local memory by shared_preferences my Model :
class Vehicle {
final String vehicleId;
final String vehicleType;
Vehicle({
this.vehicleId,
this.vehicleType,
});
}
after when i search about this i found half-solution :) to convert to List<String> and add this to my class :
factory Vehicle.fromJson(Map<String, dynamic> vehicleJson){
return new Vehicle(
vehicleId: vehicleJson['vehicleId'],
vehicleType: vehicleJson['vehicleType'],
);
}
Map<String, dynamic> toJson(){
return {
'vehicleId': this.vehicleId,
'vehicleType' : this.vehicleType,
};
}
but i can't found how can i save and get it :(
sorry my English not good