lemmur-app-android/lib/hooks/memo_future.dart

10 lines
445 B
Dart
Raw Normal View History

2020-09-15 15:20:34 +02:00
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
2020-09-30 19:05:00 +02:00
/// creates an [AsyncSnapshot] from the Future returned from the valueBuilder.
/// [keys] can be used to rebuild the Future
AsyncSnapshot<T?> useMemoFuture<T>(Future<T> Function() valueBuilder,
[List<Object> keys = const <Object>[]]) =>
2021-04-05 20:14:39 +02:00
useFuture(useMemoized<Future<T>>(valueBuilder, keys),
preserveState: false, initialData: null);