getDeviceContext method
Returns device/OS context for Dart-level crashes.
Implementation
@override
Future<Map<String, dynamic>?> getDeviceContext() async {
try {
final raw = await methodChannel.invokeMethod<Map<dynamic, dynamic>>(
'getDeviceContext',
);
if (raw == null) {
return _fallbackDeviceContext(source: 'native-null-fallback');
}
return raw.map((key, value) => MapEntry(key.toString(), value));
} on MissingPluginException catch (error) {
debugPrint(
'[AppSentrik] getDeviceContext native method missing; using fallback: $error',
);
return _fallbackDeviceContext(
source: 'missing-plugin-fallback',
error: error.toString(),
);
} on PlatformException catch (error) {
debugPrint(
'[AppSentrik] getDeviceContext platform error; using fallback: $error',
);
return _fallbackDeviceContext(
source: 'platform-exception-fallback',
error: error.toString(),
);
} catch (error) {
debugPrint(
'[AppSentrik] getDeviceContext failed; using fallback: $error',
);
return _fallbackDeviceContext(
source: 'dart-exception-fallback',
error: error.toString(),
);
}
}