getDeviceFreeMemory static method

Future<String> getDeviceFreeMemory()

TODO: Restore in the future, requires either ripping just relevant code from Connectivity plugin (preferred solution) or by asking publishers to add two properties, describing usage of location, to their info.plist: 'NSLocationAlwaysAndWhenInUseUsageDescription' & 'NSLocationWhenInUseUsageDescription'. Source: https://pub.dev/packages/connectivity Source: https://pub.dev/packages/system_info

Implementation

//  /// Uses plugin "connectivity".
//  /// Existing Android/iOS values are: "wifi", "2g", "3g", "4g"
//  ///
//  /// NOTE: Flutter, incl. Connectivity package currently only provide wifi or cell. No '2g/3g/4g/..' resolution.
//  ///       A PR is open for adding the 'networkType' resolution but still wasn't accepted: https://github.com/flutter/plugins/pull/1945
//  ///
//  /// NOTE: Unlike other values here, every query to this method must pull current results as values are dynamic.
//  ///
//  /// Source: https://pub.dev/packages/connectivity
//  /// Source: https://pub.dev/documentation/connectivity/latest/
//  static Future<String> getNetworkConnSpeed() async {
//      var connectivityResult = await (Connectivity().checkConnectivity());
//      if (connectivityResult == ConnectivityResult.mobile) {
//        return "3g"; //Providing Taboola back-end with common value until better resolution is available.
//      } else if (connectivityResult == ConnectivityResult.wifi) {
//        return "wifi";
//      }
//
//      return "offline"; //value taken from iOS, Android SDK does not handle this case.
//  }

/// Source: https://pub.dev/packages/system_info
static Future<String> getDeviceFreeMemory() async {
  const int kiloByte = 1024;

  if (TextUtils.isEmptyOrNull(_mem)) {
    int memInteger;

    if (dartIo.Platform.isAndroid) {
      memInteger = SysInfo.getFreeVirtualMemory() ~/ kiloByte;
    } else {
      memInteger =
          0; //FIXME: Hardcoded, current version of library doesn't work on iOS properly.
    }

    _mem = "$memInteger";
  }
  return _mem;
}