FLUTTER ECOSYSTEM

memoize

Returns cached result of function call when inputs were not changed from previous invocation.

Latest version
3.0.0
30-day downloads
68.1K
Likes
33
Pub points
130

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Overview

The memoize package is a Dart utility that caches the results of function calls based on their input parameters. When a function is invoked with the same arguments as a previous call, it returns the cached result instead of recomputing it, improving performance for expensive or frequently called functions. It supports all major platforms including Android, iOS, Web, macOS, Windows, and Linux. The package is particularly useful in reactive or stateful applications where repeated computations can be avoided. It integrates seamlessly into Flutter projects via pub.dev.

Use cases
  • Caching expensive computations
  • Optimizing UI rendering with stable inputs
  • Improving performance in state management
  • Reducing redundant API calls
  • Enhancing responsiveness in data-heavy apps
  • Avoiding repeated calculations in animations
Key features
  • Automatic caching based on input equality
  • Support for async and sync functions
  • Cross-platform compatibility
  • Lightweight and easy to integrate
  • Built-in support for complex types via custom comparators
  • Minimal boilerplate required
Suitable for
  • Developers optimizing performance in Flutter apps
  • State management with frequent recalculations
  • Apps with heavy computational logic
  • Reactive UIs requiring fast updates
  • Teams using functional programming patterns
Considerations
  • Memory usage increases with cache size
  • Cache invalidation must be handled manually if needed
  • Not suitable for functions with side effects
  • May not work well with mutable input objects without custom equality
  • Performance gain depends on function cost and invocation frequency
Supported platformsAndroidiOSWebmacOSWindowsLinux

Install package

flutter pub add memoize

Categories

Source repository

Related projects