showSnackBar static method

void showSnackBar(
  1. BuildContext context,
  2. String message, {
  3. Widget? icon,
  4. String? timestamp,
  5. String? senderName,
  6. Widget? action,
})

Implementation

static void showSnackBar(
  BuildContext context,
  String message, {
  Widget? icon,
  String? timestamp,
  String? senderName,
  Widget? action,
}) {
  ScaffoldMessenger.of(context).showSnackBar(
    SnackBar(
      backgroundColor: Colors.white,
      behavior: SnackBarBehavior.floating,
      content: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              icon ?? const SizedBox.shrink(),
              timestamp != null
                  ? Text(
                      timestamp,
                      style: TextStyle(
                        color: NGFTColors.typographyColor[500],
                        fontSize: 12,
                      ),
                    )
                  : const SizedBox.shrink()
            ],
          ),
          const SizedBox(height: 5),
          senderName != null
              ? Text(
                  senderName,
                  style: TextStyle(
                    color: NGFTColors.typographyColor[500],
                    fontSize: 12,
                    fontWeight: FontWeight.bold,
                  ),
                )
              : const SizedBox.shrink(),
          const SizedBox(height: 5),
          Row(
            children: [
              Expanded(
                child: Text(
                  message,
                  textAlign: TextAlign.justify,
                  style: TextStyle(
                    color: NGFTColors.typographyColor[500],
                    fontSize: 12,
                  ),
                ),
              ),
              const SizedBox(width: 10),
              action ?? const SizedBox.shrink(),
            ],
          )
        ],
      ),
      dismissDirection: DismissDirection.up,
      margin: EdgeInsets.only(
        bottom: MediaQuery.of(context).size.height - 250,
        left: 10,
        right: 10,
      ),
    ),
  );
}