I want to dismiss SnackBar
on SnackBarAction
's onPressed
method. I tried with Navigator.of(context).pop();
but SnackBar
is not dismissing my screen get black instead.
Here is code:
void showInSnackBar(String value) {
homeScaffoldKey.currentState.showSnackBar(new SnackBar(content: new Text(value),
action: SnackBarAction(
label: 'Dissmiss',
textColor: Colors.yellow,
onPressed: () {
// Navigator.of(context).pop();
},
),));
}
Try using hideCurrentSnackBar
method
onPressed: () {
homeScaffoldKey.currentState.hideCurrentSnackBar();
},
More info here: https://docs.flutter.io/flutter/material/ScaffoldState/hideCurrentSnackBar.html