getTitle method
Returns the packaging title from the controllers, or null if empty.
Implementation
String? getTitle() {
final List<String> result = <String>[];
void addIfNotEmpty(String text) {
if (text.isNotEmpty) {
result.add('$text ');
}
}
if (controllerUnits.text.isNotEmpty) {
result.add('${controllerUnits.text} x ');
}
addIfNotEmpty(controllerShape.text);
addIfNotEmpty(controllerQuantity.text);
if (controllerMaterial.text.isNotEmpty) {
if (controllerWeight.text.isNotEmpty) {
result.add('(${controllerMaterial.text}: ${controllerWeight.text}g)');
} else {
result.add('(${controllerMaterial.text})');
}
} else if (controllerWeight.text.isNotEmpty) {
result.add('(${controllerWeight.text}g)');
}
if (result.isEmpty) {
return null;
}
return result.join('');
}