✨ Desktop device name, close #7
This commit is contained in:
		| @@ -1,3 +1,6 @@ | ||||
| import 'dart:io'; | ||||
| import 'package:device_info_plus/device_info_plus.dart'; | ||||
| import 'package:easy_localization/easy_localization.dart'; | ||||
| import 'package:flutter_udid/flutter_udid.dart'; | ||||
|  | ||||
| String? _cachedUdid; | ||||
| @@ -9,3 +12,18 @@ Future<String> getUdid() async { | ||||
|   _cachedUdid = await FlutterUdid.consistentUdid; | ||||
|   return _cachedUdid!; | ||||
| } | ||||
|  | ||||
| Future<String> getDeviceName() async { | ||||
|   DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); | ||||
|   if (Platform.isAndroid) { | ||||
|     AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; | ||||
|     return androidInfo.device; | ||||
|   } else if (Platform.isIOS) { | ||||
|     IosDeviceInfo iosInfo = await deviceInfo.iosInfo; | ||||
|     return iosInfo.name; | ||||
|   } else if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) { | ||||
|     return Platform.localHostname; | ||||
|   } else { | ||||
|     return 'unknown'.tr(); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user