TipsDialog.dart 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import 'package:flutter/material.dart';
  2. class TipsDialog {
  3. static show(BuildContext context, String title, tips) async {
  4. await showDialog<Null>(
  5. context: context,
  6. barrierDismissible: false,
  7. builder: (BuildContext context) {
  8. return AlertDialog(
  9. title: Text(title),
  10. content: SingleChildScrollView(
  11. child: ListBody(
  12. children: <Widget>[Text(tips)],
  13. ),
  14. ),
  15. actions: <Widget>[
  16. TextButton(
  17. child: Text('确定'),
  18. onPressed: () {
  19. Navigator.of(context).pop();
  20. },
  21. ),
  22. ],
  23. );
  24. },
  25. );
  26. }
  27. static wait(BuildContext context, String title, tips) async {
  28. await showDialog<Null>(
  29. context: context,
  30. barrierDismissible: false,
  31. builder: (BuildContext context) {
  32. return AlertDialog(
  33. title: Text(title),
  34. content: SingleChildScrollView(
  35. child: ListBody(
  36. children: <Widget>[Text(tips)],
  37. ),
  38. ),
  39. );
  40. },
  41. );
  42. }
  43. static showByChoose(
  44. BuildContext context, String title, tips, yes, no, Function f) async {
  45. await showDialog<Null>(
  46. context: context,
  47. barrierDismissible: false,
  48. builder: (BuildContext context) {
  49. return AlertDialog(
  50. title: Text(title),
  51. content: SingleChildScrollView(
  52. child: ListBody(
  53. children: <Widget>[Text(tips)],
  54. ),
  55. ),
  56. actions: <Widget>[
  57. TextButton(
  58. child: Text(no),
  59. onPressed: () {
  60. f(false);
  61. },
  62. ),
  63. TextButton(
  64. child: Text(yes),
  65. onPressed: () {
  66. f(true);
  67. },
  68. ),
  69. ],
  70. );
  71. },
  72. );
  73. }
  74. }