What is missing is that you need to return the value when closing the dialog, like this:
return AlertDialog(
title: Slider(
value: value,
min: 0,
max: 100,
onChanged: (va) {
setState(() {
value = va;
});
},
),
actions: [
ElevatedButton(
onPressed: () => Navigator.pop(context),
child: Text('cancel')),
ElevatedButton(
onPressed: () => Navigator.pop(context, value),
child: Text('confirm')),
],
);
It will then be returned by the showDialog function as expected as a Future