toPluginClassName function consumer producer

String toPluginClassName(
  1. String pluginName, {
  2. bool postfixWithPlugin = false,
})

The plugin ClassName which is equal to the library name converted to camelcase + 'Plugin' postfix if postfixWithPlugin is set to true.

Example: Given pluginName 'super_awesome' will return SuperAwesomePlugin.

Example: Given pluginName 'super_awesome_plugin' will return SuperAwesomePlugin.

Implementation

String toPluginClassName(String pluginName, {bool postfixWithPlugin = false}) {
  final className = pluginName
      .split("_")
      .map((e) => "${e[0].toUpperCase()}${e.substring(1, e.length)}")
      .join();

  return postfixWithPlugin ? className.postfixedWithPlugin : className;
}