genderToJson function
Converts a Gender enumeration to a JSON string representation.
This function takes a Gender
enumeration as input and converts it to a JSON
string representation. If the input Gender
is null, the function returns
the JSON string representation of the default gender Gender.unknown
. Otherwise,
it returns the JSON string representation of the input gender's name
property.
@param gender The Gender enumeration to convert to a JSON string. @return A JSON string representation of the input Gender enumeration.
Implementation
String genderToJson(Gender? gender) {
return (gender?.name ?? Gender.unknown.name).toLowerCase();
}