getCurrentFields method
Implementation
Future<Map<String, dynamic>> getCurrentFields() async {
Map<String, dynamic> fields = currentFields();
if (fields.isEmpty) {
final url = '$mauticBaseUrl/api/fields/contact';
final headers = getHeaders();
final response = await httpClient.get(Uri.parse(url), headers: headers);
if (response.statusCode == 200) {
fields = jsonDecode(response.body)['fields'] as Map<String, dynamic>;
setCurrentFields(fields);
} else {
throw Exception(
'Failed to retrieve contact fields: ${response.statusCode}');
}
}
return fields;
}