Flutter snackbar dismiss on SnackBarAction onPressed
Try using hideCurrentSnackBar
method
onPressed: () {
homeScaffoldKey.currentState.hideCurrentSnackBar();
},
More info here: https://docs.flutter.io/flutter/material/ScaffoldState/hideCurrentSnackBar.html
You can also use,
Scaffold.of(context).hideCurrentSnackBar();
Be careful when you use context, use the correct context.
NOTE
In the new Flutter Version, this method is deprecated. Therefore use
ScaffoldMessenger.of(context).hideCurrentSnackBar();