bind<T> method

  1. @override
Future<T> bind<T>(
  1. EngineContext context,
  2. T instance
)
override

Binds the query parameters from the context to the provided instance.

This method takes the query parameters stored in the EngineContext's query cache and binds them to the provided instance if it is a Map.

  • Parameters:
    • context: The EngineContext containing the query parameters to bind.
    • instance: The instance to which the query parameters will be bound.

Implementation

@override
Future<T> bind<T>(EngineContext context, T instance) async {
  // Check if the instance is a Map.
  if (instance is Map) {
    // Iterate over the entries in the context's query cache.
    for (final entry in context.queryCache.entries) {
      // Bind each query parameter to the instance.
      instance[entry.key] = entry.value;
    }
  } else if (instance is Bindable) {
    instance.bind(context.queryCache);
  }
  return instance;
}