Artifact.fromJson constructor
Creates a Matrix from JSON data.
json A map containing 'rows', 'cols', and 'data' keys.
Implementation
factory Artifact.fromJson(final Map<String, dynamic> json) {
// determine the mandatory cols/width of the matrix
final int cols = (json['cols'] as int?) ?? 0;
final Artifact artifact = Artifact(cols, 0);
artifact.font = json['font'] ?? '';
artifact._matrix = Uint8List.fromList(
(json['data'] as List<dynamic>).expand((final dynamic row) {
return row.toString().split('').map((cell) => cell == '#' ? 1 : 0);
}).toList(),
);
return artifact;
}