getMissing function

List<String> getMissing(
  1. WidgetRef ref
)

Implementation

List<String> getMissing(WidgetRef ref) {
  // // The rolesProvider lists the roles for the different variables which we
  // // need to know for parsing the R scripts.

  // Map<String, String> roles = ref.read(rolesProvider);

  // // Extract the input variable from the rolesProvider.

  // List<String> vars = [];
  // roles.forEach((key, value) {
  //   if (value == 'Input' || value == 'Risk' || value == 'Target') {
  //     vars.add(key);
  //   }
  // });

  // ONLY INCLUDE THOSE WITH MISSING VALUES.

  Map metaData = ref.read(metaDataProvider.notifier).state;
  Map roles = ref.read(rolesProvider.notifier).state;

  List<String> variables = [];

  metaData.forEach((key, value) {
    if (value is Map && value.containsKey('missing')) {
      List missing = value['missing'];
      if (missing.isNotEmpty && missing[0] > 0) {
        variables.add(key);
      }
    }
  });

  // Filter the variables list to only include those present in the roles map.

  variables.retainWhere((variable) => roles.containsKey(variable));

  return variables;
}