memberGet method

  1. @override
dynamic memberGet(
  1. String id, {
  2. String? from,
  3. bool isRecursive = false,
  4. bool ignoreUndefined = false,
})
override

Fetch a member by the id, in the form of

object.id

id must be of String type.

Implementation

@override
dynamic memberGet(String id,
    {String? from, bool isRecursive = false, bool ignoreUndefined = false}) {
  switch (id) {
    case 'crypto.randomUUID':
      return ({positionalArgs, namedArgs}) {
        return randomUUID();
      };
    case 'crypto.randomUID':
      return ({positionalArgs, namedArgs}) {
        return randomUID(
          length: namedArgs['length'],
          withTime: namedArgs['withTime'],
        );
      };
    case 'crypto.randomNID':
      return ({positionalArgs, namedArgs}) {
        return randomNID(
          length: namedArgs['length'],
          withTime: namedArgs['withTime'],
        );
      };
    case 'crypto.crcString':
      return ({positionalArgs, namedArgs}) {
        String data = positionalArgs[0];
        int crc = positionalArgs[1] ?? 0;
        return crcString(data, crc);
      };
    case 'crypto.crcInt':
      return ({positionalArgs, namedArgs}) {
        String data = positionalArgs[0];
        int crc = positionalArgs[1] ?? 0;
        return crcInt(data, crc);
      };
    default:
      if (!ignoreUndefined) throw HTError.undefined(id);
  }
}