ReplaceAll constructor

ReplaceAll()

Implementation

ReplaceAll()
  : super(
      methodName: "replaceAll",
      arity: 2,
      targetType: NativeMethodTarget.string,
      function: (target, _, args) {
        final arg = args[0];
        if (arg is! String) {
          throw RuntimeError("replaceAll() takes a string as an argument.");
        }
        final arg2 = args[1];
        if (arg2 is! String) {
          throw RuntimeError("replaceAll() takes a string as an argument.");
        }
        return target.replaceAll(arg, arg2);
      },
    );