dvHomeWidgetId function
The identifier for a generated widget class.
StepCounterWidget is step-counter. The trailing Widget goes because
every one of them has it and it says nothing.
Implementation
String dvHomeWidgetId(String className) {
final String bare = className.endsWith('Widget') && className.length > 6
? className.substring(0, className.length - 6)
: className;
final StringBuffer out = StringBuffer();
for (int i = 0; i < bare.length; i++) {
final String character = bare[i];
final String lower = character.toLowerCase();
if (character != lower && out.isNotEmpty) out.write('-');
out.write(lower);
}
return out.isEmpty ? 'widget' : out.toString();
}