McpEvents class
Punto de entrada público del sistema mcpe2e.
Expone las operaciones del sistema como API simple sin que el llamador necesite conocer el Registry, Simulator o Executor internamente.
Uso típico en la app:
// 1. Registrar widgets antes de montarlos
McpEvents.instance.registerWidget(const McpMetadataKey(
id: 'auth.login_button',
widgetType: McpWidgetType.button,
description: 'Botón principal de login',
screen: 'LoginScreen',
));
// 2. Usar la key en el widget
ElevatedButton(
key: McpEvents.instance.getGlobalKey('auth.login_button'),
onPressed: _handleLogin,
child: const Text('Ingresar'),
)
// 3. Iniciar el servidor (en main() o en un initState de debug)
if (kDebugMode) await McpEventServer.start();
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
executeEvent(
{required String widgetKey, required McpEventType eventType, McpEventParams? params}) → Future< bool> -
Ejecuta el
eventTypesobre el widget identificado porwidgetKey. -
getAllWidgetIds(
) → List< String> - Lista los IDs de todos los widgets registrados.
-
getAllWidgets(
) → List< McpMetadataKey> - Lista la metadata de todos los widgets registrados.
-
getContext(
String id) → BuildContext? - Retorna el BuildContext del widget si está montado.
-
getGlobalKey(
String id) → GlobalKey< State< ?StatefulWidget> > - Retorna la GlobalKey para asignar al widget en el árbol.
-
getWidgetMetadata(
String id) → McpMetadataKey? - Retorna la metadata registrada para un widget.
-
isRegistered(
String id) → bool -
Retorna true si el widget con
idestá registrado. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerWidget(
McpMetadataKey key) → void - Registra un widget testable y crea su GlobalKey interna.
-
toJson(
{String? screen, String? route}) → Map< String, dynamic> - Genera el JSON de contexto consumido por el servidor MCP externo.
-
toString(
) → String -
A string representation of this object.
inherited
-
unregisterWidget(
String id) → void - Elimina un widget del registro.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited