toMap method
This method tries to convert
a two-dimnensional tuple into
a {key:value}
pair.
Implementation
Map<dynamic, dynamic> toMap() {
Map<dynamic, dynamic> result = {};
List<dynamic> initialTuple = this.data[0];
if (initialTuple.length != 2) {
throw 'Tuple items do not have the required length!';
} else {
for (int i = 0; i < this.data.length; i++) {
var key = this.data[i][0];
var value = this.data[i][1];
try {
result.addAll({key: value});
} catch (e) {
print('Map could not be built.');
}
}
}
return result;
}