Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Flutter hook for Completer (dart:async)
import 'dart:async';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
class _CompleterHook extends Hook<Completer> {
@override
HookState<Completer, Hook<Completer>> createState() => _CompleterHookState();
}
class _CompleterHookState extends HookState<Completer, _CompleterHook> {
Completer _completer;
@override
void initHook() {
_completer = Completer<void>();
super.initHook();
}
@override
Completer build(BuildContext context) => _completer;
}
Completer<void> useCompleterHook() {
return Hook.use(_CompleterHook());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment