mobile_skt/lib/util/device.util.dart

43 lines
937 B
Dart
Raw Normal View History

2024-04-07 17:32:46 +08:00
import 'dart:io';
import 'package:package_info/package_info.dart';
2024-04-09 08:31:17 +08:00
import 'package:url_launcher/url_launcher.dart';
2024-04-07 17:32:46 +08:00
class DeviceUtil {
2024-04-09 08:31:17 +08:00
///发邮件
static void sendEmail(String email) {
if (email.isNotEmpty) {
String url = 'mailto:$email';
launchUrl(Uri.parse(url));
}
}
///打电话
static void callPhone(String phone) {
if (phone.isNotEmpty) {
String url = 'tel:$phone';
if (Platform.isIOS) {
url = 'tel://$phone';
}
if (Platform.isAndroid) {
url = 'tel:$phone';
}
launchUrl(Uri.parse(url));
}
}
2024-04-07 17:32:46 +08:00
/// 获取当前版本
static Future<String> getAppVersion() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
return packageInfo.version;
}
/// 获取平台信息
static Future<String> getPlatForm() async {
if (Platform.isAndroid) {
return 'android';
} else {
return 'ios';
}
}
}