2021-03-12 19:52:26 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
/// Simple alert dialog
|
|
|
|
///
|
|
|
|
/// @author Pierre Hubert
|
|
|
|
|
2022-03-10 18:39:57 +00:00
|
|
|
Future<void> alert(BuildContext context, String? msg) async {
|
|
|
|
await showDialog(context: context, builder: (c) => _AlertDialog(msg: msg!));
|
2021-03-12 19:52:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class _AlertDialog extends StatelessWidget {
|
|
|
|
final String msg;
|
|
|
|
|
2022-03-10 18:39:57 +00:00
|
|
|
const _AlertDialog({Key? key, required this.msg})
|
2021-03-12 19:52:26 +00:00
|
|
|
: assert(msg != null),
|
|
|
|
super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return AlertDialog(
|
|
|
|
content: Text(msg),
|
|
|
|
actions: <Widget>[
|
|
|
|
MaterialButton(
|
|
|
|
child: Text("OK"),
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|