collect static method

Future<CommonContext> collect()

Implementation

static Future<CommonContext> collect() async {
  var osName = "";
  var osVersion = "";
  var platform = "";
  var version = "";
  var deviceModelName = "";
  try {
    var packageInfo = await PackageInfo.fromPlatform();
    if (Platform.isAndroid) {
      var androidInfo = await deviceInfoPlugin.androidInfo;
      deviceModelName = androidInfo.model;
      platform = "android";
      version = packageInfo.version;
      osName = androidInfo.version.codename;
      osVersion = androidInfo.version.sdkInt.toString();
    } else if (Platform.isIOS) {
      var iosInfo = await deviceInfoPlugin.iosInfo;
      deviceModelName = iosInfo.model ?? "";
      platform = "ios";
      version = packageInfo.version;
      osName = iosInfo.systemName ?? "ios";
      osVersion = iosInfo.systemVersion ?? "";
    }
  } catch (e) {
    debugPrint(e.toString());
  }
  return CommonContext(platform, version, osName, osVersion, deviceModelName);
}