toMap method
Implementation
Map<String, dynamic> toMap({bool addComments = false}) {
Map<String, dynamic> result = {};
List<Map<String, dynamic>> finalList = [];
if (gitDependencies != null && gitDependencies!.isNotEmpty) {
if (addComments) {
finalList.add({'${comment}1': 'git related dependencies'});
}
finalList += gitDependencies!.map((x) => x.toMap()).toList();
}
if (pathDependencies != null && pathDependencies!.isNotEmpty) {
if (addComments) {
finalList.add({'${comment}2': 'path related dependencies'});
}
finalList += pathDependencies!.map((x) => x.toMap()).toList();
}
if (normalDependencies != null && normalDependencies!.isNotEmpty) {
if (addComments) {
finalList.add({'${comment}3': 'normal dependencies'});
}
finalList += normalDependencies!.map((x) => x.toMap()).toList();
}
if (hostedDependencies != null && hostedDependencies!.isNotEmpty) {
if (addComments) {
finalList.add({'${comment}4': 'hosted dependencies'});
}
finalList += hostedDependencies!.map((x) => x.toMap()).toList();
}
if (sdkDependencies != null && sdkDependencies!.isNotEmpty) {
if (addComments) {
finalList.add({'${comment}5': 'sdk dependencies'});
}
finalList += sdkDependencies!.map((x) => x.toMap()).toList();
}
for (var map in finalList) {
result.addAll(map);
}
return result;
}