AsyncMemoizer in Dart/Flutter
Asked Answered
E

2

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?

Eslinger answered 18/4, 2020 at 22:16 Comment(3)
this may help #52250078Chiang
AsyncMemoizer is part of package:async, not dart:async.Sackett
Ahhh thanks @jamesdlin, that's it!!Eslinger
S
22
import 'package:async/async.dart';
Strophanthus answered 4/7, 2020 at 6:36 Comment(0)
R
1

First add dependency:

dart pub add async

Then import and use it:

import 'package:async/async.dart';
...
final _memoizer = AsyncMemoizer();
Ratafia answered 8/10, 2022 at 8:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.