getInterfaceType method
Returns the expression to use for the Dart abstract interface type.
Implementation
String getInterfaceType() {
if (!baseType.useInterfaceType) {
return getDartType();
}
final String optional = isNullableOptional ? '?' : '';
if (baseType.isTimestamp && parent.fileGen!.useBetterProtos) {
return '$coreImportPrefix.DateTime$optional';
} else if (baseType.isDuration && parent.fileGen!.useBetterProtos) {
return '$coreImportPrefix.Duration$optional';
}
if (isMapField) {
final d = baseType.generator as MessageGenerator;
final keyType =
d._fieldList[0].baseType.getInterfaceType(parent.fileGen!);
final valueType =
d._fieldList[1].baseType.getInterfaceType(parent.fileGen!);
return '$coreImportPrefix.Map<$keyType, $valueType>$optional';
}
if (isRepeated) {
return baseType.getRepeatedInterfaceType(parent.fileGen!) + optional;
}
return baseType.getInterfaceType(parent.fileGen!) + optional;
}