61 lines
1.9 KiB
Dart
61 lines
1.9 KiB
Dart
import 'package:hub/backend/api_requests/api_manager.dart';
|
|
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
|
import 'package:hub/flutter_flow/request_manager.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hub/pages/liberation_history/liberation_history_widget.dart';
|
|
import 'package:hub/shared/helpers/db_helper.dart';
|
|
|
|
class LiberationHistoryModel extends FlutterFlowModel<LiberationHistoryWidget> {
|
|
final DatabaseHelper db = DatabaseHelper();
|
|
late final String devUUID;
|
|
late final String userUUID;
|
|
late final String cliUUID;
|
|
|
|
final unfocusNode = FocusNode();
|
|
FocusNode? textFieldFocusNode;
|
|
TextEditingController? textController;
|
|
String? Function(BuildContext, String?)? textControllerValidator;
|
|
|
|
final _getLiberationsManager = StreamRequestManager<ApiCallResponse>();
|
|
Stream<ApiCallResponse> getLiberations({
|
|
String? uniqueQueryKey,
|
|
bool? overrideCache,
|
|
required Stream<ApiCallResponse> Function() requestFn,
|
|
}) =>
|
|
_getLiberationsManager.performRequest(
|
|
uniqueQueryKey: uniqueQueryKey,
|
|
overrideCache: overrideCache,
|
|
requestFn: requestFn,
|
|
);
|
|
void clearGetLiberationsCache() => _getLiberationsManager.clear();
|
|
void clearGetLiberationsCacheKey(String? uniqueKey) =>
|
|
_getLiberationsManager.clearRequest(uniqueKey);
|
|
|
|
@override
|
|
void initState(BuildContext context) {
|
|
init();
|
|
}
|
|
|
|
Future<void> init() async {
|
|
devUUID = await db
|
|
.get(key: 'devUUID', field: 'value')
|
|
.then((value) => value.toString());
|
|
userUUID = await db
|
|
.get(key: 'userUUID', field: 'value')
|
|
.then((value) => value.toString());
|
|
cliUUID = await db
|
|
.get(key: 'cliUUID', field: 'value')
|
|
.then((value) => value.toString());
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
unfocusNode.dispose();
|
|
textFieldFocusNode?.dispose();
|
|
textController?.dispose();
|
|
|
|
clearGetLiberationsCache();
|
|
}
|
|
}
|