Files
cashier_reserve_app/lib/common/utils/utils.dart
2024-11-25 14:11:57 +08:00

47 lines
1.3 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'func_tools.dart';
class Utils {
///大陆手机号码11位数匹配格式前三位固定格式+后8位任意数
static bool isPhone(String phone) {
return RegExp('^1\\d{10}\$').hasMatch(phone);
}
static void toast(String? text, BuildContext? context) {
if (isEmptyString(text)) {
return;
}
Fluttertoast.showToast(
msg: "$text",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
// backgroundColor: Colors.red,
// textColor: Colors.white,
fontSize: 16.0);
}
static Future alert(BuildContext context, String? content, {String? title}) {
return showCupertinoDialog(
context: context,
builder: (BuildContext context) {
return CupertinoAlertDialog(
title: Text(title ?? '提示'),
content: Text(content!),
actions: <Widget>[
TextButton(
child: const Text('确定'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
});
}
}