showMessage static method

dynamic showMessage(
  1. BuildContext context,
  2. MessageType messageType,
  3. String content, {
  4. TextStyle textStyle = const TextStyle(fontSize: 14, color: Colors.white),
  5. double marginBottom = 12,
  6. int durationMilliseconds = 2500,
  7. Color? backgroundColor,
  8. Icon? leftIcon,
})

Implementation

static showMessage(
    BuildContext context, MessageType messageType, String content,
    {TextStyle textStyle=const TextStyle(fontSize: 14, color: Colors.white),
    double marginBottom = 12,
    int durationMilliseconds = 2500,
    Color ?backgroundColor,
    Icon ? leftIcon
    }) {

  ScaffoldMessenger.of(context).showSnackBar(SnackBar(
    margin: EdgeInsets.fromLTRB(12, 0, 12, marginBottom),
    behavior: SnackBarBehavior.floating,
    duration: Duration(milliseconds: durationMilliseconds),
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(4),
    ),
    elevation: 2,
    backgroundColor: backgroundColor??getColor(messageType),
    content: Container(
      child: Row(
        children: <Widget>[
          leftIcon??Icon(
            getIcon(messageType),
            color: Colors.white,
          ),
          SizedBox(
            width: 12,
          ),
          Text(content, style: textStyle)
        ],
      ),
    ),
  ));
}