apply method
dynamic
apply(])
override
Applies a function with controlled validation.
Parameters:
function
: The operation to performpositionalArguments
: Positional argsnamedArguments
: Named args
Returns:
Sync The result of the operation if validation passes
Async A Future
that resolves to the result of the operation
Implementation
@override
dynamic apply(Function function, List? positionalArguments, [Map<Symbol, dynamic>? namedArguments]) {
if (test.action(function, this, arguments: (positionalArguments: positionalArguments, namedArguments: namedArguments))) {
final notification = namedArguments?[#$notification] ?? true;
if (function == add) {
return Function.apply(_add, positionalArguments, {#notification: notification});
}
else if (function == addAll) {
return Function.apply(_addAll, positionalArguments, {#notification: notification});
}
else if (function == clear) {
return Function.apply(_clear, null, {#notification: notification});
}
else if (function == fillRange) {
return Function.apply(_fillRange, positionalArguments, {#fillValue: namedArguments![#fillValue], #notification: notification});
}
else if (function == insert) {
return Function.apply(_insert, positionalArguments, {#notification: notification});
}
else if (function == insertAll) {
return Function.apply(_insertAll, positionalArguments, {#notification: notification});
}
else if (function == remove) {
return Function.apply(_remove, positionalArguments, {#notification: notification});
}
else if (function == removeAt) {
return Function.apply(_removeAt, positionalArguments, {#notification: notification});
}
else if (function == removeLast) {
return Function.apply(_removeLast, positionalArguments, {#notification: notification});
}
else if (function == removeRange) {
return Function.apply(_removeRange, positionalArguments, {#notification: notification});
}
else if (function == replaceRange) {
return Function.apply(_replaceRange, positionalArguments, {#notification: notification});
}
else if (function == removeWhere) {
return Function.apply(_removeWhere, positionalArguments, {#notification: notification});
}
else if (function == retainWhere) {
return Function.apply(_retainWhere, positionalArguments, {#notification: notification});
}
else if (function == setAll) {
return Function.apply(_setAll, positionalArguments, {#notification: notification});
}
else if (function == setRange) {
return Function.apply(_setRange, positionalArguments, {#skipCount: namedArguments![#skipCount], #notification: notification});
}
else if (function == setFirst) {
return Function.apply(_setFirst, positionalArguments, {#skipCount: namedArguments![#skipCount], #notification: notification});
}
else if (function == setValueAt) {
return Function.apply(_setValueAt, positionalArguments, {#skipCount: namedArguments![#skipCount], #notification: notification});
}
else if (function == sort) {
if (test.action(sort, this, arguments: (positionalArguments: positionalArguments, namedArguments: namedArguments))) {
_properties.container.sort(positionalArguments!.first as int Function(E a, E b));
}
}
else if (function == shuffle) {
if (test.action(shuffle, this, arguments: (positionalArguments: positionalArguments, namedArguments: namedArguments))) {
_properties.container.shuffle(positionalArguments!.first as Random);
}
}
return Function.apply(function, positionalArguments, namedArguments);
}
}