Matrix.fromJson constructor

Matrix.fromJson(
  1. Map<String, dynamic> json
)

Creates a Matrix from JSON data.

json A map containing 'rows', 'cols', and 'data' keys.

Implementation

factory Matrix.fromJson(final Map<String, dynamic> json) {
  final Matrix matrix = Matrix();
  matrix.font = json['font'];
  matrix.rows = json['rows'];
  matrix.cols = json['cols'];
  matrix._data = (json['data'] as List<dynamic>).map((row) {
    return row.toString().split('').map((cell) => cell == '#').toList();
  }).toList();
  return matrix;
}