push<T> method

  1. @nonVirtual
Future<T> push<T>(
  1. Widget widget
)
inherited

Adds a widget to the module's internal navigation stack.

Returns a Future that completes when the widget is popped from the stack. This enables request-response patterns within modules.

Example:

final result = await push<String>(EditProfilePage());
if (result == 'saved') {
  // Handle successful save
}

Parameters:

  • widget - The widget to push onto the stack
  • metadata - Optional metadata associated with this route

Returns: A Future that completes with the result when popped

Throws:

  • ModuleException if the module is disposed

Implementation

@nonVirtual
Future<T> push<T>(Widget widget) {
  final entry = InternalRoute(Completer<T>(), widget);
  _stack.add(entry);
  logger.info('$name PUSH ${_stack.length}', ['router']);
  events.emit<String>(['router', 'push'].join(Events.sep), '');
  return entry.completer.future;
}