Skip to content

Commit

Permalink
Revert "fix: TextSelectionGestureDetector update for Flutter 3.10.0 (#39
Browse files Browse the repository at this point in the history
)"

This reverts commit 2c46bdf.
  • Loading branch information
zmtzawqlp committed May 14, 2023
1 parent 2c46bdf commit 20a6409
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 30 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
.pub-cache/
.pub/
build/
pubspec.lock

# Android related
**/android/**/gradle-wrapper.jar
Expand Down
4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Unreleased

* fix: TextSelectionGestureDetector update for Flutter 3.10.0

# 10.0.0

* fix issue on ios after flutter version 3.7.0. #191 #198
Expand Down
2 changes: 1 addition & 1 deletion lib/src/background_text_span.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class BackgroundTextSpan extends SpecialTextSpan {
}

@override
int get hashCode => Object.hash(
int get hashCode => hashValues(
style,
text,
recognizer,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/extended_widget_span.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ExtendedWidgetSpan extends WidgetSpan with SpecialInlineSpanBase {

@override
int get hashCode =>
Object.hash(super.hashCode, baseHashCode, widgetSpanSize.size);
hashValues(super.hashCode, baseHashCode, widgetSpanSize.size);

@override
RenderComparison compareTo(InlineSpan other) {
Expand Down
27 changes: 11 additions & 16 deletions lib/src/selection/extended_text_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,8 @@ class ExtendedTextSelectionGestureDetectorBuilder {
///
/// * [TextSelectionGestureDetector.onTapDown], which triggers this callback.
@protected
void onTapDown(TapDragDownDetails details) {
renderEditable.handleTapDown(
TapDownDetails(
globalPosition: details.globalPosition,
localPosition: details.localPosition,
kind: details.kind,
),
);
void onTapDown(TapDownDetails details) {
renderEditable.handleTapDown(details);
// The selection overlay should only be shown when the user is interacting
// through a touch screen (via either a finger or a stylus). A mouse shouldn't
// trigger the selection overlay.
Expand Down Expand Up @@ -179,7 +173,7 @@ class ExtendedTextSelectionGestureDetectorBuilder {
/// * [TextSelectionGestureDetector.onSingleTapUp], which triggers
/// this callback.
@protected
void onSingleTapUp(TapDragUpDetails details) {
void onSingleTapUp(TapUpDetails details) {
if (delegate.selectionEnabled) {
renderEditable.selectWordEdge(cause: SelectionChangedCause.tap);
}
Expand Down Expand Up @@ -290,7 +284,7 @@ class ExtendedTextSelectionGestureDetectorBuilder {
/// * [TextSelectionGestureDetector.onDoubleTapDown], which triggers this
/// callback.
@protected
void onDoubleTapDown(TapDragDownDetails details) {
void onDoubleTapDown(TapDownDetails details) {
if (delegate.selectionEnabled) {
renderEditable.selectWord(cause: SelectionChangedCause.tap);
if (shouldShowSelectionToolbar) {
Expand All @@ -308,7 +302,7 @@ class ExtendedTextSelectionGestureDetectorBuilder {
/// * [TextSelectionGestureDetector.onDragSelectionStart], which triggers
/// this callback.
@protected
void onDragSelectionStart(TapDragStartDetails details) {
void onDragSelectionStart(DragStartDetails details) {
if (!delegate.selectionEnabled) {
return;
}
Expand All @@ -331,13 +325,14 @@ class ExtendedTextSelectionGestureDetectorBuilder {
/// * [TextSelectionGestureDetector.onDragSelectionUpdate], which triggers
/// this callback./lib/src/material/text_field.dart
@protected
void onDragSelectionUpdate(TapDragUpdateDetails details) {
void onDragSelectionUpdate(
DragStartDetails startDetails, DragUpdateDetails updateDetails) {
if (!delegate.selectionEnabled) {
return;
}
renderEditable.selectPositionAt(
from: details.localOffsetFromOrigin,
to: details.localPosition,
from: startDetails.globalPosition,
to: updateDetails.globalPosition,
cause: SelectionChangedCause.drag,
);
}
Expand All @@ -351,7 +346,7 @@ class ExtendedTextSelectionGestureDetectorBuilder {
/// * [TextSelectionGestureDetector.onDragSelectionEnd], which triggers this
/// callback.
@protected
void onDragSelectionEnd(TapDragEndDetails details) {
void onDragSelectionEnd(DragEndDetails details) {
/* Subclass should override this method if needed. */
}

Expand Down Expand Up @@ -449,7 +444,7 @@ class CommonTextSelectionGestureDetectorBuilder
}

@override
void onSingleTapUp(TapDragUpDetails details) {
void onSingleTapUp(TapUpDetails details) {
hideToolbar();
if (delegate.selectionEnabled) {
switch (Theme.of(_context).platform) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/selection/extended_text_selection_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ class SelectionOverlay {
OverlayEntry(builder: _buildStartHandle),
OverlayEntry(builder: _buildEndHandle),
];
Overlay.of(context, rootOverlay: true, debugRequiredFor: debugRequiredFor)
Overlay.of(context, rootOverlay: true, debugRequiredFor: debugRequiredFor)!
.insertAll(_handles!);
}

Expand All @@ -646,7 +646,7 @@ class SelectionOverlay {
return;
}
_toolbar = OverlayEntry(builder: _buildToolbar);
Overlay.of(context, rootOverlay: true, debugRequiredFor: debugRequiredFor)
Overlay.of(context, rootOverlay: true, debugRequiredFor: debugRequiredFor)!
.insert(_toolbar!);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/special_inline_span_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter/rendering.dart';
/// create by zmtzawqlp on 2019/7/10
///
mixin SpecialInlineSpanBase {
abstract class SpecialInlineSpanBase {
/// actual text
String get actualText;

Expand All @@ -28,7 +28,7 @@ mixin SpecialInlineSpanBase {
other.actualText == actualText;
}

int get baseHashCode => Object.hash(actualText, start, deleteAll);
int get baseHashCode => hashValues(actualText, start, deleteAll);

RenderComparison baseCompareTo(SpecialInlineSpanBase other) {
if (other.actualText != actualText) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/special_text_span.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class SpecialTextSpan extends TextSpan with SpecialInlineSpanBase {
}

@override
int get hashCode => Object.hash(super.hashCode, baseHashCode);
int get hashCode => hashValues(super.hashCode, baseHashCode);

@override
RenderComparison compareTo(InlineSpan other) {
Expand Down
51 changes: 51 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
characters:
dependency: transitive
description:
name: characters
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.16.0"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.2"
sdks:
dart: ">=2.17.0 <3.0.0"
flutter: ">=3.0.0"
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version: 10.0.0
homepage: https://github.com/fluttercandies/extended_text_library

environment:
sdk: '>=3.0.0 <4.0.0'
flutter: ">=3.10.0"
sdk: '>=2.17.0 <3.0.0'
flutter: ">=3.0.0"

dependencies:
flutter:
Expand Down

0 comments on commit 20a6409

Please sign in to comment.