Repository navigation
[Flutter Driver] tap on a Sliver throws an exception #67743
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolef: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.6Found to occur in 3.6Found to occur in 3.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work ont: flutter driver"flutter driver", flutter_drive, or a driver test"flutter driver", flutter_drive, or a driver testteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.Issues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool team
Description
Flutter driver throwing the error:
await driver.tap(find.byType('RenderSliverStickyHeader'));
Error thrown:
DriverError: Error in Flutter application: Uncaught extension error while executing tap: type 'RenderSliverStickyHeader' is not a subtype of type 'RenderBox' in type cast
#0 _HitTestableFinder.filter.<anonymous closure> (package:flutter_test/src/finders.dart:504:52)
#1 _SyncIterator.moveNext (dart:core-patch/core_patch.dart:165:25)
#2 Iterable.isEmpty (dart:core/iterable.dart:440:33)
#3 Iterable.isNotEmpty (dart:core/iterable.dart:447:27)
#4 FlutterDriverExtension._waitForElement.<anonymous closure> (package:flutter_driver/src/extension/extension.dart:278:51)
#5 FlutterDriverExtension._waitUntilFrame (package:flutter_driver/src/extension/extension.dart:263:19)
#6 FlutterDriverExtension._waitForElement (package:flutter_driver/src/extension/extension.dart:278:11)
<asynchronous suspension>
#7 FlutterDriverExtension._tap (package:flutter_driver/src/extension/extension.dart:385:41)
#8 FlutterDriverExtension.call (package:flutter_driver/src/extension/extension.dart:216:53)
#9 BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart:547:32)
<asynchronous suspension>
#10 BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart)
#11 _runExtension (dart:developer-patch/developer.dart:84:23)
The code from package:flutter_test/src/finders.dart that results in the error:
@override
Iterable<Element> filter(Iterable<Element> parentCandidates) sync* {
for (final Element candidate in parentCandidates) {
final RenderBox box = candidate.renderObject as RenderBox;
assert(box != null);
final Offset absoluteOffset = box.localToGlobal(alignment.alongSize(box.size));
final HitTestResult hitResult = HitTestResult();
WidgetsBinding.instance!.hitTest(hitResult, absoluteOffset);
for (final HitTestEntry entry in hitResult.path) {
if (entry.target == candidate.renderObject) {
yield candidate;
break;
}
}
}
}
As this Widget is a Sliver, it cannot be cast to a RenderBox. I did not work much with Slivers, I am therefore unsure how this is correctly implemented for them. I know that they work with geometry, but I don't know how to get the absoluteOffset for the calculation.
If someone could point me to the right direction, I would create a PR for this
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolef: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.6Found to occur in 3.6Found to occur in 3.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work ont: flutter driver"flutter driver", flutter_drive, or a driver test"flutter driver", flutter_drive, or a driver testteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.Issues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool team
Activity
pedromassangocode commentedon Nov 10, 2020
Hi @Xavjer
Can you please provide your
flutter doctor -v, yourpubspec.yamland a minimal reproducible code sample?Thank you
Xavjer commentedon Nov 10, 2020
Hi @pedromassangocode I just pushed a sample of this issue here:
https://github.com/Xavjer/slivertaptest
Run driver like in the official example:
flutter drive --target=test_driver/app.dartI am currently working with 1.21.0-9.1.pre, but I also tried this with never versions and the issue is happening there too.
pedromassangocode commentedon Nov 11, 2020
Reproducible on
masteras well.Logs
flutter doctor -v
huycozy commentedon Nov 24, 2022
This issue is reproducible on the latest
stableandmasterchannels with provided sample code.Logs
flutter doctor -v (stable and master)
[✓] Flutter (Channel stable, 3.3.9, on macOS 13.0 22A380 darwin-x64, locale en-VN) • Flutter version 3.3.9 on channel stable at /Users/huynq/Documents/GitHub/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision b8f7f1f986 (31 hours ago), 2022-11-23 06:43:51 +0900 • Engine revision 8f2221fbef • Dart version 2.18.5 • DevTools version 2.15.0 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/huynq/Library/Android/sdk • Platform android-33, build-tools 31.0.0 • ANDROID_HOME = /Users/huynq/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14A400 • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) [✓] IntelliJ IDEA Community Edition (version 2022.2.2) • IntelliJ at /Applications/IntelliJ IDEA CE.app • Flutter plugin version 70.0.5 • Dart plugin version 222.4167.21 [✓] IntelliJ IDEA Community Edition (version 2022.1.1) • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart [✓] VS Code (version 1.73.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.52.0 [✓] Connected device (3 available) • SM T225 (mobile) • R9JT3004VRJ • android-arm64 • Android 12 (API 31) • macOS (desktop) • macos • darwin-x64 • macOS 13.0 22A380 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.110 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found!4 remaining items
artemperegut commentedon Dec 27, 2023
Still reproducible on 3.7.12.
Logs
matanlurey commentedon Jul 10, 2025
This isn't a bug -
tapcan only be used on widgets that correspond to aRenderBox.In the examples above, you'd tap an element in the
*Sliver, instead of the*Sliveritself.That being said - it should not crash, there are error messages in other cases in
flutter_test, but the_HitTestable*class casts eagerly without checking - we should fix that by considering objects that are not hit-testable (i.e. Slivers)falseinstead of crashing.Give an actionable error to `flutter_test.*tap` of a `RenderSliver` (#…
Give an actionable error to `flutter_test.*tap` of a `RenderSliver` (f…
github-actions commentedon Jul 24, 2025
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 -vand a minimal reproduction of the issue.Give an actionable error to `flutter_test.*tap` of a `RenderSliver` (f…
Give an actionable error to `flutter_test.*tap` of a `RenderSliver` (f…
Give an actionable error to `flutter_test.*tap` of a `RenderSliver` (f…
Give an actionable error to `flutter_test.*tap` of a `RenderSliver` (f…
Give an actionable error to `flutter_test.*tap` of a `RenderSliver` (…