generateGetter method
Generates code that gets a representation of the type from an expression
representing an XmlElement
.
The representation of the type should be a String or XmlElement
that can be deserialized by a SerializerGenerator.
An implementation to get a representation of the type from the text of an XML element could be as simple as:
String generateGetter(String expression) => '$expression.getText()';
Implementation
@override
String generateGetter(String expression) {
final buffer = StringBuffer(super.generateGetter(expression));
if (_isNullable) {
buffer.write('?');
}
buffer.write('.map((e) => e.getText()).whereType<String>()');
return buffer.toString();
}