Flutter onClosing callback for showModalBottomSheet
Perhaps it's not the best solution, but showModalBottomSheet return a "Future" so you can used it.
For example:
void _showModal() {
Future<void> future = showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return Container(height: 260.0, child: Text('I am text'));
},
);
future.then((void value) => _closeModal(value));
}
void _closeModal(void value) {
print('modal closed');
}
You can also achieve it by use of whenComplete
function of showModalBottomSheet
.
Let's see below code
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return Container(
height: 260.0,
child: Text('I am text')
);
},
).whenComplete(() {
print('Hey there, I\'m calling after hide bottomSheet');
});