kirz_ram_info 0.1.0 copy "kirz_ram_info: ^0.1.0" to clipboard
kirz_ram_info: ^0.1.0 copied to clipboard

A Flutter plugin to get total and used RAM information. iOS only.

kirz_ram_info #

A Flutter plugin to get total and used RAM information on iOS devices.

Platform Support #

  • ✅ iOS
  • ❌ Android (throws an error)

Features #

  • Get total RAM in bytes
  • Get used RAM in bytes
  • Calculate free RAM
  • Convert values to MB/GB
  • Calculate RAM usage percentage

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  kirz_ram_info: ^0.0.1

Usage #

import 'package:kirz_ram_info/kirz_ram_info.dart';

// Get complete RAM information
try {
  final ramInfo = await KirzRamInfo.getRamInfo();
  print('Total RAM: ${ramInfo.totalRamGB.toStringAsFixed(2)} GB');
  print('Used RAM: ${ramInfo.usedRamGB.toStringAsFixed(2)} GB');
  print('Free RAM: ${ramInfo.freeRamGB.toStringAsFixed(2)} GB');
  print('Usage: ${ramInfo.usagePercentage.toStringAsFixed(1)}%');
} catch (e) {
  print('Error: $e'); // Will throw on Android
}

// Get only total RAM
final totalRam = await KirzRamInfo.getTotalRam();
print('Total RAM: ${totalRam / (1024 * 1024 * 1024)} GB');

// Get only used RAM
final usedRam = await KirzRamInfo.getUsedRam();
print('Used RAM: ${usedRam / (1024 * 1024 * 1024)} GB');

RamInfo Properties #

The RamInfo class provides the following properties:

  • totalRam - Total RAM in bytes (int)
  • usedRam - Used RAM in bytes (int)
  • freeRam - Free RAM in bytes (int, computed)
  • totalRamMB - Total RAM in megabytes (double)
  • usedRamMB - Used RAM in megabytes (double)
  • freeRamMB - Free RAM in megabytes (double)
  • totalRamGB - Total RAM in gigabytes (double)
  • usedRamGB - Used RAM in gigabytes (double)
  • freeRamGB - Free RAM in gigabytes (double)
  • usagePercentage - RAM usage percentage 0-100 (double)

Platform-Specific Notes #

iOS #

Uses native iOS APIs to get accurate RAM information:

  • ProcessInfo.processInfo.physicalMemory for total RAM
  • mach_task_basic_info and vm_statistics64 for used RAM

Android #

Throws a PlatformException with code UNSUPPORTED_PLATFORM when called.

Error Handling #

Always wrap calls in try-catch blocks:

try {
  final ramInfo = await KirzRamInfo.getRamInfo();
  // Use ramInfo
} on PlatformException catch (e) {
  if (e.code == 'UNSUPPORTED_PLATFORM') {
    print('This platform is not supported');
  }
} catch (e) {
  print('Error getting RAM info: $e');
}

License #

MIT License

0
likes
150
points
121
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to get total and used RAM information. iOS only.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on kirz_ram_info

Packages that implement kirz_ram_info