-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathinternal_info_service.dart
45 lines (37 loc) · 1.59 KB
/
internal_info_service.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Dart imports:
import 'dart:io';
// Package imports:
import 'package:device_info_plus/device_info_plus.dart';
import 'package:package_info_plus/package_info_plus.dart';
// Project imports:
import 'package:notredame/features/app/integration/networking_service.dart';
import 'package:notredame/utils/locator.dart';
// UTILS
// SERVICES
class InternalInfoService {
// Build the error message with the current device informations
Future<String> getDeviceInfoForErrorReporting() async {
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
final NetworkingService networkingService = locator<NetworkingService>();
final DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
String? deviceName;
if (Platform.isAndroid) {
final AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
deviceName = androidInfo.model;
} else if (Platform.isIOS) {
final IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
deviceName = iosInfo.utsname.machine;
}
return "**Device Infos** \n"
"- **Device:** ${deviceName ?? 'Not Provided'} \n"
"- **Version:** ${packageInfo.version} \n"
"- **Connectivity:** ${await networkingService.getConnectionType()} \n"
"- **Build number:** ${packageInfo.buildNumber} \n"
"- **Platform operating system:** ${Platform.operatingSystem} \n"
"- **Platform operating system version:** ${Platform.operatingSystemVersion} \n";
}
/// Get the current device informations to show for error reporting
Future<PackageInfo> getPackageInfo() async {
return PackageInfo.fromPlatform();
}
}