Skip to main content

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

A common platform interface for memory_info.

memory_info_platform_interface #

A common platform interface for the memory_info plugin.

This interface allows platform-specific implementations of memory_info, as well as the plugin itself, to ensure they support the same interface.

Usage #

Apps should depend on memory_info, not on this package directly.

To implement a new platform, extend MemoryInfoPlatform and set it as the default instance:

class MemoryInfoMyPlatform extends MemoryInfoPlatform {
  static void registerWith() {
    MemoryInfoPlatform.instance = MemoryInfoMyPlatform();
  }

  @override
  Future<Memory> memoryInfo() async {
    // Read values from the platform here.
    return Memory(120, 8192, 2048, false, appAvailableMem: 1500);
  }

  @override
  Future<DiskSpace> diskSpace() async {
    return DiskSpace(64000, 128000);
  }

  @override
  Stream<MemoryPressureEvent> get onMemoryPressure => const Stream.empty();
}

The default implementation, MethodChannelMemoryInfo, talks to the native side over the github.com/MrOlolo/memory_info method channel and the github.com/MrOlolo/memory_info/pressure event channel.

Models #

All sizes are in megabytes.

  • Memory: appMem, totalMem, freeMem, lowMemory, appAvailableMem, lowMemoryThreshold, advertisedMem, javaHeapUsedMem, javaHeapMaxMem
  • DiskSpace: freeSpace, totalSpace, usedSpace
  • MemoryPressureEvent: level (MemoryPressureLevel), androidTrimLevel

See the memory_info README for what each value means on each platform.

Note on breaking changes #

Prefer non-breaking changes (such as adding a method or an optional field) over breaking changes for this package.

License #

MIT

0
likes
140
points
36k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A common platform interface for memory_info.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, meta, plugin_platform_interface

More

Packages that depend on memory_info_platform_interface