toMap method
Converts the object into a map that can be used in database operations.
The map will contain the user's name and hashed password. If the ID is not null and not 0,
it will also be included in the map. This allows for the auto-increment functionality in databases
that do not require the ID to be manually set.
Returns a Map<String, dynamic> representing the user.
Implementation
Map<String, dynamic> toMap() {
Map<String, dynamic> map = {
'name': name,
'hashedPassword': hashedPassword,
};
// Include ID only if it is set (non-null and non-zero).
if (ID != null && ID != 0) {
map['ID'] = ID;
}
return map;
}