getMapFromJson method
dynamic
getMapFromJson(})
Implementation
dynamic getMapFromJson(
String? path, {
required void Function() callbackJsonIsList,
String warningMessage = 'Format json not valid!',
}) {
final json = path != null ? File(path).readAsStringSync() : '{}';
dynamic response;
try {
response = jsonDecode(json);
if (response is List) {
callbackJsonIsList();
response = response.first;
}
} catch (e) {
StatusHelper.warning(warningMessage);
return null;
}
if (response is! Map) {
StatusHelper.warning(warningMessage);
return null;
}
return response;
}