showSnackBar method

void showSnackBar(
  1. BuildContext context, {
  2. Duration duration = const Duration(milliseconds: 500),
  3. TextStyle? style,
  4. Color? backgroundColor,
  5. TextDirection? direction,
})

Implementation

void showSnackBar(
  BuildContext context, {
  Duration duration = const Duration(milliseconds: 500),
  TextStyle? style,
  Color? backgroundColor,
  TextDirection? direction,
}) {
  try {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(
        backgroundColor: backgroundColor ?? Colors.white,
        content: Text(
          this,
          textDirection: direction,
          style: style ?? const TextStyle(color: Colors.white),
        ),
        duration: duration,
      ),
    );
  } catch (e) {
    Logger('SnackBar').severe(e);
  }
}