48 lines
1.1 KiB
Dart
48 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
enum SnackbarType { success, error, warning, info }
|
|
|
|
void showAppSnackbar({
|
|
required String title,
|
|
required String message,
|
|
SnackbarType type = SnackbarType.info,
|
|
}) {
|
|
Color backgroundColor;
|
|
IconData iconData;
|
|
|
|
switch (type) {
|
|
case SnackbarType.success:
|
|
backgroundColor = Colors.green;
|
|
iconData = Icons.check_circle;
|
|
break;
|
|
case SnackbarType.error:
|
|
backgroundColor = Colors.red;
|
|
iconData = Icons.error;
|
|
break;
|
|
case SnackbarType.warning:
|
|
backgroundColor = Colors.orange;
|
|
iconData = Icons.warning;
|
|
break;
|
|
case SnackbarType.info:
|
|
backgroundColor = Colors.blue;
|
|
iconData = Icons.info;
|
|
break;
|
|
}
|
|
|
|
Get.snackbar(
|
|
title,
|
|
message,
|
|
backgroundColor: backgroundColor,
|
|
colorText: Colors.white,
|
|
snackPosition: SnackPosition.BOTTOM,
|
|
margin: const EdgeInsets.all(16),
|
|
borderRadius: 8,
|
|
duration: const Duration(minutes: 1),
|
|
icon: Icon(
|
|
iconData,
|
|
color: Colors.white,
|
|
),
|
|
);
|
|
}
|