Skip to content

Instantly share code, notes, and snippets.

@roipeker
Created August 27, 2020 13:09
Show Gist options
  • Save roipeker/b340647a7132e2d0606ee6437d8df819 to your computer and use it in GitHub Desktop.
Save roipeker/b340647a7132e2d0606ee6437d8df819 to your computer and use it in GitHub Desktop.
Base UI utils for GetX (wip)
class AppGetUtils {
static bool isPreloading = false;
static Future<void> hidePreloader() async {
if (!isPreloading) return;
isPreloading = false;
if (!Get.isSnackbarOpen) {
Get.close(1);
}
}
static Future<void> showPreloader() async {
if (isPreloading) return;
isPreloading = true;
Get.dialog(Center(child: LoadCircular()), barrierDismissible: false);
}
static void showError(String errors, {String title = 'Error:'}) {
if (isPreloading && Get.isDialogOpen) {
Get.back(closeOverlays: true);
}
Get.snackbar(
title,
errors,
colorText: Colors.white,
borderRadius: 8,
backgroundColor: Colors.red.shade800,
icon: Icon(
Icons.error,
color: Colors.white,
),
overlayColor: Colors.black54,
overlayBlur: .1,
snackStyle: SnackStyle.FLOATING,
snackPosition: SnackPosition.TOP,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment