Open Gustl22 opened 4 months ago
Reproducible using the code sample provided above.
Framework team: is it expected that a package bug could cause this error? It's not clear to me from the stack.
cc @Renzo-Olivares
I just encountered the same error using a regular Scaffold
with GoRouter
and SelectionArea
. Are there any updates on this?
It may has to do with the fact, that the same scaffold is stacked on top via the navigation, and the selection_area may confuses them (?). ~If I wrap the secondaryBody
within its own SelectionArea
, it doesn't throw an error.~ Edit: Still occurs from time to time.
Seems related to #114254
@helpisdev @sunenvidiado-nx @gabrielrf97 you may want to thumb up (+1) the original issue description to support pushing this issue. I think comments like this should be avoided: https://github.com/flutter/flutter/tree/master/docs/contributing/issue_hygiene#comments
A theory: I adapted the example to better debug the thing.
AdaptiveScaffold
stacked on top of each other.rootA
and rootB
from the root AdaptiveScaffold
and subA
and subB
from the subpage are added to the SelectionArea tree.RenderFractionalTranslation#40372 NEEDS-LAYOUT NEEDS-PAINT
, so these are the two selectable Texts from the root Scaffold: A
and B
.AdaptiveScaffold
uses _SlotIds to layout the childs. ~I think these slot ids are not unique, if there are multiple AdaptiveScaffold
s involved, so it just layouts the wrong child Text
by chance. I can't really tell, why this is only the case, when both, the secondaryBody and the body are present.~ Edit: I might be wrong as the MultiChildLayoutDelegate._idToChild
of _AdaptiveLayoutDelegate
only exists in its own context.So it would be a flutter_adaptive_scaffold
package issue. Can this be correct?
But in general it would be good to have better logging message, which widget is responsible for the error.
I could reproduce it without flutter_adaptive_scaffold
. The problem is, that the SelectableArea
tries to compare the selectables (if there are more than 2), and then cannot determine the size of the ones of the root
page, because they weren't even layouted.
Cc: @Renzo-Olivares
Steps to reproduce
Execute the code sample (tested on
web
ormacos
)Expected results
To not throw any error
Actual results
But nothing visually wrong.
Code sample
Code sample
```dart import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { final router = GoRouter( // Default to the nested location // Or for a more realistic use-case, navigate to the url /a/b on the web initialLocation: '/root/sub', routes: [ GoRoute( path: '/root', builder: (_, __) { // With selection area here, error will occur return const SelectionArea( child: Column( children: [ // Must be at least two selectable texts Text('rootA'), Text('rootB'), ], ), ); }, routes: [ GoRoute( path: 'sub', builder: (_, __) { return const SelectionArea( child: Column( children: [ // Must be at least two selectable texts Text('subA'), Text('subB'), ], ), ); }, ), ], ), ], ); return MaterialApp.router( routerConfig: router, ); } } ```Screenshots or Video
Screenshots / Video demonstration
[Upload media here]Logs
Logs
Web: ```console Launching lib/test_main.dart on Chrome in debug mode... Waiting for connection from debug service on Chrome... This app is linked to the debug service: ws://127.0.0.1:56108/pmYkwM1S-38=/ws Debug service listening on ws://127.0.0.1:56108/pmYkwM1S-38=/ws Debug service listening on ws://127.0.0.1:56108/pmYkwM1S-38=/ws ======== Exception caught by scheduler library ===================================================== The following assertion was thrown during a scheduler callback: Assertion failed: file:///opt/homebrew/Caskroom/flutter/3.22.2/flutter/packages/flutter/lib/src/rendering/box.dart:2165:12 hasSize "RenderBox was not laid out: RenderFractionalTranslation#d1f01 NEEDS-LAYOUT NEEDS-PAINT" When the exception was thrown, this was the stack: dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3 throw_ dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3 assertFailed packages/flutter/src/rendering/box.dart 2165:12 get size packages/flutter/src/rendering/proxy_box.dart 2936:29 applyPaintTransform packages/flutter/src/rendering/object.dart 3354:22 getTransformTo packages/flutter/src/rendering/paragraph.dart 2003:22 getTransformTo packages/flutter/src/widgets/selectable_region.dart 1925:8 [_compareScreenOrder] dart-sdk/lib/internal/sort.dart 69:51 _insertionSort dart-sdk/lib/internal/sort.dart 58:7 _doSort dart-sdk/lib/internal/sort.dart 33:5 sort dart-sdk/lib/_internal/js_dev_runtime/private/js_array.dart 471:12 sort] packages/flutter/src/widgets/selectable_region.dart 1824:70Flutter Doctor output
Doctor output
```console [✓] Flutter (Channel stable, 3.22.2, on macOS 14.6 23G5061b darwin-arm64, locale en-US) • Flutter version 3.22.2 on channel stable at /opt/homebrew/Caskroom/flutter/3.22.2/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 761747bfc5 (5 weeks ago), 2024-06-05 22:15:13 +0200 • Engine revision edd8546116 • Dart version 3.4.3 • DevTools version 2.34.3 [!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) • Android SDK at /Users/swi-oberhauser/Library/Android/sdk ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 15.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15F31d • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions). [✓] IntelliJ IDEA Ultimate Edition (version 2024.1.3) • IntelliJ at /Applications/IntelliJ IDEA.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 [✓] IntelliJ IDEA Community Edition (version 2024.1.4) • IntelliJ at /Applications/IntelliJ IDEA CE.app • Flutter plugin version 80.0.2 • Dart plugin version 241.17890.8 [✓] Connected device (3 available) • macOS (desktop) • macos • darwin-arm64 • macOS 14.6 23G5061b darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.6 23G5061b darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 2 categories ```Related
117527
114254