helpers_view_model.dart 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import 'package:flutter/material.dart';
  2. class HelpersViewModel {
  3. static Future<void> dialog(
  4. int buttons,
  5. Widget widget,
  6. String content,
  7. BuildContext context,
  8. String textBtn1,
  9. String textBtn2,
  10. Function callback,
  11. Function callback2
  12. ) async {
  13. return showDialog<void>(
  14. context: context,
  15. builder: (BuildContext context) {
  16. return AlertDialog(
  17. title: widget,
  18. content: Text(content),
  19. actions: <Widget>[
  20. TextButton(
  21. child: Text(textBtn1, style: TextStyle(color: Colors.black)),
  22. onPressed: () {
  23. Navigator.of(context).pop();
  24. callback();
  25. },
  26. ),
  27. if(buttons == 2)
  28. TextButton(
  29. child: Text(textBtn2, style: TextStyle(color: Colors.black)),
  30. onPressed: () {
  31. Navigator.of(context).pop();
  32. callback2();
  33. },
  34. ),
  35. ],
  36. );
  37. },
  38. );
  39. }
  40. }