Repository navigation
Improve documentation and assert for Stack.textDirection; also, API docs for Localizations should admit to adding a Directionality #13013
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkc: crashStack traces logged to the consoleStack traces logged to the consoled: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.waiting for PR to land (fixed)A fix is in flightA fix is in flight
Milestone
Description
Steps to Reproduce
The following empty Stack layout trips an assertion.
import 'package:flutter/widgets.dart';
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
MyApp() {
}
@override
Widget build(BuildContext context) {
return new Stack();
}
}Logs
I/flutter (24950): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (24950): The following assertion was thrown during performLayout():
I/flutter (24950): 'package:flutter/src/painting/alignment.dart': Failed assertion: line 513 pos 12: 'direction !=
I/flutter (24950): null': is not true.
I/flutter (24950):
I/flutter (24950): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (24950): more information in this error message to help you determine and fix the underlying cause.
I/flutter (24950): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (24950): https://github.com/flutter/flutter/issues/new
I/flutter (24950):
I/flutter (24950): When the exception was thrown, this was the stack:
I/flutter (24950): #2 AlignmentDirectional.resolve (package:flutter/src/painting/alignment.dart:513:12)
I/flutter (24950): #3 RenderStack._resolve (package:flutter/src/rendering/stack.dart:327:36)
I/flutter (24950): #4 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:436:5)
I/flutter (24950): #5 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter (24950): #6 RenderView.performLayout (package:flutter/src/rendering/view.dart:142:13)
I/flutter (24950): #7 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1837:7)
I/flutter (24950): #8 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1126:18)
I/flutter (24950): #9 BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:262:19)
I/flutter (24950): #10 BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:581:22)
I/flutter (24950): #11 BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:200:5)
I/flutter (24950): #12 BindingBase&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:713:15)
I/flutter (24950): #13 BindingBase&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:649:9)
I/flutter (24950): #14 BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/rendering/binding.dart:286:20)
I/flutter (24950): #16 _Timer._runTimers (dart:isolate-patch/dart:isolate/timer_impl.dart:367)
I/flutter (24950): #17 _Timer._handleMessage (dart:isolate-patch/dart:isolate/timer_impl.dart:401)
I/flutter (24950): #18 _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:163)
I/flutter (24950): (elided 3 frames from class _AssertionError and package dart:async-patch)
I/flutter (24950):
I/flutter (24950): The following RenderObject was being processed when the exception was fired:
I/flutter (24950): RenderStack#46ac0 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (24950): creator: Stack ← MyApp ← [root]
I/flutter (24950): parentData: <none>
I/flutter (24950): constraints: BoxConstraints(w=1024.0, h=768.0)
I/flutter (24950): size: MISSING
I/flutter (24950): alignment: AlignmentDirectional.topStart
I/flutter (24950): textDirection: null
I/flutter (24950): fit: loose
I/flutter (24950): overflow: clip
I/flutter (24950): This RenderObject has no descendants.
I/flutter (24950): ════════════════════════════════════════════════════════════════════════════════════════════════════
Flutter Doctor
[✓] Flutter (on Mac OS X 10.13.1 17B48, locale en-CA, channel alpha)
• Flutter at /Users//flutter/flutter
• Framework revision e8aa40eddd (4 weeks ago), 2017-10-17 15:42:40 -0700
• Engine revision 7c4142808c
• Tools Dart version 1.25.0-dev.11.0
[✓] Android toolchain - develop for Android devices (Android SDK 25.0.3)
• Android SDK at /Users//Library/Android/sdk
• Platform android-25, build-tools 25.0.3
• ANDROID_HOME = /Users//Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.1, Build version 9B55
• ios-deploy 1.9.2
• CocoaPods version 1.3.1
[✓] Android Studio (version 2.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)
[✓] IntelliJ IDEA Community Edition (version 2017.2.5)
• Flutter plugin version 18.2
• Dart plugin version 172.4155.35
[✓] Connected devices
• SM T810 • 33003b44d0cd3317 • android-arm • Android 7.0 (API 24) (emulator)
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 lista: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkc: crashStack traces logged to the consoleStack traces logged to the consoled: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.waiting for PR to land (fixed)A fix is in flightA fix is in flight
Activity
Hixie commentedon Nov 14, 2017
Yeah, you don't have a
textDirectionargument, which is required if you don't have aDirectionalitywidget, which you don't have either.We should definitely make that clearer though.
ErikUggeldahl commentedon Nov 14, 2017
Thanks Ian. I knew it was likely something on my end, but agreed, the error isn't clear on resolution steps. My humble suggestion would be to catch it higher in the stack with a clear assertion.
ErikUggeldahl commentedon Nov 14, 2017
As a note, I was curious if this would also trigger an assert if a
WidgetApp(orMaterialApp) was used as the base widget. When it didn't, I useddebugDumpApp()and discovered the tree did indeed include aDirectionalitywidget.It turns out this is included by the
Localizationswidget, though this isn't mentioned anywhere in its documentation. Perhaps it should be?Hixie commentedon Nov 15, 2017
Yeah we should document that too.
[-]Assertion tripped with empty Stack layout[/-][+]Improve documentation and assert for Stack.textDirection; also, API docs for Localizations should admit to adding a Directionality[/+]goderbauer commentedon Apr 22, 2020
/cc @Piinks
github-actions commentedon Aug 19, 2021
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.