transaction.dart 880 B

1234567891011121314151617181920212223242526
  1. import 'dart:collection';
  2. import 'package:flutter/material.dart';
  3. import 'package:flowy_editor/document/selection.dart';
  4. import './operation.dart';
  5. /// A [Transaction] has a list of [Operation] objects that will be applied
  6. /// to the editor. It is an immutable class and used to store and transmit.
  7. ///
  8. /// If you want to build a new [Transaction], use [TransactionBuilder] directly.
  9. ///
  10. /// There will be several ways to consume the transaction:
  11. /// 1. Apply to the state to update the UI.
  12. /// 2. Send to the backend to store and do operation transforming.
  13. /// 3. Used by the UndoManager to implement redo/undo.
  14. @immutable
  15. class Transaction {
  16. final UnmodifiableListView<Operation> operations;
  17. final Selection? beforeSelection;
  18. final Selection? afterSelection;
  19. const Transaction({
  20. required this.operations,
  21. this.beforeSelection,
  22. this.afterSelection,
  23. });
  24. }