data.dart 932 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'package:flowy_sdk/protobuf/flowy-grid-data-model/grid.pb.dart';
  2. import 'package:equatable/equatable.dart';
  3. import 'package:flowy_sdk/protobuf/flowy-grid-data-model/meta.pb.dart';
  4. class GridInfo {
  5. List<Row> rows;
  6. List<Field> fields;
  7. GridInfo({
  8. required this.rows,
  9. required this.fields,
  10. });
  11. GridRowData rowAtIndex(int index) {
  12. final row = rows[index];
  13. return GridRowData(
  14. row: row,
  15. fields: fields,
  16. cellMap: row.cellByFieldId,
  17. );
  18. }
  19. int numberOfRows() {
  20. return rows.length;
  21. }
  22. }
  23. class GridRowData extends Equatable {
  24. final Row row;
  25. final List<Field> fields;
  26. final Map<String, Cell> cellMap;
  27. const GridRowData({
  28. required this.row,
  29. required this.fields,
  30. required this.cellMap,
  31. });
  32. @override
  33. List<Object> get props => [row.hashCode, cellMap];
  34. }
  35. class GridColumnData {
  36. final List<Field> fields;
  37. GridColumnData({required this.fields});
  38. }