Skip to content
Snippets Groups Projects
cell_location.dart 605 B
Newer Older
Benoît Harrault's avatar
Benoît Harrault committed
import 'package:flutter_custom_toolbox/flutter_toolbox.dart';

class CellLocation {
  final int col;
  final int row;

  CellLocation({
    required this.col,
    required this.row,
  });

  factory CellLocation.go(int row, int col) {
    return CellLocation(col: col, row: row);
  }

  void dump() {
    printlog('$CellLocation:');
    printlog('  row: $row');
    printlog('  col: $col');
    printlog('');
  }

  @override
  String toString() {
    return '[${col + 1},${row + 1}]';
  }

  Map<String, dynamic>? toJson() {
    return <String, dynamic>{
      'row': row,
      'col': col,
    };
  }
}