dialog_utils.dart 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import 'package:flutter/material.dart';
  2. import 'confirm_dialog.dart';
  3. class DialogUtils {
  4. static showCommonDialog(BuildContext parentContext,
  5. {String positiveMsg = '',
  6. String negativeMsg = '',
  7. Function onDone,
  8. Function onCancel,
  9. String msg = ''}) {
  10. showDialog(
  11. context: parentContext,
  12. builder: (context) {
  13. return showCustomCommonDialog(parentContext, context,
  14. positiveMsg: positiveMsg,
  15. negativeMsg: negativeMsg,
  16. onDone: onDone,
  17. onCancel: onCancel,
  18. msg: msg);
  19. }).then((result) {});
  20. }
  21. static Widget showCustomCommonDialog(
  22. BuildContext parentContext, BuildContext context,
  23. {String positiveMsg = '',
  24. String negativeMsg = '',
  25. Function onDone,
  26. Function onCancel,
  27. String msg = ''}) {
  28. ConfirmDialog messageDialog = new ConfirmDialog(
  29. title: "",
  30. message: msg,
  31. positiveText: positiveMsg,
  32. negativeText: negativeMsg,
  33. onPositivePressEvent: (str) {
  34. if (onDone != null) {
  35. onDone();
  36. }
  37. Navigator.pop(context);
  38. },
  39. onCloseEvent: () {
  40. if (onCancel != null) {
  41. onCancel();
  42. }
  43. Navigator.pop(context);
  44. },
  45. minHeight: 70,
  46. );
  47. return messageDialog;
  48. }
  49. }