bind<T> method
Binds URI parameters from the context to the instance.
If the instance is a Map, it iterates over the entries in context.params
and assigns the first value of each entry to the corresponding key in the instance.
If the entry value is empty, it assigns null to the key.
context - The engine context containing the parameters to bind.
instance - The instance to which the parameters will be bound.
Implementation
@override
Future<T> bind<T>(EngineContext context, T instance) async {
if (instance is Map) {
for (final entry in context.params.entries) {
final values = entry.value as List;
instance[entry.key] = values.isEmpty ? null : values.first;
}
} else if (instance is Bindable) {
final data = <String, dynamic>{};
for (final entry in context.params.entries) {
final values = entry.value as List;
data[entry.key] = values.isEmpty ? null : values.first;
}
instance.bind(data);
}
return instance;
}