From 74e518214745f061b99acd808ce642aab34620a0 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Fri, 22 Jan 2021 18:29:02 -0600 Subject: [PATCH] Remove span deprecations (#73747) --- .../flutter/lib/src/painting/inline_span.dart | 53 ------------------- .../lib/src/painting/placeholder_span.dart | 13 ----- .../flutter/lib/src/painting/text_span.dart | 43 ++++----------- 3 files changed, 9 insertions(+), 100 deletions(-) diff --git a/packages/flutter/lib/src/painting/inline_span.dart b/packages/flutter/lib/src/painting/inline_span.dart index 8af74c68dc..0856bf25e6 100644 --- a/packages/flutter/lib/src/painting/inline_span.dart +++ b/packages/flutter/lib/src/painting/inline_span.dart @@ -156,32 +156,6 @@ abstract class InlineSpan extends DiagnosticableTree { /// of [TextSpan]. final TextStyle? style; - // TODO(garyq): Remove the deprecated visitTextSpan, text, and children. - /// Returns the text associated with this span if this is an instance of [TextSpan], - /// otherwise returns null. - @Deprecated( - 'InlineSpan does not innately have text. Use TextSpan.text instead. ' - 'This feature was deprecated after v1.7.3.' - ) - String? get text => null; - - // TODO(garyq): Remove the deprecated visitTextSpan, text, and children. - /// Returns the [InlineSpan] children list associated with this span if this is an - /// instance of [TextSpan], otherwise returns null. - @Deprecated( - 'InlineSpan does not innately have children. Use TextSpan.children instead. ' - 'This feature was deprecated after v1.7.3.' - ) - List? get children => null; - - /// Returns the [GestureRecognizer] associated with this span if this is an - /// instance of [TextSpan], otherwise returns null. - @Deprecated( - 'InlineSpan does not innately have a recognizer. Use TextSpan.recognizer instead. ' - 'This feature was deprecated after v1.7.3.' - ) - GestureRecognizer? get recognizer => null; - /// Apply the properties of this object to the given [ParagraphBuilder], from /// which a [Paragraph] can be obtained. /// @@ -196,18 +170,6 @@ abstract class InlineSpan extends DiagnosticableTree { /// [Paragraph] objects can be drawn on [Canvas] objects. void build(ui.ParagraphBuilder builder, { double textScaleFactor = 1.0, List? dimensions }); - // TODO(garyq): Remove the deprecated visitTextSpan, text, and children. - /// Walks this [TextSpan] and any descendants in pre-order and calls `visitor` - /// for each span that has content. - /// - /// When `visitor` returns true, the walk will continue. When `visitor` returns - /// false, then the walk will end. - @Deprecated( - 'Use visitChildren instead. ' - 'This feature was deprecated after v1.7.3.' - ) - bool visitTextSpan(bool visitor(TextSpan span)); - /// Walks this [InlineSpan] and any descendants in pre-order and calls `visitor` /// for each span that has content. /// @@ -319,21 +281,6 @@ abstract class InlineSpan extends DiagnosticableTree { @protected int? codeUnitAtVisitor(int index, Accumulator offset); - /// Populates the `semanticsOffsets` and `semanticsElements` with the appropriate data - /// to be able to construct a [SemanticsNode]. - /// - /// If applicable, the beginning and end text offset are added to [semanticsOffsets]. - /// [PlaceholderSpan]s have a text length of 1, which corresponds to the object - /// replacement character (0xFFFC) that is inserted to represent it. - /// - /// Any [GestureRecognizer]s are added to `semanticsElements`. Null is added to - /// `semanticsElements` for [PlaceholderSpan]s. - @Deprecated( - 'Implement computeSemanticsInformation instead. ' - 'This feature was deprecated after v1.7.3.' - ) - void describeSemantics(Accumulator offset, List semanticsOffsets, List semanticsElements); - /// In checked mode, throws an exception if the object is not in a /// valid configuration. Otherwise, returns true. /// diff --git a/packages/flutter/lib/src/painting/placeholder_span.dart b/packages/flutter/lib/src/painting/placeholder_span.dart index 17e8980057..b6486d40c3 100644 --- a/packages/flutter/lib/src/painting/placeholder_span.dart +++ b/packages/flutter/lib/src/painting/placeholder_span.dart @@ -66,18 +66,6 @@ abstract class PlaceholderSpan extends InlineSpan { collector.add(InlineSpanSemanticsInformation.placeholder); } - // TODO(garyq): Remove this after next stable release. - /// The [visitTextSpan] method is invalid on [PlaceholderSpan]s. - @override - @Deprecated( - 'Use to visitChildren instead. ' - 'This feature was deprecated after v1.7.3.' - ) - bool visitTextSpan(bool visitor(TextSpan span)) { - assert(false, 'visitTextSpan is deprecated. Use visitChildren to support InlineSpans'); - return false; - } - /// Populates the `semanticsOffsets` and `semanticsElements` with the appropriate data /// to be able to construct a [SemanticsNode]. /// @@ -85,7 +73,6 @@ abstract class PlaceholderSpan extends InlineSpan { /// replacement character (0xFFFC) that is inserted to represent it. /// /// Null is added to `semanticsElements` for [PlaceholderSpan]s. - @override void describeSemantics(Accumulator offset, List semanticsOffsets, List semanticsElements) { semanticsOffsets.add(offset.value); semanticsOffsets.add(offset.value + 1); diff --git a/packages/flutter/lib/src/painting/text_span.dart b/packages/flutter/lib/src/painting/text_span.dart index 9415c5dd19..46b752692d 100644 --- a/packages/flutter/lib/src/painting/text_span.dart +++ b/packages/flutter/lib/src/painting/text_span.dart @@ -79,7 +79,6 @@ class TextSpan extends InlineSpan { /// children. /// /// This getter does not include the contents of its children. - @override final String? text; @@ -92,7 +91,6 @@ class TextSpan extends InlineSpan { /// and may have unexpected results. /// /// The list must not contain any nulls. - @override final List? children; /// A gesture recognizer that will receive events that hit this span. @@ -170,7 +168,6 @@ class TextSpan extends InlineSpan { /// } /// ``` /// {@end-tool} - @override final GestureRecognizer? recognizer; /// An alternative semantics label for this [TextSpan]. @@ -239,36 +236,6 @@ class TextSpan extends InlineSpan { return true; } - // TODO(garyq): Remove this after next stable release. - /// Walks this [TextSpan] and any descendants in pre-order and calls `visitor` - /// for each span that has content. - /// - /// When `visitor` returns true, the walk will continue. When `visitor` - /// returns false, then the walk will end. - @override - @Deprecated( - 'Use to visitChildren instead. ' - 'This feature was deprecated after v1.7.3.' - ) - bool visitTextSpan(bool visitor(TextSpan span)) { - if (text != null) { - if (!visitor(this)) - return false; - } - if (children != null) { - for (final InlineSpan child in children!) { - assert( - child is TextSpan, - 'visitTextSpan is deprecated. Use visitChildren to support InlineSpans', - ); - final TextSpan textSpanChild = child as TextSpan; - if (!textSpanChild.visitTextSpan(visitor)) - return false; - } - } - return true; - } - /// Returns the text span that contains the given position in the text. @override InlineSpan? getSpanForPositionVisitor(TextPosition position, Accumulator offset) { @@ -338,7 +305,15 @@ class TextSpan extends InlineSpan { return null; } - @override + /// Populates the `semanticsOffsets` and `semanticsElements` with the appropriate data + /// to be able to construct a [SemanticsNode]. + /// + /// If applicable, the beginning and end text offset are added to [semanticsOffsets]. + /// [PlaceholderSpan]s have a text length of 1, which corresponds to the object + /// replacement character (0xFFFC) that is inserted to represent it. + /// + /// Any [GestureRecognizer]s are added to `semanticsElements`. Null is added to + /// `semanticsElements` for [PlaceholderSpan]s. void describeSemantics(Accumulator offset, List semanticsOffsets, List semanticsElements) { if ( recognizer != null &&