Skip to content

flutter_test finders still references flutter/material Tooltip widget #191063

Closed
flutter/packages
#12492

Description

@hanskokx

Steps to reproduce

  1. Ensure you are using Flutter 3.47 with the material_ui package
  2. Create a widget that exposes a Tooltip widget from the material_ui package
  3. Write a test to ensure the Tooltip is visible by using find.byTooltip

Expected results

Tests should pass

Actual results

Tests fail

Code sample

Code sample
testWidgets("Custom tooltips in NavigationBarDestination",
      (WidgetTester tester) async {
    await tester.pumpWidget(
      MaterialApp(
        home: Scaffold(
          bottomNavigationBar: NavigationBar(
            destinations: const <NavigationDestination>[
              NavigationDestination(
                label: "A",
                tooltip: "A tooltip",
                icon: Icon(Icons.ac_unit),
              ),
              NavigationDestination(
                label: "B",
                icon: Icon(Icons.battery_alert),
              ),
              NavigationDestination(
                label: "C",
                icon: Icon(Icons.cake),
                tooltip: "",
              ),
            ],
          ),
        ),
      ),
    );

    expect(find.text("A"), findsOneWidget);
    await tester.longPress(find.text("A"));
    expect(find.byTooltip("A tooltip"), findsOneWidget);

    expect(find.text("B"), findsOneWidget);
    await tester.longPress(find.text("B"));
    expect(find.byTooltip("B"), findsOneWidget);

    expect(find.text("C"), findsOneWidget);
    await tester.longPress(find.text("C"));
    expect(find.byTooltip("C"), findsNothing);
  });

Screenshots or Video

Logs

Logs
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: exactly one matching candidate
  Actual: _WidgetPredicateWidgetFinder:<Found 0 widgets with widget matching predicate: []>
   Which: means none were found but one was expected

When the exception was thrown, this was the stack:
#4      main.<anonymous closure> (file:///Users/hans/Projects/custom_adaptive_scaffold/test/framework_mirror/navigation_bar_test.dart:549:5)
<asynchronous suspension>
#5      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:192:15)
<asynchronous suspension>
#6      TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1953:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

This was caught by the test expectation on the following line:
  file:///Users/hans/Projects/custom_adaptive_scaffold/test/framework_mirror/navigation_bar_test.dart line 549
The test description was:
  Custom tooltips in NavigationBarDestination
════════════════════════════════════════════════════════════════════════════════════════════════════

Analysis

The bug appears to be in flutter_test/lib/src/finders.dart on line 13:

import 'package:flutter/material.dart' show Tooltip;

Rather than referencing the new material_ui package, it's expecting a Tooltip rom the old flutter/material.dart.

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.47.0, on macOS 26.5.2 25F84 darwin-arm64, locale en-US) [196ms]
    • Flutter version 3.47.0 on channel stable at /Users/hans/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cf2416426 (2 days ago), 2026-08-11 11:53:49 -0700
    • Engine revision 5f77625673
    • Dart version 3.13.0
    • DevTools version 2.60.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets,
      enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration

