returnPostData method
Implementation
Future<HashMap<String, String?>> returnPostData(Object exception, String stacktrace, Severity severity, CrashType crashType, Map<String, dynamic> customProperties) async
{
HashMap<String, String> decodedStack = _decodeStacktrace(stacktrace, crashType);
HashMap requestData = new HashMap<String, String?>();
String osVersion = "";
String apiVersion = "";
requestData["DeviceId"] = _deviceId;
if (!kIsWeb)
{
if (Platform.isAndroid) {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
String? version = androidInfo.version.release != null ? androidInfo.version.release : "";
osVersion = "Android " + version!;
apiVersion = androidInfo.version.sdkInt.toString();
}
else if (Platform.isIOS) {
osVersion = Platform.operatingSystem;
apiVersion = Platform.operatingSystemVersion;
}
else if (Platform.isWindows)
{
osVersion = "Windows";
apiVersion = Platform.operatingSystemVersion;
}
}
else
{
osVersion = "N/A";
final Browser browserDetails = Browser();
String browser = browserDetails.browser;
String? browserVersion = browserDetails.version;
requestData["Browser"] = browser;
requestData["BrowserVersion"] = browserVersion;
String height = MediaQuery.of(_context).size.height.toString();
String width = MediaQuery.of(_context).size.width.toString();
requestData["BrowserWidthHeight"] = width + " x " + height;
}
int width = MediaQuery
.of(_context)
.size
.width
.ceil();
int height = MediaQuery
.of(_context)
.size
.height
.ceil();
String defaultLocale = !kIsWeb ? Platform.localeName : "N/A";
if (exception is Exception)
{
Exception exceptionObj = exception;
requestData["ExceptionType"] = exceptionObj.runtimeType.toString();
requestData["ExceptionMessage"] = exceptionObj.toString();
}
else
{
FlutterErrorDetails exceptionObj = exception as FlutterErrorDetails;
requestData["ExceptionType"] = exceptionObj.exception.runtimeType.toString();
requestData["ExceptionMessage"] = exceptionObj.exception.toString();
}
requestData["DeviceID"] = _deviceId;
requestData["Stacktrace"] = stacktrace;
requestData["Severity"] = _getSeverityString(severity);
requestData["CrashType"] = crashType == CrashType.HANDLED ? "Handled" : "Unhandled";
requestData["DeviceType"] = "Flutter";
requestData["ProjectID"] = _projectId;
requestData["VersionName"] = _versionName;
requestData["ClassFile"] = decodedStack["Class"];
requestData["LineNo"] = decodedStack["LineNo"];
if (!kIsWeb)
{
requestData["ScreenResolution"] = width.toString() + " x " + height.toString();
}
requestData["Locale"] = defaultLocale;
requestData["OSName"] = osVersion;
requestData["OSVersion"] = apiVersion;
if (customProperties.isNotEmpty)
{
requestData["CustomProperty"] = jsonEncode(customProperties);
}
return requestData as FutureOr<HashMap<String, String?>> ;
}