init
This commit is contained in:
commit
e833bcaec4
224 files changed
+11812
No files matched your search
@@ -0,0 +1,33 @@
|
||||
class Role {
|
||||
// Proprietà della classe
|
||||
final int id;
|
||||
final String name;
|
||||
final String description;
|
||||
|
||||
// Costruttore con parametri nominati e 'required'
|
||||
Role({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.description,
|
||||
});
|
||||
|
||||
// ---
|
||||
|
||||
/// Converte l'oggetto Role in una mappa per la serializzazione JSON.
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'description': description,
|
||||
};
|
||||
}
|
||||
|
||||
/// Crea un oggetto Role da una mappa (es. da una risposta JSON).
|
||||
factory Role.fromJson(Map<String, dynamic> json) {
|
||||
return Role(
|
||||
id: json['id'] as int,
|
||||
name: json['name'] as String,
|
||||
description: json['description'] as String,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user