Files
wehub-resource-sync bb087aad19
CI / format (push) Failing after 2s
CI / packaging (push) Failing after 0s
CI / test (push) Failing after 3s
chore: import upstream snapshot with attribution
2026-07-13 11:58:56 +08:00

28 lines
919 B
Dart

import 'package:localsend_app/model/state/server/server_state.dart';
import 'package:refena_flutter/refena_flutter.dart';
/// Having this class allows us to have one parameter to access all relevant server methods.
class ServerUtils {
/// The ref to the provider.
Ref Function() refFunc;
Ref get ref => refFunc();
/// The current server state.
/// This should be used within route controllers because it is guaranteed to be online and therefore non-null.
ServerState Function() getState;
/// The current server state or null.
/// This should be used outside of routes because the server may be offline.
ServerState? Function() getStateOrNull;
/// Updates the server state.
void Function(ServerState? Function(ServerState? oldState) builder) setState;
ServerUtils({
required this.refFunc,
required this.getState,
required this.getStateOrNull,
required this.setState,
});
}