getSnackToast static method

dynamic getSnackToast(
  1. dynamic context, {
  2. dynamic title = "Error",
  3. dynamic message = '',
  4. dynamic snackPosition = SnackPosition.TOP,
  5. dynamic backgroundColor = Colors.black,
  6. dynamic colorText = Colors.white,
  7. Widget? icon,
  8. Duration? duration,
  9. Function? onTapSnackBar,
  10. Function? onTapButton,
  11. bool withButton = false,
  12. dynamic buttonText = 'Ok',
  13. Function? onDismissed,
})

Implementation

static getSnackToast(
  context, {
  title = "Error",
  message = '',
  snackPosition = SnackPosition.TOP,
  backgroundColor = Colors.black,
  colorText = Colors.white,
  Widget? icon,
  Duration? duration,
  Function? onTapSnackBar,
  Function? onTapButton,
  bool withButton = false,
  buttonText = 'Ok',
  Function? onDismissed,
}) {
  final snackBar = SnackBar(
    content: Text(message),
    duration: const Duration(milliseconds: 700),
    backgroundColor: backgroundColor,
    action: SnackBarAction(
      label: title,
      onPressed: () {
        // Some code to undo the change.
      },
    ),
  );
  // Find the ScaffoldMessenger in the widget tree
  // and use it to show a SnackBar.
  ScaffoldMessenger.of(context).showSnackBar(snackBar);
}