From 864469da83bfc0806adbd0dadb73d0d0bba7cf92 Mon Sep 17 00:00:00 2001 From: Matthew Whitaker Date: Fri, 30 Sep 2022 12:31:50 -0600 Subject: [PATCH 1/3] feat: SelectableHtml deprecated in favor of SelectionArea --- lib/custom_render.dart | 2 ++ lib/flutter_html.dart | 2 ++ lib/html_parser.dart | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/custom_render.dart b/lib/custom_render.dart index 35e678beec..46ffe34d34 100644 --- a/lib/custom_render.dart +++ b/lib/custom_render.dart @@ -102,6 +102,8 @@ class CustomRender { }) : inlineSpan = null; } +@Deprecated( + "Please use a standard Html widget with CustomRender. Wrap the widget in SelectionArea") class SelectableCustomRender extends CustomRender { final TextSpan Function(RenderContext, List Function()) textSpan; diff --git a/lib/flutter_html.dart b/lib/flutter_html.dart index 1b5d7fe55e..ada5eac661 100644 --- a/lib/flutter_html.dart +++ b/lib/flutter_html.dart @@ -198,6 +198,8 @@ class _HtmlState extends State { } } +@Deprecated( + "Please use Flutter's new SelectionArea widget. Upgrade from SelectableHtml to Html and wrap the widget in a SelectionArea widget.") class SelectableHtml extends StatefulWidget { /// The `SelectableHtml` widget takes HTML as input and displays a RichText /// tree of the parsed HTML content (which is selectable) diff --git a/lib/html_parser.dart b/lib/html_parser.dart index 8d73cc5d18..42f84b423a 100644 --- a/lib/html_parser.dart +++ b/lib/html_parser.dart @@ -53,12 +53,14 @@ class HtmlParser extends StatelessWidget { required this.onCssParseError, required this.onImageError, required this.shrinkWrap, - required this.selectable, + @Deprecated('Wrapping the Html widget in a SelectionArea widget is preferred') + this.selectable = false, required this.style, required this.customRenders, required this.tagsList, this.root, - this.selectionControls, + @Deprecated('Wrapping the Html widget in a SelectionArea widget is preferred') + this.selectionControls, this.scrollPhysics, }) : internalOnAnchorTap = onAnchorTap ?? (key != null ? _handleAnchorTap(key, onLinkTap) : onLinkTap); From bf15cd7e8476e7427ed7d3e5b947cf4b59021316 Mon Sep 17 00:00:00 2001 From: Matthew Whitaker Date: Sat, 1 Oct 2022 09:40:01 -0600 Subject: [PATCH 2/3] Update deprecated SelectableHtml to use SelectionArea and support all widgets --- README.md | 16 +++------- lib/custom_render.dart | 13 ++------ lib/flutter_html.dart | 19 ++++++----- lib/html_parser.dart | 22 +++---------- lib/src/css_box_widget.dart | 19 +++++------ lib/src/html_elements.dart | 63 ------------------------------------- test/flutter_html_test.dart | 14 --------- test/html_parser_test.dart | 8 +++-- 8 files changed, 38 insertions(+), 136 deletions(-) diff --git a/README.md b/README.md index 9210a56651..50524d7be1 100644 --- a/README.md +++ b/README.md @@ -148,19 +148,11 @@ If you would like to modify or sanitize the HTML before rendering it, then `Html #### Selectable Text -The package also has two constructors for selectable text support - `SelectableHtml()` and `SelectableHtml.fromDom()`. +Note: These constructors are deprecated. It is preferred that you use Flutter's new `SelectionArea` instead (just wrap the `Html` widget in a `SelectionArea`). -The difference between the two is the same as noted above. - -Please note: Due to Flutter [#38474](https://github.com/flutter/flutter/issues/38474), selectable text support is significantly watered down compared to the standard non-selectable version of the widget. The changes are as follows: - -1. The list of tags that can be rendered is significantly reduced. Key omissions include no support for images/video/audio, table, and ul/ol. - -2. No support for `customRender`, `customImageRender`, `onImageError`, `onImageTap`, `onMathError`, and `navigationDelegateForIframe`. (Support for `customRender` may be added in the future). - -3. Styling support is significantly reduced. Only text-related styling works (e.g. bold or italic), while container related styling (e.g. borders or padding/margin) do not work. - -Once the above issue is resolved, the aforementioned compromises will go away. Currently the `SelectableText.rich()` constructor does not support `WidgetSpan`s, resulting in the feature losses above. +> The package also has two constructors for selectable text support - `SelectableHtml()` and `SelectableHtml.fromDom()`. +> +> The difference between the two is the same as noted above. ### Parameters: diff --git a/lib/custom_render.dart b/lib/custom_render.dart index 46ffe34d34..6b013a3b50 100644 --- a/lib/custom_render.dart +++ b/lib/custom_render.dart @@ -102,19 +102,10 @@ class CustomRender { }) : inlineSpan = null; } -@Deprecated( - "Please use a standard Html widget with CustomRender. Wrap the widget in SelectionArea") -class SelectableCustomRender extends CustomRender { - final TextSpan Function(RenderContext, List Function()) textSpan; - - SelectableCustomRender.fromTextSpan({ - required this.textSpan, - }) : super.inlineSpan(inlineSpan: null); -} - CustomRender blockElementRender({Style? style, List? children}) => CustomRender.inlineSpan(inlineSpan: (context, buildChildren) { - if (context.parser.selectable) { + if (context.parser.selectable && + context.parser.selectableIgnoreBlockWidgets) { return TextSpan( style: context.style.generateTextStyle(), children: (children as List?) ?? diff --git a/lib/flutter_html.dart b/lib/flutter_html.dart index ada5eac661..532a54641f 100644 --- a/lib/flutter_html.dart +++ b/lib/flutter_html.dart @@ -189,6 +189,7 @@ class _HtmlState extends State { onImageError: widget.onImageError, shrinkWrap: widget.shrinkWrap, selectable: false, + selectableIgnoreBlockWidgets: false, style: widget.style, customRenders: {} ..addAll(widget.customRenders) @@ -198,8 +199,6 @@ class _HtmlState extends State { } } -@Deprecated( - "Please use Flutter's new SelectionArea widget. Upgrade from SelectableHtml to Html and wrap the widget in a SelectionArea widget.") class SelectableHtml extends StatefulWidget { /// The `SelectableHtml` widget takes HTML as input and displays a RichText /// tree of the parsed HTML content (which is selectable) @@ -232,6 +231,8 @@ class SelectableHtml extends StatefulWidget { /// (e.g. bold or italic), while container related styling (e.g. borders or padding/margin) /// do not work because we can't use the `ContainerSpan` class (it needs an enclosing `WidgetSpan`). + @Deprecated( + "Please use Flutter's new SelectionArea widget. Upgrade from SelectableHtml to Html and wrap the widget in a SelectionArea widget.") SelectableHtml({ Key? key, GlobalKey? anchorKey, @@ -245,11 +246,14 @@ class SelectableHtml extends StatefulWidget { this.tagsList = const [], this.selectionControls, this.scrollPhysics, + this.ignoreBlockElements = false, }) : documentElement = null, assert(data != null), _anchorKey = anchorKey ?? GlobalKey(), super(key: key); + @Deprecated( + "Please use Flutter's new SelectionArea widget. Upgrade from SelectableHtml to Html and wrap the widget in a SelectionArea widget.") SelectableHtml.fromDom({ Key? key, GlobalKey? anchorKey, @@ -263,6 +267,7 @@ class SelectableHtml extends StatefulWidget { this.tagsList = const [], this.selectionControls, this.scrollPhysics, + this.ignoreBlockElements = false, }) : data = null, assert(document != null), documentElement = document!.documentElement, @@ -282,6 +287,7 @@ class SelectableHtml extends StatefulWidget { this.tagsList = const [], this.selectionControls, this.scrollPhysics, + this.ignoreBlockElements = false, }) : data = null, assert(documentElement != null), _anchorKey = anchorKey ?? GlobalKey(), @@ -327,10 +333,9 @@ class SelectableHtml extends StatefulWidget { /// Either return a custom widget for specific node types or return null to /// fallback to the default rendering. - final Map customRenders; + final Map customRenders; - static List get tags => - List.from(HtmlElements.selectableElements); + final bool ignoreBlockElements; @override State createState() => _SelectableHtmlState(); @@ -361,12 +366,12 @@ class _SelectableHtmlState extends State { onImageError: null, shrinkWrap: widget.shrinkWrap, selectable: true, + selectableIgnoreBlockWidgets: widget.ignoreBlockElements, style: widget.style, customRenders: {} ..addAll(widget.customRenders) ..addAll(generateDefaultRenders()), - tagsList: - widget.tagsList.isEmpty ? SelectableHtml.tags : widget.tagsList, + tagsList: widget.tagsList.isEmpty ? Html.tags : widget.tagsList, selectionControls: widget.selectionControls, scrollPhysics: widget.scrollPhysics, ), diff --git a/lib/html_parser.dart b/lib/html_parser.dart index 42f84b423a..e8ebfefcf1 100644 --- a/lib/html_parser.dart +++ b/lib/html_parser.dart @@ -33,6 +33,7 @@ class HtmlParser extends StatelessWidget { final ImageErrorListener? onImageError; final bool shrinkWrap; final bool selectable; + final bool selectableIgnoreBlockWidgets; final Map style; final Map customRenders; @@ -53,14 +54,13 @@ class HtmlParser extends StatelessWidget { required this.onCssParseError, required this.onImageError, required this.shrinkWrap, - @Deprecated('Wrapping the Html widget in a SelectionArea widget is preferred') - this.selectable = false, + required this.selectable, + required this.selectableIgnoreBlockWidgets, required this.style, required this.customRenders, required this.tagsList, this.root, - @Deprecated('Wrapping the Html widget in a SelectionArea widget is preferred') - this.selectionControls, + this.selectionControls, this.scrollPhysics, }) : internalOnAnchorTap = onAnchorTap ?? (key != null ? _handleAnchorTap(key, onLinkTap) : onLinkTap); @@ -348,20 +348,6 @@ class HtmlParser extends StatelessWidget { if (entry.call(newContext)) { buildChildren() => tree.children.map((tree) => parseTree(newContext, tree)).toList(); - if (newContext.parser.selectable && - customRenders[entry] is SelectableCustomRender) { - selectableBuildChildren() => tree.children - .map((tree) => parseTree(newContext, tree) as TextSpan) - .toList(); - return (customRenders[entry] as SelectableCustomRender) - .textSpan - .call(newContext, selectableBuildChildren); - } - if (newContext.parser.selectable) { - return customRenders[entry]! - .inlineSpan! - .call(newContext, buildChildren) as TextSpan; - } if (customRenders[entry]?.inlineSpan != null) { return customRenders[entry]! .inlineSpan! diff --git a/lib/src/css_box_widget.dart b/lib/src/css_box_widget.dart index 727095c0f4..e6b80b0b34 100644 --- a/lib/src/css_box_widget.dart +++ b/lib/src/css_box_widget.dart @@ -110,17 +110,18 @@ class CssBoxWidget extends StatelessWidget { return Container(); } - return SelectableText.rich( - TextSpan( + return SelectionArea( + selectionControls: selectionControls, + child: Text.rich( + TextSpan( + style: style.generateTextStyle(), + children: children, + ), style: style.generateTextStyle(), - children: children, + textAlign: style.textAlign, + textDirection: style.direction, + maxLines: style.maxLines, ), - style: style.generateTextStyle(), - textAlign: style.textAlign, - textDirection: style.direction, - maxLines: style.maxLines, - selectionControls: selectionControls, - scrollPhysics: scrollPhysics, ); } diff --git a/lib/src/html_elements.dart b/lib/src/html_elements.dart index 304c9ff395..72f6fe0e9d 100644 --- a/lib/src/html_elements.dart +++ b/lib/src/html_elements.dart @@ -141,67 +141,4 @@ class HtmlElements { ]; static const replacedExternalElements = ["iframe", "img", "video", "audio"]; - - static const selectableElements = [ - "br", - "a", - "article", - "aside", - "blockquote", - "body", - "center", - "dd", - "div", - "dl", - "dt", - "figcaption", - "figure", - "footer", - "h1", - "h2", - "h3", - "h4", - "h5", - "h6", - "header", - "hr", - "html", - "main", - "nav", - "noscript", - "p", - "pre", - "section", - "summary", - "abbr", - "acronym", - "address", - "b", - "bdi", - "bdo", - "big", - "cite", - "code", - "data", - "del", - "dfn", - "em", - "font", - "i", - "ins", - "kbd", - "mark", - "q", - "s", - "samp", - "small", - "span", - "strike", - "strong", - "time", - "tt", - "u", - "var", - "wbr", - ]; } diff --git a/test/flutter_html_test.dart b/test/flutter_html_test.dart index 30acdbe449..6a43154333 100644 --- a/test/flutter_html_test.dart +++ b/test/flutter_html_test.dart @@ -17,20 +17,6 @@ void main() { }, ); - testWidgets( - "Check that selectable widget does not fail on empty data", - (tester) async { - await tester.pumpWidget( - MaterialApp( - home: SelectableHtml( - data: '', - ), - ), - ); - expect(find.text('', findRichText: true), findsOneWidget); - }, - ); - testWidgets( "Check that widget displays given text", (tester) async { diff --git a/test/html_parser_test.dart b/test/html_parser_test.dart index 056de9c148..47fa3b1463 100644 --- a/test/html_parser_test.dart +++ b/test/html_parser_test.dart @@ -49,6 +49,7 @@ void testNewParser(BuildContext context) { onImageError: null, shrinkWrap: false, selectable: true, + selectableIgnoreBlockWidgets: true, style: const {}, customRenders: generateDefaultRenders(), tagsList: Html.tags, @@ -74,6 +75,7 @@ void testNewParser(BuildContext context) { onImageError: null, shrinkWrap: false, selectable: true, + selectableIgnoreBlockWidgets: true, style: const {}, customRenders: generateDefaultRenders(), tagsList: Html.tags, @@ -97,7 +99,8 @@ void testNewParser(BuildContext context) { onCssParseError: null, onImageError: null, shrinkWrap: false, - selectable: true, + selectable: false, + selectableIgnoreBlockWidgets: false, style: const {}, customRenders: generateDefaultRenders(), tagsList: Html.tags, @@ -122,7 +125,8 @@ void testNewParser(BuildContext context) { onCssParseError: null, onImageError: null, shrinkWrap: false, - selectable: true, + selectable: false, + selectableIgnoreBlockWidgets: false, style: const {}, customRenders: generateDefaultRenders(), tagsList: Html.tags, From a3ac46ced881d7c8efcbe4301914be5df75d765c Mon Sep 17 00:00:00 2001 From: Matthew Whitaker Date: Sat, 22 Oct 2022 15:14:08 -0600 Subject: [PATCH 3/3] breaking: Remove SelectableHtml --- lib/custom_render.dart | 17 ---- lib/flutter_html.dart | 182 ------------------------------------ lib/html_parser.dart | 11 --- lib/src/css_box_widget.dart | 37 +------- test/html_parser_test.dart | 16 ---- 5 files changed, 1 insertion(+), 262 deletions(-) diff --git a/lib/custom_render.dart b/lib/custom_render.dart index 6b013a3b50..b216f38643 100644 --- a/lib/custom_render.dart +++ b/lib/custom_render.dart @@ -104,23 +104,6 @@ class CustomRender { CustomRender blockElementRender({Style? style, List? children}) => CustomRender.inlineSpan(inlineSpan: (context, buildChildren) { - if (context.parser.selectable && - context.parser.selectableIgnoreBlockWidgets) { - return TextSpan( - style: context.style.generateTextStyle(), - children: (children as List?) ?? - context.tree.children - .expandIndexed((i, childTree) => [ - context.parser.parseTree(context, childTree), - if (i != context.tree.children.length - 1 && - childTree.style.display == Display.block && - childTree.element?.localName != "html" && - childTree.element?.localName != "body") - const TextSpan(text: "\n"), - ]) - .toList(), - ); - } return WidgetSpan( alignment: PlaceholderAlignment.baseline, baseline: TextBaseline.alphabetic, diff --git a/lib/flutter_html.dart b/lib/flutter_html.dart index 532a54641f..8d6296519e 100644 --- a/lib/flutter_html.dart +++ b/lib/flutter_html.dart @@ -188,8 +188,6 @@ class _HtmlState extends State { onCssParseError: widget.onCssParseError, onImageError: widget.onImageError, shrinkWrap: widget.shrinkWrap, - selectable: false, - selectableIgnoreBlockWidgets: false, style: widget.style, customRenders: {} ..addAll(widget.customRenders) @@ -198,183 +196,3 @@ class _HtmlState extends State { ); } } - -class SelectableHtml extends StatefulWidget { - /// The `SelectableHtml` widget takes HTML as input and displays a RichText - /// tree of the parsed HTML content (which is selectable) - /// - /// **Attributes** - /// **data** *required* takes in a String of HTML data (required only for `Html` constructor). - /// **documentElement** *required* takes in a Element of HTML data (required only for `Html.fromDom` and `Html.fromElement` constructor). - /// - /// **onLinkTap** This function is called whenever a link (``) - /// is tapped. - /// - /// **onAnchorTap** This function is called whenever an anchor (#anchor-id) - /// is tapped. - /// - /// **tagsList** Tag names in this array will be the only tags rendered. By default, all tags that support selectable content are rendered. - /// - /// **style** Pass in the style information for the Html here. - /// See [its wiki page](https://github.com/Sub6Resources/flutter_html/wiki/Style) for more info. - /// - /// **PLEASE NOTE** - /// - /// There are a few caveats due to Flutter [#38474](https://github.com/flutter/flutter/issues/38474): - /// - /// 1. The list of tags that can be rendered is significantly reduced. - /// Key omissions include no support for images/video/audio, table, and ul/ol because they all require widgets and `WidgetSpan`s. - /// - /// 2. No support for `customRender`, `customImageRender`, `onImageError`, `onImageTap`, `onMathError`, and `navigationDelegateForIframe`. - /// - /// 3. Styling support is significantly reduced. Only text-related styling works - /// (e.g. bold or italic), while container related styling (e.g. borders or padding/margin) - /// do not work because we can't use the `ContainerSpan` class (it needs an enclosing `WidgetSpan`). - - @Deprecated( - "Please use Flutter's new SelectionArea widget. Upgrade from SelectableHtml to Html and wrap the widget in a SelectionArea widget.") - SelectableHtml({ - Key? key, - GlobalKey? anchorKey, - required this.data, - this.onLinkTap, - this.onAnchorTap, - this.onCssParseError, - this.shrinkWrap = false, - this.style = const {}, - this.customRenders = const {}, - this.tagsList = const [], - this.selectionControls, - this.scrollPhysics, - this.ignoreBlockElements = false, - }) : documentElement = null, - assert(data != null), - _anchorKey = anchorKey ?? GlobalKey(), - super(key: key); - - @Deprecated( - "Please use Flutter's new SelectionArea widget. Upgrade from SelectableHtml to Html and wrap the widget in a SelectionArea widget.") - SelectableHtml.fromDom({ - Key? key, - GlobalKey? anchorKey, - @required dom.Document? document, - this.onLinkTap, - this.onAnchorTap, - this.onCssParseError, - this.shrinkWrap = false, - this.style = const {}, - this.customRenders = const {}, - this.tagsList = const [], - this.selectionControls, - this.scrollPhysics, - this.ignoreBlockElements = false, - }) : data = null, - assert(document != null), - documentElement = document!.documentElement, - _anchorKey = anchorKey ?? GlobalKey(), - super(key: key); - - SelectableHtml.fromElement({ - Key? key, - GlobalKey? anchorKey, - @required this.documentElement, - this.onLinkTap, - this.onAnchorTap, - this.onCssParseError, - this.shrinkWrap = false, - this.style = const {}, - this.customRenders = const {}, - this.tagsList = const [], - this.selectionControls, - this.scrollPhysics, - this.ignoreBlockElements = false, - }) : data = null, - assert(documentElement != null), - _anchorKey = anchorKey ?? GlobalKey(), - super(key: key); - - /// A unique key for this Html widget to ensure uniqueness of anchors - final GlobalKey _anchorKey; - - /// The HTML data passed to the widget as a String - final String? data; - - /// The HTML data passed to the widget as a pre-processed [dom.Element] - final dom.Element? documentElement; - - /// A function that defines what to do when a link is tapped - final OnTap? onLinkTap; - - /// A function that defines what to do when an anchor link is tapped. When this value is set, - /// the default anchor behaviour is overwritten. - final OnTap? onAnchorTap; - - /// A function that defines what to do when CSS fails to parse - final OnCssParseError? onCssParseError; - - /// A parameter that should be set when the HTML widget is expected to be - /// have a flexible width, that doesn't always fill its maximum width - /// constraints. For example, auto horizontal margins are ignored, and - /// block-level elements only take up the width they need. - final bool shrinkWrap; - - /// A list of HTML tags that are the only tags that are rendered. By default, this list is empty and all supported HTML tags are rendered. - final List tagsList; - - /// An API that allows you to override the default style for any HTML element - final Map style; - - /// Custom Selection controls allows you to override default toolbar and build custom toolbar - /// options - final TextSelectionControls? selectionControls; - - /// Allows you to override the default scrollPhysics for [SelectableText.rich] - final ScrollPhysics? scrollPhysics; - - /// Either return a custom widget for specific node types or return null to - /// fallback to the default rendering. - final Map customRenders; - - final bool ignoreBlockElements; - - @override - State createState() => _SelectableHtmlState(); -} - -class _SelectableHtmlState extends State { - late final dom.Element documentElement; - - @override - void initState() { - super.initState(); - documentElement = widget.data != null - ? HtmlParser.parseHTML(widget.data!) - : widget.documentElement!; - } - - @override - Widget build(BuildContext context) { - return SizedBox( - width: widget.shrinkWrap ? null : MediaQuery.of(context).size.width, - child: HtmlParser( - key: widget._anchorKey, - htmlData: documentElement, - onLinkTap: widget.onLinkTap, - onAnchorTap: widget.onAnchorTap, - onImageTap: null, - onCssParseError: widget.onCssParseError, - onImageError: null, - shrinkWrap: widget.shrinkWrap, - selectable: true, - selectableIgnoreBlockWidgets: widget.ignoreBlockElements, - style: widget.style, - customRenders: {} - ..addAll(widget.customRenders) - ..addAll(generateDefaultRenders()), - tagsList: widget.tagsList.isEmpty ? Html.tags : widget.tagsList, - selectionControls: widget.selectionControls, - scrollPhysics: widget.scrollPhysics, - ), - ); - } -} diff --git a/lib/html_parser.dart b/lib/html_parser.dart index e8ebfefcf1..6777df471d 100644 --- a/lib/html_parser.dart +++ b/lib/html_parser.dart @@ -32,16 +32,12 @@ class HtmlParser extends StatelessWidget { final OnCssParseError? onCssParseError; final ImageErrorListener? onImageError; final bool shrinkWrap; - final bool selectable; - final bool selectableIgnoreBlockWidgets; final Map style; final Map customRenders; final List tagsList; final OnTap? internalOnAnchorTap; final Html? root; - final TextSelectionControls? selectionControls; - final ScrollPhysics? scrollPhysics; final Map cachedImageSizes = {}; @@ -54,14 +50,10 @@ class HtmlParser extends StatelessWidget { required this.onCssParseError, required this.onImageError, required this.shrinkWrap, - required this.selectable, - required this.selectableIgnoreBlockWidgets, required this.style, required this.customRenders, required this.tagsList, this.root, - this.selectionControls, - this.scrollPhysics, }) : internalOnAnchorTap = onAnchorTap ?? (key != null ? _handleAnchorTap(key, onLinkTap) : onLinkTap); @@ -101,9 +93,6 @@ class HtmlParser extends StatelessWidget { return CssBoxWidget.withInlineSpanChildren( style: processedTree.style, children: [parsedTree], - selectable: selectable, - scrollPhysics: scrollPhysics, - selectionControls: selectionControls, shrinkWrap: shrinkWrap, ); } diff --git a/lib/src/css_box_widget.dart b/lib/src/css_box_widget.dart index e6b80b0b34..86669d7fa4 100644 --- a/lib/src/css_box_widget.dart +++ b/lib/src/css_box_widget.dart @@ -22,17 +22,7 @@ class CssBoxWidget extends StatelessWidget { this.textDirection, this.childIsReplaced = false, this.shrinkWrap = false, - bool selectable = false, - TextSelectionControls? selectionControls, - ScrollPhysics? scrollPhysics, - }) : child = selectable - ? _generateSelectableWidgetChild( - children, - style, - selectionControls, - scrollPhysics, - ) - : _generateWidgetChild(children, style); + }) : child = _generateWidgetChild(children, style); /// The child to be rendered within the CSS Box. final Widget child; @@ -100,31 +90,6 @@ class CssBoxWidget extends StatelessWidget { ); } - static Widget _generateSelectableWidgetChild( - List children, - Style style, - TextSelectionControls? selectionControls, - ScrollPhysics? scrollPhysics, - ) { - if (children.isEmpty) { - return Container(); - } - - return SelectionArea( - selectionControls: selectionControls, - child: Text.rich( - TextSpan( - style: style.generateTextStyle(), - children: children, - ), - style: style.generateTextStyle(), - textAlign: style.textAlign, - textDirection: style.direction, - maxLines: style.maxLines, - ), - ); - } - /// Whether or not the content-box should expand its width to fill the /// width available to it or if it should just let its inner content /// determine the content-box's width. diff --git a/test/html_parser_test.dart b/test/html_parser_test.dart index 47fa3b1463..18482c8344 100644 --- a/test/html_parser_test.dart +++ b/test/html_parser_test.dart @@ -48,13 +48,9 @@ void testNewParser(BuildContext context) { onCssParseError: null, onImageError: null, shrinkWrap: false, - selectable: true, - selectableIgnoreBlockWidgets: true, style: const {}, customRenders: generateDefaultRenders(), tagsList: Html.tags, - selectionControls: null, - scrollPhysics: null, ), ); @@ -74,13 +70,9 @@ void testNewParser(BuildContext context) { onCssParseError: null, onImageError: null, shrinkWrap: false, - selectable: true, - selectableIgnoreBlockWidgets: true, style: const {}, customRenders: generateDefaultRenders(), tagsList: Html.tags, - selectionControls: null, - scrollPhysics: null, ), ); @@ -99,13 +91,9 @@ void testNewParser(BuildContext context) { onCssParseError: null, onImageError: null, shrinkWrap: false, - selectable: false, - selectableIgnoreBlockWidgets: false, style: const {}, customRenders: generateDefaultRenders(), tagsList: Html.tags, - selectionControls: null, - scrollPhysics: null, ), ); @@ -125,13 +113,9 @@ void testNewParser(BuildContext context) { onCssParseError: null, onImageError: null, shrinkWrap: false, - selectable: false, - selectableIgnoreBlockWidgets: false, style: const {}, customRenders: generateDefaultRenders(), tagsList: Html.tags, - selectionControls: null, - scrollPhysics: null, ), );