Skip to content

How to implement a lazy loading behavior outside the Flutter scope? #708

Answered by rrousselGit
YuriHeiko asked this question in Q&A
Discussion options

You must be logged in to vote

You shouldn't create a ProviderContainer.
That assertAsBytes is also anti-pattern.

Instead, consider making a provider:

final bytesForAssetPathProvider = FutureProvider.autoDispose.family<Uint8List, String>((ref, path) async {
  final repository = ref.watch(cdnRepositoryProvider);

  return repository.load(path);
});

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@YuriHeiko
Comment options

@YuriHeiko
Comment options

Answer selected by rrousselGit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #707 on August 23, 2021 10:35.