register method
Implementation
void register(DigiaCEPPlugin plugin) {
if (!_initialized) {
_log.e('register() ignored — called before initialize(). Call '
'Digia.initialize() first');
}
final previous = _activePlugin;
if (previous != null) {
// G6, and the order matters: everything the outgoing plugin owns settles
// *first*, so its own outcome handlers run and hand its slot back while
// its bridge is still alive. Only then does it tear down. Reversing these
// two lines is exactly the leak this redesign exists to remove.
_coordinator.detach(previous.id);
previous.detach();
}
_activePlugin = plugin;
plugin.attach(this);
_log.i('Plugin registered (plugin=${plugin.id})',
stage: TimelineStage.session,
reason: TimelineReason.pluginRegistered,
extras: {'plugin': plugin.id});
// A plugin that attaches after FAILED must stop buffering too.
if (_sdkState == SDKState.failed) {
_notifyPlugin('onHostInitFailed', (plugin) => plugin.onHostInitFailed());
}
}