[✓] Android toolchain - develop for Android devices (Android SDK version 37.0.0) [852ms]
    • Android SDK at /Users/hans/Library/Android/sdk
    • Emulator version 37.1.11.0 (build_id 15917651) (CL:N/A)
    • Platform android-37.1, build-tools 37.0.0
    • ANDROID_SDK_ROOT = /Users/hans/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 25.0.2+-15348964-b329.117)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.6) [458ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17F113
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [3ms]
    • CHROME_EXECUTABLE = /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (2 available) [5.7s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 26.5.2 25F84 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 151.0.7922.137
    ! Error: Browsing on the local area network for Hackberry Hans iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources [249ms]
    • All expected network resources are available.

• No issues found!

Activity

  1. suryaKommana2662 commented on Aug 13, 2026

    @suryaKommana2662
    Contributor

    @hanskokx Thanks for the report. I tried reproducing the issue using the provided test case on Flutter 3.47.0, but the test passes successfully with:

    00:04 +1: All tests passed!

    I have attached my test/tooltip_test.dart file for reference. Could you please provide a minimal reproducible project and including the pubspec.yaml.

    tooltip_test.dart file

    import 'package:flutter/material.dart';
    import 'package:flutter_test/flutter_test.dart';
    
    void main() {
      testWidgets("Custom tooltips in NavigationBarDestination",
              (WidgetTester tester) async {
            await tester.pumpWidget(
              MaterialApp(
                home: Scaffold(
                  bottomNavigationBar: NavigationBar(
                    destinations: const <NavigationDestination>[
                      NavigationDestination(
                        label: "A",
                        tooltip: "A tooltip",
                        icon: Icon(Icons.ac_unit),
                      ),
                      NavigationDestination(
                        label: "B",
                        icon: Icon(Icons.battery_alert),
                      ),
                      NavigationDestination(
                        label: "C",
                        icon: Icon(Icons.cake),
                        tooltip: "",
                      ),
                    ],
                  ),
                ),
              ),
            );
    
            expect(find.text("A"), findsOneWidget);
            await tester.longPress(find.text("A"));
            expect(find.byTooltip("A tooltip"), findsOneWidget);
    
            expect(find.text("B"), findsOneWidget);
            await tester.longPress(find.text("B"));
            expect(find.byTooltip("B"), findsOneWidget);
    
            expect(find.text("C"), findsOneWidget);
            await tester.longPress(find.text("C"));
            expect(find.byTooltip("C"), findsNothing);
          });
    }

    Flutter Doctor Output

    [✓] Flutter (Channel stable, 3.47.0, on macOS 26.4 25E246 darwin-arm64, locale en-IN) [760ms]
        • Flutter version 3.47.0 on channel stable at /Users/suryakommana/develop/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 4cf2416426 (2 days ago), 2026-08-11 11:53:49 -0700
        • Engine revision 5f77625673
        • Dart version 3.13.0
        • DevTools version 2.60.0
        • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets,
          enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,414ms]
        • Android SDK at /Users/suryakommana/Library/Android/sdk
        • Emulator version 37.1.11.0 (build_id 15917651) (CL:N/A)
        • Platform android-37.0, build-tools 36.0.0
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
          This is the JDK bundled with the latest Android Studio installation on this machine.
          To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 25.0.2+-15348964-b329.117)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 26.6) [645ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 17F113
        • CocoaPods version 1.17.0
    
    [✓] Chrome - develop for the web [5ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Connected device (4 available) [5.8s]
        • sdk gphone16k arm64 (mobile) • emulator-5554                        • android-arm64  • Android 17 (API 37) (emulator)
        • iPhone 17 (mobile)           • E354ECD5-7984-44E0-9C38-082B39E72C88 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-26-5 (simulator)
        • macOS (desktop)              • macos                                • darwin-arm64   • macOS 26.4 25E246 darwin-arm64
        • Chrome (web)                 • chrome                               • web-javascript • Google Chrome 151.0.7922.109
    
    [✓] Network resources [482ms]
        • All expected network resources are available.
    
    • No issues found!
  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    and removed
    in triagePresently being triaged by the triage team
    on Aug 13, 2026
  3. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 13, 2026
  4. suryaKommana2662 commented on Aug 13, 2026

    @suryaKommana2662
    Contributor

    @hanskokx Thanks for providing the repository. I pulled the custom_adaptive_scaffold/tree/6.0.0-dev branch and was able to reproduce the issue locally on Flutter 3.47.0. I ran the specific test with:

    flutter test test/framework_mirror/navigation_bar_test.dart \
      --name "Custom tooltips in NavigationBarDestination"
    

    The test fails with:

    Expected: exactly one matching candidate
    Actual: _WidgetPredicateWidgetFinder:
    Found 0 widgets with widget matching predicate: []
    

    The failure occurs at navigation_bar_test.dart:575, matching the reported behavior. Routing to the team-framework for further investigation.

  5. added
    a: tests"flutter test", flutter_test, or one of our tests
    frameworkflutter/packages/flutter repository. See also f: labels.
    team-designOwned by Design Languages team
    fyi-frameworkFor the attention of Framework team
    and removed
    in triagePresently being triaged by the triage team
    on Aug 13, 2026
  6. 6 remaining items

  7. self-assigned this
    on Aug 17, 2026
  8. added
    P1High-priority issues at the top of the work list
    P2Important issues not at the top of the work list
    and removed
    P1High-priority issues at the top of the work list
    on Aug 18, 2026
  9. hanskokx commented on Aug 21, 2026

    @hanskokx
    Author

    I've introduced the findByTooltip method directly in my test (see this commit), as it did not appear to be exported via the material_ui package. The test now passes, however I had expected the method to be exported from material_ui and it was a bit odd to me that it wasn't.

  10. github-actions commented on Sep 16, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  11. locked as resolved and limited conversation to collaborators on Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our testsframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions