Use VoidCallback

This commit is contained in:
shilangyu 2021-01-03 20:03:32 +00:00
parent e7745e3e9b
commit c3837b97aa
5 changed files with 10 additions and 9 deletions

View File

@ -7,7 +7,7 @@ import 'ref.dart';
class Debounce {
final bool loading;
final void Function() callback;
final VoidCallback callback;
const Debounce({
@required this.loading,
@ -20,7 +20,7 @@ class Debounce {
/// will run `callback()` after debounce hook hasn't been called for the
/// specified `delayDuration`
Debounce useDebounce(
Future<Null> Function() callback, [
Future<void> Function() callback, [
Duration delayDuration = const Duration(seconds: 1),
]) {
final loading = useState(false);

View File

@ -8,8 +8,8 @@ import 'ref.dart';
class DelayedLoading {
final bool pending;
final bool loading;
final void Function() start;
final void Function() cancel;
final VoidCallback start;
final VoidCallback cancel;
const DelayedLoading({
@required this.pending,

View File

@ -11,14 +11,15 @@ import 'stores.dart';
/// Snackbar is rendered. If [any] is set to true, this check is performed for
/// all instances and if any of them have an account, the wrapped action will be
/// called with a null token.
Function(
Function(Jwt token) action, [
VoidCallback Function(
void Function(Jwt token) action, [
String message,
]) useLoggedInAction(String instanceHost, {bool any = false}) {
final context = useContext();
final store = useAccountsStore();
return (Function(Jwt token) action, [message]) {
return (action, [message]) {
if (any && store.hasNoAccount ||
!any && store.isAnonymousFor(instanceHost)) {
return () {

View File

@ -456,7 +456,7 @@ class _CommentTag extends StatelessWidget {
class _CommentAction extends StatelessWidget {
final IconData icon;
final void Function() onPressed;
final VoidCallback onPressed;
final String tooltip;
final bool loading;
final Color iconColor;

View File

@ -4,7 +4,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import '../hooks/ref.dart';
class InfiniteScrollController {
Function() clear;
VoidCallback clear;
InfiniteScrollController() {
usedBeforeCreation() => throw Exception(