$getProperty method

  1. @override
$Value? $getProperty(
  1. Runtime runtime,
  2. String identifier
)

Get a property by identifier on this instance

Implementation

@override
$Value? $getProperty(Runtime runtime, String identifier) {
  switch (identifier) {
    case 'a':
      return $double($value.a);
    case 'r':
      return $double($value.r);
    case 'g':
      return $double($value.g);
    case 'b':
      return $double($value.b);
    case 'colorSpace':
      return $ColorSpace.wrap($value.colorSpace);
    case 'toARGB32':
      return $Function((runtime, target, args) {
        return $int((target!.$value as Color).toARGB32());
      });
    case 'withValues':
      return $Function((runtime, target, args) {
        final result = (target!.$value as Color).withValues(
          alpha: args[0]?.$value,
          red: args[1]?.$value,
          green: args[2]?.$value,
          blue: args[3]?.$value,
          colorSpace: args[4]?.$value,
        );
        return $Color.wrap(result);
      });
    case 'withAlpha':
      return $Function((runtime, target, args) {
        final result = (target!.$value as Color).withAlpha(args[0]!.$value);
        return $Color.wrap(result);
      });
    case 'withRed':
      return $Function((runtime, target, args) {
        final result = (target!.$value as Color).withRed(args[0]!.$value);
        return $Color.wrap(result);
      });
    case 'withGreen':
      return $Function((runtime, target, args) {
        final result = (target!.$value as Color).withGreen(args[0]!.$value);
        return $Color.wrap(result);
      });
    case 'withBlue':
      return $Function((runtime, target, args) {
        final result = (target!.$value as Color).withBlue(args[0]!.$value);
        return $Color.wrap(result);
      });
    case 'computeLuminance':
      return $Function((runtime, target, args) {
        return $double((target!.$value as Color).computeLuminance());
      });
  }
  throw UnimplementedError();
}