Remove assert that prevents WidgetSpans from being used in SelectableText (#92295)

This commit is contained in:
Gary Qian
2021-10-25 16:23:03 -07:00
committed by GitHub
parent 4d79bb02c4
commit 1daae0b0ae
2 changed files with 7 additions and 5 deletions

View File

@@ -585,9 +585,11 @@ class _SelectableTextState extends State<SelectableText> with AutomaticKeepAlive
@override
Widget build(BuildContext context) {
super.build(context); // See AutomaticKeepAliveClientMixin.
assert(() {
return _controller._textSpan.visitChildren((InlineSpan span) => span.runtimeType == TextSpan);
}(), 'SelectableText only supports TextSpan; Other type of InlineSpan is not allowed');
// TODO(garyq): Assert to block WidgetSpans from being used here are removed,
// but we still do not yet have nice handling of things like carets, clipboard,
// and other features. We should add proper support. Currently, caret handling
// is blocked on SkParagraph switch and https://github.com/flutter/engine/pull/27010
// should be landed in SkParagraph after the switch is complete.
assert(debugCheckHasMediaQuery(context));
assert(debugCheckHasDirectionality(context));
assert(

View File

@@ -319,7 +319,7 @@ void main() {
expect(selectableText.enableInteractiveSelection, true);
});
testWidgets('Rich selectable text only support TextSpan', (WidgetTester tester) async {
testWidgets('Rich selectable text supports WidgetSpan', (WidgetTester tester) async {
await tester.pumpWidget(
const MediaQuery(
data: MediaQueryData(),
@@ -357,7 +357,7 @@ void main() {
),
),
);
expect(tester.takeException(), isAssertionError);
expect(tester.takeException(), isNull);
});
testWidgets('no text keyboard when widget is focused', (WidgetTester tester) async {