| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import 'package:flutter/material.dart';
- import 'package:fluttertoast/fluttertoast.dart';
- class TipsDialog {
- static Future<void> show(
- BuildContext context,
- String title,
- String tips,
- ) {
- return showDialog<void>(
- context: context,
- barrierDismissible: false,
- builder: (context) {
- return AlertDialog(
- title: Text(title),
- content: SingleChildScrollView(
- child: ListBody(children: [Text(tips)]),
- ),
- actions: [
- TextButton(
- child: const Text('确定'),
- onPressed: () => Navigator.of(context).pop(),
- ),
- ],
- );
- },
- );
- }
- static Future<bool?> showByChoose(
- BuildContext context,
- String title,
- String tips,
- String yes,
- String no,
- ) {
- return showDialog<bool>(
- context: context,
- barrierDismissible: false,
- builder: (context) {
- return AlertDialog(
- title: Text(title),
- content: SingleChildScrollView(
- child: ListBody(children: [Text(tips)]),
- ),
- actions: [
- TextButton(
- child: Text(no),
- onPressed: () => Navigator.of(context).pop(false),
- ),
- TextButton(
- child: Text(yes),
- onPressed: () => Navigator.of(context).pop(true),
- ),
- ],
- );
- },
- );
- }
- static void toast(String message) {
- Fluttertoast.showToast(msg: message, gravity: ToastGravity.CENTER);
- }
- }
|