Skip to content

TextSpan with recognizer in ListTile fails assertion #54665

@nachtmaar

Description

@nachtmaar

Steps to Reproduce

$ flutter test <file.dart>
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  testWidgets("ups ...", (WidgetTester tester) async {
    TextSpan w = TextSpan(
      text: 'foo',
      style: TextStyle(color: Colors.blueAccent, fontWeight: FontWeight.bold),
      recognizer: TapGestureRecognizer()
        ..onTap = () {
          // navigate to desired screen
        },
    );

    await tester.pumpWidget(
      MaterialApp(
        home: Scaffold(
          body: SwitchListTile(
            title: RichText(
              text: w,
            ),
            value: false,
            onChanged: (_) {},
          ),
        ),
      ),
    );
    await tester.pumpAndSettle();
  });
}

Expected results:
Test succeeds.

Actual results:
Test fails with the following error:

══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
'package:flutter/src/semantics/semantics.dart': Failed assertion: line 2626 pos 16: 'node.parent ==
null || !node.parent.isPartOfNodeMerging || node.isMergedIntoParent': is not true.

See flutter test in Logs for whole output!

Logs
Testing started at 16:54 ...
/Users/xxxxxx/development/flutter/bin/flutter --no-color test --machine --plain-name "ups ..." test/widget/richtext_link_test.dart
══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
'package:flutter/src/semantics/semantics.dart': Failed assertion: line 2626 pos 16: 'node.parent ==
null || !node.parent.isPartOfNodeMerging || node.isMergedIntoParent': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially
more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=BUG.md

When the exception was thrown, this was the stack:
#2      SemanticsOwner.sendSemanticsUpdate (package:flutter/src/semantics/semantics.dart:2626:16)
#3      PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1042:23)
#4      AutomatedTestWidgetsFlutterBinding.drawFrame (package:flutter_test/src/binding.dart:985:31)
#5      RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:283:5)
#6      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1102:15)
#7      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1041:9)
#8      AutomatedTestWidgetsFlutterBinding.pump.<anonymous closure> (package:flutter_test/src/binding.dart:872:9)
#11     TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:69:41)
#12     AutomatedTestWidgetsFlutterBinding.pump (package:flutter_test/src/binding.dart:859:27)
#13     WidgetTester.pumpWidget.<anonymous closure> (package:flutter_test/src/widget_tester.dart:323:22)
#16     TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:69:41)
#17     WidgetTester.pumpWidget (package:flutter_test/src/widget_tester.dart:320:27)
#18     main.<anonymous closure> (file:///Users/xxxxxx77/coding-pers/glutyfree/frontend-flutter/test/widget/richtext_link_test.dart:16:18)
#20     main.<anonymous closure> (file:///Users/xxxxxx77/coding-pers/glutyfree/frontend-flutter/test/widget/richtext_link_test.dart:6:26)
#21     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:124:25)
#23     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:122:9)
#24     TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:696:19)
#38     AutomatedTestWidgetsFlutterBinding.runTest.<anonymous closure> (package:flutter_test/src/binding.dart:1066:17)
#40     AutomatedTestWidgetsFlutterBinding.runTest.<anonymous closure> (package:flutter_test/src/binding.dart:1054:35)
(elided 37 frames from class _AssertionError, class _FakeAsync, package dart:async, package dart:async-patch, and package stack_trace)
════════════════════════════════════════════════════════════════════════════════════════════════════

Test failed. See exception logs above.
The test description was: ups ...

Nothing to show, test is provided.

[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E266, locale en-DE)
    • Flutter version 1.12.13+hotfix.9 at /Users/xxxxxx/development/flutter
    • Framework revision f139b11009 (2 weeks ago), 2020-03-30 13:57:30 -0700
    • Engine revision af51afceb8
    • Dart version 2.7.2

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
    • Android SDK at /Users/xxxxxx/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.4, Build version 11E146
    • CocoaPods version 1.9.1

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.0.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.40.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.7.0

[✓] Connected device (3 available)
    • Android SDK built for x86 • emulator-5554                        • android-x86 • Android 10 (API 29) (emulator)
    • iPhone 11 Pro             • F5B265ED-92AE-4C3E-BCBB-FB695B0CF5A2 • ios         • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
    • iPhone 11 Pro Max         • 40A5CB14-4898-4953-B776-B83CAFFCC589 • ios         • com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: tests"flutter test", flutter_test, or one of our testsa: typographyText rendering, possibly libtxtf: material designflutter/packages/flutter/material repository.found in release: 3.3Found to occur in 3.3found in release: 3.6Found to occur in 3.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions