fetchQuestions method
Implementation
Future<List<dynamic>?> fetchQuestions(int typeId, int? jobId,
{bool forceRefresh = false}) async {
if (questionGroups == null || forceRefresh) {
try {
// Fetch the Form object
DynamicFormModel? fetchedForm =
await _dynamicFormService.fetchDynamicByTypeId(typeId);
if (fetchedForm != null &&
fetchedForm.items.isNotEmpty &&
jobId != null) {
_lastFetchedForms[jobId] = fetchedForm;
questionGroups = fetchedForm.items;
notifyListeners();
} else {
print("No form or questions received from the service");
}
return questionGroups;
} catch (e) {
print('Error fetching questions: $e');
return null;
}
}
return questionGroups;
}