Created
August 27, 2020 13:09
-
-
Save roipeker/b340647a7132e2d0606ee6437d8df819 to your computer and use it in GitHub Desktop.
Base UI utils for GetX (wip)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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