mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-24 12:40:45 +08:00
35 lines
926 B
Dart
35 lines
926 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class Utils {
|
|
static Future<void> showAlertDialog(BuildContext context, String msg) async {
|
|
return showDialog<void>(
|
|
context: context,
|
|
barrierDismissible: true, // user must tap button!
|
|
builder: (BuildContext context) {
|
|
return AlertDialog(
|
|
title: const Text('警告 ⚠️'),
|
|
content: SingleChildScrollView(
|
|
child: ListBody(
|
|
children: <Widget>[
|
|
Text(msg),
|
|
],
|
|
),
|
|
),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
child: const Text('确定'),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
static showSnakeBar(BuildContext context, String msg) {
|
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(msg)));
|
|
}
|
|
}
|