write method Null safety

  1. @override
void write(
  1. Map<String, dynamic> attributes

Sets all field keys and values in the specified attributes map. This method is called before the serialization.

Note: if you have complex fields such as nested objects, non generic lists or maps, you need to implement both Serializable and OnDemandSerializable, extend SerializableObject and implement OnDemandSerializable, or specify the corresponding transformers and objectCreators in the Serializer on demand methods.

Compare Serializer.serializeOnDemand() and Serializer.deserializeOnDemand() methods.

attributes['name'] = name;
attributes['price'] = price;


void write(Map<String, dynamic> attributes) {
  attributes['typeName'] = typeName;
  attributes['hostname'] = hostname;
  attributes['port'] = port;
  attributes['username'] = username;
  attributes['socketType'] = socketTypeName;
  attributes['authentication'] = authenticationName;
  attributes['authenticationAlternative'] = authenticationAlternativeName;