takeAction method
void
takeAction( - dynamic method
)
Implementation
void takeAction(method) {
// Run the R scripts. For different selected cleanup, the text will be
// different as well as the script to execute.
// For check special conditions:
// Delete Ignored but no variables Ignored.
if (method == 'Ignored' && getIgnored(ref).isEmpty) {
showOk(
context: context,
title: 'No Variables Selected to Ignore',
content: '''
To delete the Ignored variables you will first need to choose some
variables to Ignore from the **Dataset** tab **Role** page.
''',
);
} else
// All good.
{
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Row(
children: [
Icon(Icons.warning, color: Colors.red),
SizedBox(width: 20),
Text('Warning'),
],
),
content: Text(wordWrap(warning(method))),
actions: <Widget>[
// No button
TextButton(
style: TextButton.styleFrom(
textStyle: Theme.of(context).textTheme.labelLarge,
),
child: const Text('No'),
onPressed: () {
Navigator.of(context).pop();
},
),
// Yes button
TextButton(
style: TextButton.styleFrom(
textStyle: Theme.of(context).textTheme.labelLarge,
),
child: const Text('Yes'),
onPressed: () async {
Navigator.of(context).pop();
// has to use await here because if deletion happens before rsource, rsource won't delete anything in R.
await rSource(context, ref, [dispatch(method)]);
deletionAction(method);
ref.read(cleanupPageControllerProvider).animateToPage(
// Index of the second page.
1,
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
},
),
],
);
},
);
}
}