operator_annotation 0.0.1 operator_annotation: ^0.0.1 copied to clipboard
Annotations for the operator code-generator. This package does nothing without operator too.
- Usage
import 'package:operator_annotation/operator_annotation.dart';
part 'test.operator.dart';
@operator
class A {
final int a;
A(this.a);
}
//////
part of 'test.dart';
extension AX on A {
dynamic operator [](String prop) {
final func = map[prop];
if (func == null) {
throw ArgumentError('Property `$prop` does not exist on ItemClass.');
}
return func.call(this);
}
static Map<String, Function(A)> map = {'a': (A ins) => ins.a};
}