didUpdateIntent method

  1. @mustCallSuper
  2. @override
void didUpdateIntent({
  1. CorallineTerminalIntent? oldIntent,
  2. CorallineTerminalIntent? newIntent,
})
override

Intercepts incoming terminal intents to extract and couple the BuildContext provider.

  • oldIntent: The previously active intent, if any.
  • newIntent: The new intent being applied to the terminal.

Ensures:

  • If newIntent is a CoralWidgetTerminalIntent, its provider's coral is coupled.
  • Otherwise, the internal context coupler is decoupled.

Implementation

@mustCallSuper
@override
void didUpdateIntent({
  CorallineTerminalIntent? oldIntent,
  CorallineTerminalIntent? newIntent,
}) {
  try {
    super.didUpdateIntent(oldIntent: oldIntent, newIntent: newIntent);
  } catch (error, stackTrace) {
    Zone.current.handleUncaughtError(error, stackTrace);
  }

  final finalOldIntent =
      oldIntent is CoralWidgetTerminalIntent ? oldIntent : null;
  final finalNewIntent =
      newIntent is CoralWidgetTerminalIntent ? newIntent : null;

  if (finalNewIntent != null) {
    _contextCoupler.couple(finalNewIntent.contextProvider.coral);
  } else {
    _contextCoupler.decouple();
  }

  if (!identical(finalOldIntent?._context, finalNewIntent?._context)) {
    didUpdateBuildContext(finalOldIntent?._context, finalNewIntent?._context);
  }
}