dialog.dart 887 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. class DialogController extends GetxController {
  4. var isDialogVisible = false.obs;
  5. void showErrorDialog() {
  6. isDialogVisible.value = true;
  7. }
  8. Future<bool?> showNormalDialog({
  9. required String title,
  10. String? content,
  11. Widget? child,
  12. required String cancelText,
  13. required String enterText,
  14. bool Function()? validator,
  15. }) {
  16. assert(content != null || child != null);
  17. return Get.dialog(
  18. AlertDialog(
  19. title: Text(title),
  20. content: child ?? Text(content!),
  21. actions: [
  22. TextButton(
  23. onPressed: () => Get.back(result: false),
  24. child: Text(cancelText),
  25. ),
  26. TextButton(
  27. onPressed: () => Get.back(result: true),
  28. child: Text(enterText),
  29. ),
  30. ],
  31. ),
  32. );
  33. }
  34. }