addMethod method

WidgetPluginBuilder addMethod (
  1. WidgetBuilder builder,
  2. String type,
  3. {List<String> aliases}
)

Implementation

WidgetPluginBuilder addMethod(WidgetBuilder builder, String type,
    {List<String> aliases}) {
  assert(builder != null, "Builder must be provided");
  assert(!VoyagerUtils.isNullOrBlank(type),
      "Widget type might not be null or blank");
  assert(_builders[type] == null, "Type $type is already registered.");
  aliases?.forEach((alias) {
    assert(
        _builders[alias] == null, "Alias $alias for $type is already used.");
    _builders[alias] = builder;
  });
  _builders[type] = builder;
  return this;
}