In my app I would like to show a bottom sheet with showModalBottomSheet
to let the user pick a font. When a new font is selected I would like to reflect the changes immediately in the parent view that is presenting the sheet without closing the sheet.
With Navigator.pop(context, value);
I can easily send data back to the parent but I don't wanna close the bottom sheet on every selection.
Is there any way to achieve this behavior?
This it my current code to show and hide the picker modal:
In the parent view.
void showFontPicker() {
showModalBottomSheet(
context: context,
isScrollControlled: true,
isDismissible: true,
builder: (context) => FontPickerSheet()).then((value) {
setState(() {
widget.myPostcard.font = value;
});
});
}
In the FontPickerSheet Widget:
CupertinoPicker(
itemExtent: 30,
onSelectedItemChanged: (int value) {
Navigator.pop(context, value);
},
…