use method
Registers a plugin. The same class may be used more than once as long as the instances have distinct ids.
Implementation
void use(Plugin plugin) {
if (_plugins.any((p) => p.id == plugin.id)) {
throw StateError(
'Duplicate plugin id "${plugin.id}". Give one of them a distinct id.',
);
}
// Refused rather than merely discouraged: `fw:///worktrees/<x>/config` and
// `…/changes` are the shell's own screens, and a plugin able to take one of
// those addresses could hide the one place that explains why this file did
// not load.
if (Address.shellOwned.contains(plugin.id)) {
throw StateError(
'Plugin id "${plugin.id}" is reserved for one of the shell\'s own '
'screens. Give the plugin a dotted, globally unique id.',
);
}
if (_duplicatePackagePath(plugin.config) case var path?) {
throw StateError(_duplicatePackageMessage(plugin.id, path));
}
_plugins.add(plugin);
}