7

How do you memoize your futures? I am using a FutureBuilder that gets items data by some params.

I found here a suggestion to use AsyncMemoizer, however it looks like it's missing from the dart:async package.

Are there alternatives?

valk
  • 9,363
  • 12
  • 59
  • 79

2 Answers2

20
import 'package:async/async.dart';
Zephyr
  • 11,891
  • 53
  • 45
  • 80
1

First add dependency:

dart pub add async

Then import and use it:

import 'package:async/async.dart';
...
final _memoizer = AsyncMemoizer();
Pipelin
  • 11
  • 3