buildArgument<T> method

T buildArgument<T>(
  1. String name,
  2. (T, String?) builder(
    1. double
    ), {
  3. bool replaceDouble = false,
})

Implementation

T buildArgument<T>(
  String name,
  (T, String?) Function(double) builder, {
  bool replaceDouble = false,
}) {
  double num = 0;
  late T t;
  String? str;
  do {
    num = (Random().nextDouble() * 2 - 1) * double.maxFinite / 2;
    (t, str) = builder(num);
  } while (macros.containsKey(str ?? t.toString()) ||
      macros.containsKey(num.toString()));

  macros[str ?? t.toString()] = name;
  macros[num.toString()] = replaceDouble ? name : null;
  return t;
}