validateFeatureInLine method

bool validateFeatureInLine(
  1. String line,
  2. double percent,
  3. bool validate(
    1. String
    )
)

takes a String (line) which is a line and contains a list of Strings joined with space and each one of them much validate. if most of them returned true then the function must return true

Implementation

bool validateFeatureInLine(
    String line, double percent, bool Function(String) validate) {
  int truth = 0;
  int all = 0;
  List<String> elements = line.trim().split(' ');
  for (String e in elements) {
    all++;
    if (validate(e)) truth++;
  }
  // print("truth: ${truth}");
  // print("all: ${all}");
  // print("Percent: ${truth / all * 100}");
  return truth / all * 100 > percent;
}