@@ -459,13 +459,31 @@ class TextSelectionOverlay {
459459 return ;
460460 }
461461
462- final TextSelection newSelection = TextSelection (
463- baseOffset: _selection.baseOffset,
464- extentOffset: position.offset,
465- );
466-
467- if (newSelection.baseOffset >= newSelection.extentOffset) {
468- return ; // Don't allow order swapping.
462+ final TextSelection newSelection;
463+ switch (defaultTargetPlatform) {
464+ // On Apple platforms, dragging the base handle makes it the extent.
465+ case TargetPlatform .iOS:
466+ case TargetPlatform .macOS:
467+ newSelection = TextSelection (
468+ extentOffset: position.offset,
469+ baseOffset: _selection.start,
470+ );
471+ if (position.offset <= _selection.start) {
472+ return ; // Don't allow order swapping.
473+ }
474+ break ;
475+ case TargetPlatform .android:
476+ case TargetPlatform .fuchsia:
477+ case TargetPlatform .linux:
478+ case TargetPlatform .windows:
479+ newSelection = TextSelection (
480+ baseOffset: _selection.baseOffset,
481+ extentOffset: position.offset,
482+ );
483+ if (newSelection.baseOffset >= newSelection.extentOffset) {
484+ return ; // Don't allow order swapping.
485+ }
486+ break ;
469487 }
470488
471489 _handleSelectionHandleChanged (newSelection, isEnd: true );
@@ -489,13 +507,31 @@ class TextSelectionOverlay {
489507 return ;
490508 }
491509
492- final TextSelection newSelection = TextSelection (
493- baseOffset: position.offset,
494- extentOffset: _selection.extentOffset,
495- );
496-
497- if (newSelection.baseOffset >= newSelection.extentOffset) {
498- return ; // Don't allow order swapping.
510+ final TextSelection newSelection;
511+ switch (defaultTargetPlatform) {
512+ // On Apple platforms, dragging the base handle makes it the extent.
513+ case TargetPlatform .iOS:
514+ case TargetPlatform .macOS:
515+ newSelection = TextSelection (
516+ extentOffset: position.offset,
517+ baseOffset: _selection.end,
518+ );
519+ if (newSelection.extentOffset >= _selection.end) {
520+ return ; // Don't allow order swapping.
521+ }
522+ break ;
523+ case TargetPlatform .android:
524+ case TargetPlatform .fuchsia:
525+ case TargetPlatform .linux:
526+ case TargetPlatform .windows:
527+ newSelection = TextSelection (
528+ baseOffset: position.offset,
529+ extentOffset: _selection.extentOffset,
530+ );
531+ if (newSelection.baseOffset >= newSelection.extentOffset) {
532+ return ; // Don't allow order swapping.
533+ }
534+ break ;
499535 }
500536
501537 _handleSelectionHandleChanged (newSelection, isEnd: false );
@@ -1116,7 +1152,6 @@ class _SelectionHandleOverlay extends StatefulWidget {
11161152}
11171153
11181154class _SelectionHandleOverlayState extends State <_SelectionHandleOverlay > with SingleTickerProviderStateMixin {
1119-
11201155 late AnimationController _controller;
11211156 Animation <double > get _opacity => _controller.view;
11221157
0 commit comments