dialog_util.dart 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/widgets.dart';
  3. import 'package:photos/ui/loading_widget.dart';
  4. import 'package:progress_dialog/progress_dialog.dart';
  5. ProgressDialog createProgressDialog(BuildContext context, String message) {
  6. final dialog = ProgressDialog(
  7. context,
  8. type: ProgressDialogType.Normal,
  9. isDismissible: false,
  10. );
  11. dialog.style(
  12. message: message,
  13. messageTextStyle: TextStyle(color: Colors.white),
  14. backgroundColor: Color.fromRGBO(25, 25, 25, 1.0),
  15. progressWidget: loadWidget,
  16. borderRadius: 4.0,
  17. elevation: 10.0,
  18. insetAnimCurve: Curves.easeInOut,
  19. );
  20. return dialog;
  21. }
  22. void showErrorDialog(BuildContext context, String title, String content) {
  23. AlertDialog alert = AlertDialog(
  24. title: Text(title),
  25. content: Text(content),
  26. actions: [
  27. FlatButton(
  28. child: Text("ok"),
  29. onPressed: () {
  30. Navigator.of(context, rootNavigator: true).pop('dialog');
  31. },
  32. ),
  33. ],
  34. );
  35. showDialog(
  36. context: context,
  37. builder: (BuildContext context) {
  38. return alert;
  39. },
  40. );
  41. }
  42. void showGenericErrorDialog(BuildContext context) {
  43. showErrorDialog(context, "something went wrong", "please try again.");
  44. }