@@ -70,9 +70,8 @@ class ReadingCaretController extends ChangeNotifier {
7070 region! ._selectionChanged ();
7171 return ;
7272 }
73- // Native readers distinguish an empty selection from a cleared selection,
74- // notably while preserving a selection for a secondary click. Keep that
75- // callback and its focus/copy guards exactly as they are.
73+ // Preserve native empty-versus-null semantics and existing focus/copy guards;
74+ // a secondary click may intentionally retain an empty selection.
7675 _lastSelection = null ;
7776 _unreportedSelection = null ;
7877 _region? ._ownsSelectionEndpoints = false ;
@@ -103,9 +102,8 @@ class ReadingCaretController extends ChangeNotifier {
103102 if (previous == null || region == null ) return ;
104103 final content = region._delegate? .getSelectedContent ();
105104 if (content? .plainText == previous.plainText) return ;
106- // Public dispatch does not update SelectableRegion's native callback cache.
107- // A subsequent native clear may therefore emit no callback. Fill only that
108- // gap after the transaction, retaining its raw empty-versus-null meaning.
105+ // Public dispatch leaves Flutter's callback cache unchanged. Report a silent
106+ // native clear after the transaction, preserving empty versus null.
109107 _unreportedSelection = null ;
110108 _lastSelection = null ;
111109 region._ownsSelectionEndpoints = false ;
@@ -369,9 +367,8 @@ class _ReadingCaretRegionState extends State<ReadingCaretRegion>
369367 final owner = widget.owner;
370368 final delegate = _delegate;
371369 final region = _selectionRegion;
372- // A reused SelectionArea can still hold the previous tab's collapsed range.
373- // Clear it outside build before adopting geometry for the new owner. The
374- // token is a separate generation: focus changes must not cancel this reset.
370+ // Clear a reused SelectionArea outside build before adopting the new owner.
371+ // A separate reset token prevents focus changes from cancelling the clear.
375372 WidgetsBinding .instance.addPostFrameCallback ((_) {
376373 if (! mounted ||
377374 ! _connected ||
@@ -618,10 +615,8 @@ class _ReadingCaretRegionState extends State<ReadingCaretRegion>
618615 _adoptSelection ();
619616 return ;
620617 }
621- // A selection ending at offset zero in the next paragraph has no selected
622- // glyph there. Flutter may report the previous paragraph's trailing edge
623- // for that same range. Retain the explicit caret position and affinity;
624- // only native interaction may replace it with the delegate's endpoint.
618+ // At offset zero Flutter may report the previous paragraph's trailing edge.
619+ // Retain explicit endpoints until native interaction replaces them.
625620 final paragraphs = _paragraphs ();
626621 _base = _restore (_base, paragraphs) ?? _base;
627622 _extent = _restore (_extent, paragraphs) ?? _extent;
@@ -653,9 +648,8 @@ class _ReadingCaretRegionState extends State<ReadingCaretRegion>
653648 extent.position.selectionPoint == null ) {
654649 return ;
655650 }
656- // A font/style layout replaces RenderParagraph's selectable fragments.
657- // Restore the actual range in their completed registration transaction,
658- // using the same source/item identities and the same public delegate.
651+ // Layout replaces selectable fragments. Restore the real range only after
652+ // registration completes, preserving source/item identities.
659653 _place (extent, extend: true , replayBase: base );
660654 }
661655
@@ -677,9 +671,8 @@ class _ReadingCaretRegionState extends State<ReadingCaretRegion>
677671 final owner = widget.owner;
678672 final generation = _generation;
679673 final version = ++ _selectionSyncVersion;
680- // A scrollable updates its child registry in a post-frame callback. Its
681- // geometry notification can precede completion of the child's range.
682- // Observe the completed transaction, and never republish a native event.
674+ // Registry notifications may precede the completed post-frame range.
675+ // Observe the finished transaction without republishing native events.
683676 scheduleMicrotask (() {
684677 if (! mounted ||
685678 ! _connected ||
0 commit comments