Skip to content

Commit

Permalink
improve: Make runSession async
Browse files Browse the repository at this point in the history
Necessary when calling runSession outside a button press, e.g.,
runEMATasks
  • Loading branch information
mario-bermonti committed Apr 26, 2024
1 parent 19ff4b5 commit 6b60d4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/src/services/run_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:mdigit_span_tasks_ema/src/services/data_processor.dart';
/// Run a data collection session
/// Running a session includes configuring everything needed and running a
/// cognitive task specified with [taskRunner].
void runSession(
Future<void> runSession(
{required Function({
required String participantID,
required String sessionID,
Expand Down
12 changes: 8 additions & 4 deletions lib/src/task_list/view/task_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ class DSBButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () => runSession(
taskRunner: runDigitSpanBackwards, taskName: 'ds_backwards'),
onPressed: () async {
await runSession(
taskRunner: runDigitSpanBackwards, taskName: 'ds_backwards');
},
child: Text(
'Digit Span Backwards',
style: Theme.of(context).textTheme.titleLarge,
Expand All @@ -29,8 +31,10 @@ class DSFButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () =>
runSession(taskRunner: runDigitSpanForward, taskName: 'ds_forward'),
onPressed: () async {
await runSession(
taskRunner: runDigitSpanForward, taskName: 'ds_forward');
},
child: Text(
'Digit Span Forward',
style: Theme.of(context).textTheme.titleLarge,
Expand Down

0 comments on commit 6b60d4c

Please sign in to comment.