showSnackBar static method

void showSnackBar(
  1. BuildContext context,
  2. String message, {
  3. LokotroPayResultScreen type = LokotroPayResultScreen.infoScreen,
  4. Duration duration = const Duration(seconds: 3),
})

Show snackbar with Lokotro styling

Implementation

static void showSnackBar(
  BuildContext context,
  String message, {
  LokotroPayResultScreen type = LokotroPayResultScreen.infoScreen,
  Duration duration = const Duration(seconds: 3),
}) {
  Color backgroundColor;
  Color textColor = LokotroPayColors.white;
  IconData icon;

  switch (type) {
    case LokotroPayResultScreen.successScreen:
      backgroundColor = LokotroPayColors.success;
      icon = Icons.check_circle;
      break;
    case LokotroPayResultScreen.errorScreen:
      backgroundColor = LokotroPayColors.error;
      icon = Icons.error;
      break;
    case LokotroPayResultScreen.warningScreen:
      backgroundColor = LokotroPayColors.warning;
      icon = Icons.warning;
      break;
    case LokotroPayResultScreen.infoScreen:
      backgroundColor = LokotroPayColors.info;
      icon = Icons.info;
      break;
  }

  ScaffoldMessenger.of(context).showSnackBar(
    SnackBar(
      content: Row(
        children: [
          Icon(icon, color: textColor, size: 20),
          const SizedBox(width: 12),
          Expanded(
            child: Text(
              message,
              style: TextStyle(
                color: textColor,
                fontSize: 14,
                fontWeight: FontWeight.w500,
              ),
            ),
          ),
        ],
      ),
      backgroundColor: backgroundColor,
      duration: duration,
      behavior: SnackBarBehavior.floating,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(12),
      ),
      margin: const EdgeInsets.all(16),
    ),
  );
}