deletionAction method
void
deletionAction( - String method
)
Implementation
void deletionAction(String method) {
// cleanup the state after deletion
List<String> varsToDelete = [];
switch (method) {
case 'Ignored':
varsToDelete.addAll(getIgnored(ref));
// two ways to update: read it from the stdout glimpse or update it with the information
// choose 2
case 'Variable':
String select = ref.read(selectedProvider);
varsToDelete.add(select);
case 'Vars with Missing':
varsToDelete.addAll(getMissing(ref));
case 'Obs with Missing':
// variables won't be deleted so return directly.
return;
case 'Obs with Missing Target':
// variables won't be deleted so return directly.
return;
default:
showUnderConstruction(context);
}
for (var v in varsToDelete) {
if (deleteVar(ref, v)) {
// Remove the deleted variables from the meta data.
// We were finding that a deleted variable remained in the valiable list
// for IMPUTE, for example. This was because the variable remained in
// the meta data structure. Her we remove it from the meta data, but
// perhaps we need a DELETED role and add a role to every variable to
// replace the roles variable. (gjw 20250429)
// Get the current metadata, ensuring it's treated as Map<String,
// dynamic>, and create a mutable copy to avoid modifying the state
// directly. (zy 20250429)
final currentMetaData = ref.watch(metaDataProvider);
final newMetaData = Map<String, dynamic>.from(currentMetaData);
// Remove the variable's metadata.
newMetaData.remove(v);
// Update the provider's state with the new map.
ref.watch(metaDataProvider.notifier).state = newMetaData;
debugText(' DELETED', v);
}
}
}