I'm new to Flutter and I've been stuck here for a while now. I am trying to make a main screen in Flutter for web, but I keep getting this error every time I try to apply the expanded property to the listview widget.
This is the code, the error, and what I'm trying to get:
[What I'm trying to do]:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hotelmanager/optionsList.dart';
class MainScreen extends StatefulWidget {
#override
State<StatefulWidget> createState() {
return _MainScreenState();
}
}
class _MainScreenState extends State<MainScreen> {
#override
void initState() {
super.initState();
}
#override
Widget build(BuildContext context) {
return Center(
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
alignment: Alignment.center,
color: Colors.white,
child: Column(
children: <Widget>[
/*LEFT SIDE MENU*/
Expanded(
flex: 2,
child: Column(
children: <Widget>[
ListView(
children: <Widget>[
Container(
color: Colors.red,
child: Text("RED"),
)
],
),
],
),
),
/*HORIZONTAL AND CENTRAL MENU*/
Expanded(
flex: 8,
child: Column(
children: <Widget>[
/*HORIZONTAL MENU-ROW*/
Expanded(
flex: 2,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
ListView(
children: <Widget>[
Container(
color: Colors.indigoAccent,
child: Text("BLUE"),
)
],
),
],
),
),
/*MAIN MENU-ROW*/
Expanded(
flex: 8,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
color: Colors.green,
child: Text("GREEN"),
),
],
),
)
],
),
)
],
),
));
}
}
The error log:
Launching lib\main.dart on Chrome in debug mode...
Syncing files to device Chrome...
Debug service listening on ws://127.0.0.1:62280/NmOsZXmtIqE=
Debug service listening on ws://127.0.0.1:62280/NmOsZXmtIqE=
══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
When a column is in a parent that does not provide a finite height constraint, for example if it is
in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a
flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining
space in the vertical direction.
These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child
cannot simultaneously expand to fit its parent.
Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible
children (using Flexible rather than Expanded). This will allow the flexible children to size
themselves to less than the infinite remaining space they would otherwise be forced to take, and
then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum
constraints provided by the parent.
If this message did not help you determine the problem, consider using debugDumpRenderTree():
https://flutter.dev/debugging/#rendering-layer
http://api.flutter.dev/flutter/rendering/debugDumpRenderTree.html
The affected RenderFlex is:
RenderFlex#f5e21 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE(creator: Column ← Column ← Align ← ConstrainedBox ← Container ← Center ← MainScreen ← _BodyBuilder ← MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ← CustomMultiChildLayout ← AnimatedBuilder ← ⋯, parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size), constraints: BoxConstraints(0.0<=w<=929.0, 0.0<=h<=Infinity), size: MISSING, direction: vertical, mainAxisAlignment: start, mainAxisSize: max, crossAxisAlignment: center, verticalDirection: down)
The creator information is set to:
Column ← Column ← Align ← ConstrainedBox ← Container ← Center ← MainScreen ← _BodyBuilder ←
MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ← CustomMultiChildLayout ← AnimatedBuilder ← ⋯
The nearest ancestor providing an unbounded width constraint is: RenderFlex#62f2b relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
creator: Column ← Align ← ConstrainedBox ← Container ← Center ← MainScreen ← _BodyBuilder ←
MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ← CustomMultiChildLayout ← AnimatedBuilder ←
DefaultTextStyle ← ⋯
parentData: offset=Offset(0.0, 0.0) (can use size)
constraints: BoxConstraints(0.0<=w<=929.0, 0.0<=h<=876.0)
size: MISSING
direction: vertical
mainAxisAlignment: start
mainAxisSize: max
crossAxisAlignment: center
verticalDirection: down
See also: https://flutter.dev/layout/
If none of the above helps enough to fix this problem, please don't hesitate to file a bug:
https://github.com/flutter/flutter/issues/new?template=BUG.md
The relevant error-causing widget was:
Column file:///C:/Users/Jorge%20Antelo/Desktop/Flutter/hotelmanager/lib/mainContainer.dart:46:13
When the exception was thrown, this was the stack:
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 196:49 throw_
package:flutter/src/rendering/flex.dart 693:11 <fn>
package:flutter/src/rendering/flex.dart 717:15 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/flex.dart 746:14 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/shifted_box.dart 394:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 265:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/shifted_box.dart 394:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/custom_layout.dart 171:10 layoutChild
package:flutter/src/material/scaffold.dart 484:7 performLayout
package:flutter/src/rendering/custom_layout.dart 240:7 [_callPerformLayout]
package:flutter/src/rendering/custom_layout.dart 399:14 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/proxy_box.dart 1247:11 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/proxy_box.dart 3224:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/widgets/overlay.dart 700:14 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/proxy_box.dart 110:13 performLayout
package:flutter/src/rendering/object.dart 1767:7 layout
package:flutter/src/rendering/view.dart 167:48 performLayout
package:flutter/src/rendering/object.dart 1630:7 [_layoutWithoutResize]
package:flutter/src/rendering/object.dart 887:17 flushLayout
package:flutter/src/rendering/binding.dart 401:19 drawFrame
package:flutter/src/widgets/binding.dart 884:13 drawFrame
package:flutter/src/rendering/binding.dart 283:5 [_handlePersistentFrameCallback]
package:flutter/src/scheduler/binding.dart 1108:15 [_invokeFrameCallback]
package:flutter/src/scheduler/binding.dart 1047:9 handleDrawFrame
package:flutter/src/scheduler/binding.dart 856:7 <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/isolate_helper.dart 50:19 internalCallback
The following RenderObject was being processed when the exception was fired: RenderFlex#f5e21 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
creator: Column ← Column ← Align ← ConstrainedBox ← Container ← Center ← MainScreen ← _BodyBuilder ←
MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ← CustomMultiChildLayout ← AnimatedBuilder ← ⋯
parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
constraints: BoxConstraints(0.0<=w<=929.0, 0.0<=h<=Infinity)
size: MISSING
direction: vertical
mainAxisAlignment: start
mainAxisSize: max
crossAxisAlignment: center
verticalDirection: down
This RenderObject had the following descendants (showing up to depth 5):
child 1: RenderFlex#9da6e NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child 1: RenderRepaintBoundary#b779b NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderCustomPaint#67333 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderRepaintBoundary#89099 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: _RenderScrollSemantics#0b273 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child 2: RenderFlex#fb6ad NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child 1: _RenderColoredBox#0acb4 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderParagraph#61e06 NEEDS-LAYOUT NEEDS-PAINT
text: TextSpan
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: Assertion failed: file:///C:/flutter/packages/flutter/lib/src/rendering/box.dart:1694:12
Another exception was thrown: Assertion failed: file:///C:/flutter/packages/flutter/lib/src/rendering/shifted_box.dart:322:12
Another exception was thrown: NoSuchMethodError: '<Unexpected Null Value>'
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following NoSuchMethodError was thrown during paint():
'<Unexpected Null Value>'
method not found
Receiver: null
Arguments: []
The relevant error-causing widget was:
Column file:///C:/Users/Jorge%20Antelo/Desktop/Flutter/hotelmanager/lib/mainContainer.dart:25:16
When the exception was thrown, this was the stack:
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 196:49 throw_
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 37:3 throwNullValueError
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 450:39 _notNull
package:flutter/src/rendering/flex.dart 475:38 get [_hasOverflow]
package:flutter/src/rendering/flex.dart 949:10 paint
...
The following RenderObject was being processed when the exception was fired: RenderFlex#62f2b relayoutBoundary=up1
... needs compositing
... parentData: offset=Offset(0.0, 0.0) (can use size)
... constraints: BoxConstraints(0.0<=w<=929.0, 0.0<=h<=876.0)
... size: MISSING
... direction: vertical
... mainAxisAlignment: start
... mainAxisSize: max
... crossAxisAlignment: center
... verticalDirection: down
RenderObject: RenderFlex#62f2b relayoutBoundary=up1
needs compositing
parentData: offset=Offset(0.0, 0.0) (can use size)
constraints: BoxConstraints(0.0<=w<=929.0, 0.0<=h<=876.0)
size: MISSING
direction: vertical
mainAxisAlignment: start
mainAxisSize: max
crossAxisAlignment: center
verticalDirection: down
... child 1: RenderFlex#6be7a NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
... constraints: MISSING
... size: MISSING
... direction: vertical
... mainAxisAlignment: start
... mainAxisSize: max
... crossAxisAlignment: center
... verticalDirection: down
... child 1: RenderRepaintBoundary#15c70 NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
... constraints: MISSING
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
... child: RenderCustomPaint#79694 NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: <none>
... constraints: MISSING
... size: MISSING
... child: RenderRepaintBoundary#81e95 NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: <none>
... constraints: MISSING
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
... child 2: RenderFlex#f5e21 relayoutBoundary=up2 NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
... constraints: BoxConstraints(0.0<=w<=929.0, 0.0<=h<=Infinity)
... size: MISSING
... direction: vertical
... mainAxisAlignment: start
... mainAxisSize: max
... crossAxisAlignment: center
... verticalDirection: down
... child 1: RenderFlex#9da6e NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
... constraints: MISSING
... size: MISSING
... direction: horizontal
... mainAxisAlignment: spaceEvenly
... mainAxisSize: max
... crossAxisAlignment: center
... textDirection: ltr
... verticalDirection: down
... child 1: RenderRepaintBoundary#b779b NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
... constraints: MISSING
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
... child: RenderCustomPaint#67333 NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: <none>
... constraints: MISSING
... size: MISSING
... child 2: RenderFlex#fb6ad NEEDS-LAYOUT NEEDS-PAINT
... parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
... constraints: MISSING
... size: MISSING
... direction: horizontal
... mainAxisAlignment: spaceEvenly
... mainAxisSize: max
... crossAxisAlignment: center
... textDirection: ltr
... verticalDirection: down
... child 1: _RenderColoredBox#0acb4 NEEDS-LAYOUT NEEDS-PAINT
... parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
... constraints: MISSING
... size: MISSING
... behavior: opaque
... child: RenderParagraph#61e06 NEEDS-LAYOUT NEEDS-PAINT
... parentData: <none>
... constraints: MISSING
... size: MISSING
... textAlign: start
... textDirection: ltr
... softWrap: wrapping at box width
... overflow: clip
... locale: en_US
... maxLines: unlimited
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (2) Exception caught by rendering library ═════════════════════════════════════════════════
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
The relevant error-causing widget was:
Column file:///C:/Users/Jorge%20Antelo/Desktop/Flutter/hotelmanager/lib/mainContainer.dart:46:13
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (3) Exception caught by rendering library ═════════════════════════════════════════════════
Assertion failed: file:///C:/flutter/packages/flutter/lib/src/rendering/box.dart:1694:12
hasSize
"RenderBox was not laid out: RenderFlex#f5e21 relayoutBoundary=up2 NEEDS-PAINT"
The relevant error-causing widget was:
Column file:///C:/Users/Jorge%20Antelo/Desktop/Flutter/hotelmanager/lib/mainContainer.dart:25:16
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (4) Exception caught by rendering library ═════════════════════════════════════════════════
Assertion failed: file:///C:/flutter/packages/flutter/lib/src/rendering/shifted_box.dart:322:12
child.hasSize
is not true
The relevant error-causing widget was:
Container file:///C:/Users/Jorge%20Antelo/Desktop/Flutter/hotelmanager/lib/mainContainer.dart:21:14
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (5) Exception caught by rendering library ═════════════════════════════════════════════════
'<Unexpected Null Value>'
method not found
Receiver: null
Arguments: []
The relevant error-causing widget was:
Column file:///C:/Users/Jorge%20Antelo/Desktop/Flutter/hotelmanager/lib/mainContainer.dart:25:16
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (6) Exception caught by rendering library ═════════════════════════════════════════════════
Assertion failed: file:///C:/flutter/packages/flutter/lib/src/rendering/box.dart:1694:12
hasSize
"RenderBox was not laid out: RenderFlex#f5e21 relayoutBoundary=up2 NEEDS-PAINT"
The relevant error-causing widget was:
Column file:///C:/Users/Jorge%20Antelo/Desktop/Flutter/hotelmanager/lib/mainContainer.dart:25:16
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (7) Exception caught by rendering library ═════════════════════════════════════════════════
Assertion failed: file:///C:/flutter/packages/flutter/lib/src/rendering/shifted_box.dart:322:12
child.hasSize
is not true
The relevant error-causing widget was:
Container file:///C:/Users/Jorge%20Antelo/Desktop/Flutter/hotelmanager/lib/mainContainer.dart:21:14
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (8) Exception caught by rendering library ═════════════════════════════════════════════════
'<Unexpected Null Value>'
method not found
Receiver: null
Arguments: []
The relevant error-causing widget was:
Column file:///C:/Users/Jorge%20Antelo/Desktop/Flutter/hotelmanager/lib/mainContainer.dart:25:16
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (9) Exception caught by rendering library ═════════════════════════════════════════════════
'<Unexpected Null Value>'
method not found
Receiver: null
Arguments: []
The relevant error-causing widget was:
Column file:///C:/Users/Jorge%20Antelo/Desktop/Flutter/hotelmanager/lib/mainContainer.dart:25:16
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (10) Exception caught by rendering library ════════════════════════════════════════════════
'<Unexpected Null Value>'
method not found
Receiver: null
Arguments: []
The relevant error-causing widget was:
Column file:///C:/Users/Jorge%20Antelo/Desktop/Flutter/hotelmanager/lib/mainContainer.dart:25:16
════════════════════════════════════════════════════════════════════════════════════════════════════
Application finished.
The error occurs because you are trying to expand without constrains. Expanded Widget is used with a parent with dimension constrains. Since you are using it directly as one of the children in a column it can't infer which dismission to take.
By default Expanded expand to fill dimension of the parent so you have to provide a parent like a container or padding or sizeBoxed
Edit:
You will also need some flex widgets ( Flexible) to achieve the layout.
follow this link to see a sample I made in dartpad.
return Column(
children: <Widget>[
Flexible(
flex: 1,
child: Row(children: <Widget>[
Expanded(
child: Container(
height: 150,
color: Colors.black,
child: RaisedButton(onPressed: null)))
])),
Flexible(
flex: 6,
child: Row(
children: <Widget>[
Flexible(
flex: 1,
child: Column(children: <Widget>[
Expanded(
child: Container(
width: 200,
color: Colors.white,
child: RaisedButton(onPressed: null)))
])),
Flexible(
flex: 3,
child: Column(
children: <Widget>[
Flexible(
flex: 1,
child: Row(children: <Widget>[
Expanded(
child: Container(
height: height,
color: Colors.red,
child: RaisedButton(onPressed: null)))
])),
Flexible(
flex: 10,
child: Row(children: <Widget>[
Expanded(
child: Container(
height: height,
color: Colors.green,
child: RaisedButton(
onPressed: null,
)))
])),
],
),
),
],
),
),
],
);
Related
Since i implemnetd the FittedBox with a Full width Image the app tells me to that i have a render error but i cant fix it.
All the other widgets have a expanded function and it all worked fine until i inserted the banner.
But even if i make it as small as 5 pixel the app tells me the same error..
How can i fix that?
I assume its the fitted box.
The Error:
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderFittedBox#d209c relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
package:flutter/…/rendering/box.dart:1
Failed assertion: line 2001 pos 12: 'hasSize'
The relevant error-causing widget was
Column
lib/…/event_details_screen/match_details.dart:45
The following RenderObject was being processed when the exception was fired: RenderFittedBox#d209c relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
RenderObject: RenderFittedBox#d209c relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
constraints: BoxConstraints(0.0<=w<=428.0, 0.0<=h<=Infinity)
size: MISSING
fit: fitWidth
alignment: Alignment.center
textDirection: ltr
child: RenderSemanticsAnnotations#a5a83 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(unconstrained)
size: Size(0.0, 0.0)
child: RenderImage#d2457 relayoutBoundary=up5 NEEDS-PAINT
parentData: (can use size)
constraints: BoxConstraints(unconstrained)
size: Size(0.0, 0.0)
image: null
alignment: Alignment.center
invertColors: false
filterQuality: low
class _DefaultDetailsState extends State<DefaultDetails> {
final double padding = EVENT_DETAILS_PADDING;
#override
Widget build(BuildContext context) {
return DetailScreen(
child: _screen(),
);
}
Widget _screen() {
return Column(
children: [
_section(
flex: 4,
child: TournamentTitleSection(
event: widget.event,
host: widget.host,
),
),
FittedBox(
fit: BoxFit.fitWidth,
child: Image.asset('assets/images/ads/mockup_ad.PNG'),
),
_section(
flex: 10,
child: DefaultDetailsSection(
event: widget.event,
host: widget.host,
),
),
_divider(),
_section(
flex: 4,
child: TimesSection(
event: widget.event,
calendarName: _calendarName,
),
),
...
The Widget _section.
Widget _section({Widget? child, int flex = 1}) {
return Expanded(
flex: flex,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: padding),
child: child ?? const SizedBox(),
),
);
}
I allready tried to wrap it in a Expanded Widget and also sized boy but nothing worked.
I get the following error for my code
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
When a column is in a parent that does not provide a finite height constraint, for example if it is in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining space in the vertical direction.
These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child cannot simultaneously expand to fit its parent.
Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible children (using Flexible rather than Expanded). This will allow the flexible children to size themselves to less than the infinite remaining space they would otherwise be forced to take, and then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum constraints provided by the parent.
If this message did not help you determine the problem, consider using debugDumpRenderTree():
https://flutter.dev/debugging/#rendering-layer
http://api.flutter.dev/flutter/rendering/debugDumpRenderTree.html
The affected RenderFlex is:
RenderFlex#35d16 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE(creator: Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a73f2] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#2021f] ← Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#2e976] ← RepaintBoundary ← CustomPaint-[GlobalKey#46173] ← ⋯, parentData: (can use size), constraints: BoxConstraints(w=360.0, 0.0<=h<=Infinity), size: Size(360.0, 61.0), direction: vertical, mainAxisAlignment: start, mainAxisSize: max, crossAxisAlignment: center, verticalDirection: down)
The creator information is set to:
Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a73f2] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#2021f] ← Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#2e976] ← RepaintBoundary ← CustomPaint-[GlobalKey#46173] ← ⋯
The nearest ancestor providing an unbounded width constraint is: _RenderSingleChildViewport#f779b NEEDS-LAYOUT NEEDS-PAINT:
needs compositing
creator: _SingleChildViewport ← IgnorePointer-[GlobalKey#a73f2] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#2021f] ← Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#2e976] ← RepaintBoundary ← CustomPaint-[GlobalKey#46173] ← _RawMouseRegion ← ⋯
parentData: (can use size)
constraints: BoxConstraints(w=360.0, h=467.2)
layer: OffsetLayer#5728c
size: Size(360.0, 467.2)
See also: https://flutter.dev/layout/
If none of the above helps enough to fix this problem, please don't hesitate to file a bug:
https://github.com/flutter/flutter/issues/new?template=2_bug.md
══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
When a column is in a parent that does not provide a finite height constraint, for example if it is
in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a
flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining
space in the vertical direction.
These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child
cannot simultaneously expand to fit its parent.
Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible
children (using Flexible rather than Expanded). This will allow the flexible children to size
themselves to less than the infinite remaining space they would otherwise be forced to take, and
then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum
constraints provided by the parent.
If this message did not help you determine the problem, consider using debugDumpRenderTree():
https://flutter.dev/debugging/#rendering-layer
http://api.flutter.dev/flutter/rendering/debugDumpRenderTree.html
The affected RenderFlex is:
RenderFlex#35d16 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE(creator: Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a73f2] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#2021f] ← Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#2e976] ← RepaintBoundary ← CustomPaint-[GlobalKey#46173] ← ⋯, parentData: (can use size), constraints: BoxConstraints(w=360.0, 0.0<=h<=Infinity), size: Size(360.0, 61.0), direction: vertical, mainAxisAlignment: start, mainAxisSize: max, crossAxisAlignment: center, verticalDirection: down)
The creator information is set to:
Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a73f2] ← Semantics ← Listener ←
_GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#2021f] ←
Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#2e976] ← RepaintBoundary ←
CustomPaint-[GlobalKey#46173] ← ⋯
The nearest ancestor providing an unbounded width constraint is: _RenderSingleChildViewport#f779b NEEDS-LAYOUT NEEDS-PAINT:
needs compositing
creator: _SingleChildViewport ← IgnorePointer-[GlobalKey#a73f2] ← Semantics ← Listener ←
_GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#2021f] ←
Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#2e976] ← RepaintBoundary ←
CustomPaint-[GlobalKey#46173] ← _RawMouseRegion ← ⋯
parentData: (can use size)
constraints: BoxConstraints(w=360.0, h=467.2)
layer: OffsetLayer#5728c
size: Size(360.0, 467.2)
See also: https://flutter.dev/layout/
If none of the above helps enough to fix this problem, please don't hesitate to file a bug:
https://github.com/flutter/flutter/issues/new?template=2_bug.md
The relevant error-causing widget was:
Column
/lib/screens/added_challenge_info.dart:54:34
When the exception was thrown, this was the stack:
dart:sdk_internal 5348:11 throw_
packages/flutter/src/rendering/flex.dart 926:9
packages/flutter/src/rendering/flex.dart 928:14 performLayout
packages/flutter/src/rendering/object.dart 1779:7 layout
packages/flutter/src/widgets/single_child_scroll_view.dart 581:7 performLayout
packages/flutter/src/rendering/object.dart 1636:7 [_layoutWithoutResize]
packages/flutter/src/rendering/object.dart 881:17 flushLayout
packages/flutter/src/rendering/binding.dart 462:19 drawFrame
packages/flutter/src/widgets/binding.dart 876:13 drawFrame
packages/flutter/src/rendering/binding.dart 328:5 [_handlePersistentFrameCallback]
packages/flutter/src/scheduler/binding.dart 1144:15 [_invokeFrameCallback]
packages/flutter/src/scheduler/binding.dart 1082:9 handleDrawFrame
packages/flutter/src/scheduler/binding.dart 998:5 [_handleDrawFrame]
dart:sdk_internal 186345:7 invoke
dart:sdk_internal 166271:15 invokeOnDrawFrame
dart:sdk_internal 183434:55
The following RenderObject was being processed when the exception was fired: RenderFlex#35d16 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
creator: Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a73f2] ← Semantics ← Listener ←
_GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#2021f] ←
Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#2e976] ← RepaintBoundary ←
CustomPaint-[GlobalKey#46173] ← ⋯
parentData: (can use size)
constraints: BoxConstraints(w=360.0, 0.0<=h<=Infinity)
size: Size(360.0, 61.0)
direction: vertical
mainAxisAlignment: start
mainAxisSize: max
crossAxisAlignment: center
verticalDirection: down
This RenderObject had the following descendants (showing up to depth 5):
child 1: RenderPadding#0a03f relayoutBoundary=up2 NEEDS-PAINT
child: RenderFlex#94b34 relayoutBoundary=up3 NEEDS-PAINT
child 1: RenderSemanticsAnnotations#7d3ea relayoutBoundary=up4 NEEDS-PAINT
child: RenderMouseRegion#ff92e relayoutBoundary=up5 NEEDS-PAINT
child: RenderSemanticsAnnotations#ca9a7 relayoutBoundary=up6 NEEDS-PAINT
child 2: RenderSemanticsAnnotations#46b18 relayoutBoundary=up4 NEEDS-PAINT
child: RenderMouseRegion#11cf7 relayoutBoundary=up5 NEEDS-PAINT
child: RenderSemanticsAnnotations#c1a5a relayoutBoundary=up6 NEEDS-PAINT
child 2: RenderStack#1baf2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child 1: RenderStack#6b82e NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child 1: RenderRepaintBoundary#6d25a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderSemanticsGestureHandler#cced9 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderPointerListener#06fa5 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child 2: RenderLimitedBox#fc4c2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderConstrainedBox#ec341 NEEDS-LAYOUT NEEDS-PAINT
child 2: RenderLimitedBox#ceb62 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderConstrainedBox#71b41 NEEDS-LAYOUT NEEDS-PAINT
════════════════════════════════════════════════════════════════════════════════════════════════════
Unexpected null value.
Another exception was thrown: Unexpected null value.
Cannot hit test a render box that has never been laid out.
The hitTest() method was called on this RenderBox: RenderStack#1baf2 NEEDS-LAYOUT NEEDS-PAINT:
needs compositing
creator: Stack ← RankedList ← Expanded ← Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a73f2] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#2021f] ← Listener ← _ScrollableScope ← ⋯
parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
constraints: MISSING
size: MISSING
alignment: Alignment.topCenter
textDirection: ltr
fit: loose
Unfortunately, this object's geometry is not known at this time, probably because it has never been laid out. This means it cannot be accurately hit-tested.
If you are trying to perform a hit test during the layout phase itself, make sure you only hit test nodes that have completed layout (e.g. the node's children, after their layout() method has been called).
Another exception was thrown: Cannot hit test a render box that has never been laid out.
Cannot hit test a render box that has never been laid out.
The hitTest() method was called on this RenderBox: RenderStack#1baf2 NEEDS-LAYOUT NEEDS-PAINT:
needs compositing
creator: Stack ← RankedList ← Expanded ← Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a73f2] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#2021f] ← Listener ← _ScrollableScope ← ⋯
parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
constraints: MISSING
size: MISSING
alignment: Alignment.topCenter
textDirection: ltr
fit: loose
Unfortunately, this object's geometry is not known at this time, probably because it has never been laid out. This means it cannot be accurately hit-tested.
If you are trying to perform a hit test during the layout phase itself, make sure you only hit test nodes that have completed layout (e.g. the node's children, after their layout() method has been called).
Assertion failed: /libmouse_tracker.dart:201:12
!_debugDuringDeviceUpdate
is not true
Another exception was thrown: Assertion failed: file:///home/builder/hotbuilder/packages/flutter/lib/src/rendering/mouse_tracker.dart:201:12
Cannot hit test a render box that has never been laid out.
The hitTest() method was called on this RenderBox: RenderStack#1baf2 NEEDS-LAYOUT NEEDS-PAINT:
needs compositing
creator: Stack ← RankedList ← Expanded ← Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a73f2] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#2021f] ← Listener ← _ScrollableScope ← ⋯
parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
constraints: MISSING
size: MISSING
alignment: Alignment.topCenter
textDirection: ltr
fit: loose
Unfortunately, this object's geometry is not known at this time, probably because it has never been laid out. This means it cannot be accurately hit-tested.
If you are trying to perform a hit test during the layout phase itself, make sure you only hit test nodes that have completed layout (e.g. the node's children, after their layout() method has been called).
My code is below:
I saw from similar posts that an approach I can take is to wrap the container within the scrollable with expanded so did so with _buildLeaderboard but that still didn't fix the bug... I'm wondering if it's because I'm adding RankedList to a Scrollable since it says on its pubdev
"RankedList uses scroll controller behind the scenes so you can't add your own scroll controller to the list as of now.".. If so how can I fix the issue?
Thank you as always!
class AddedChallengeInfo extends StatefulWidget {
final Challenge challenge;
const AddedChallengeInfo({required this.challenge});
#override
_AddedChallengeInfoState createState() => _AddedChallengeInfoState();
}
class _AddedChallengeInfoState extends State<AddedChallengeInfo> {
int selectedId = 0;
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xffFFAAA6),
appBar: AppBar(
iconTheme: IconThemeData(
color: Color(0xff999999),
),
backgroundColor: Colors.transparent,
actions: [
IconButton(
icon: Icon(
FontAwesomeIcons.trashAlt,
size: 20,
color: Color(0xff999999),
), // Icon
onPressed: () {
Navigator.pop(context, true);
},
),
SizedBox(width: 20)
]),
body: Stack(children: [
ChallengeHeader(challenge: widget.challenge),
DraggableScrollableSheet(
initialChildSize: 0.8,
minChildSize: 0.8,
maxChildSize: 1.0,
builder: (BuildContext context, myScrollController) {
return ClipRRect(
borderRadius: BorderRadius.vertical(top: Radius.circular(30.0)),
child: Container(
color: Colors.white,
child: SingleChildScrollView(
controller: myScrollController,
child: Column(children: [
_buildScreenSelector(),
selectedId == 0 ? SizedBox() : _buildLeaderboard(),
])),
));
})
]));
}
Widget _buildScreenSelector() {
return Padding(
padding: const EdgeInsets.only(left: 30, right: 30, top: 10, bottom: 30),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
_buildHeaderSelectorButton(0, "Intro"),
_buildHeaderSelectorButton(1, "Leaderboard"),
],
),
);
}
Widget _buildLeaderboard() {
return Expanded(
child: RankedList(
itemBuilder: (context, index) {
return Container(
height: 500,
color: index + 1 == 2 ? Colors.green : Colors.white,
child: ListTile(
title: Text(
'${index + 1}',
style: Theme.of(context).textTheme.headline6,
),
));
},
itemCount: 3,
rank: 2,
itemHeight: 56,
topItem: Container(
color: Colors.green,
child: ListTile(
title: Text(
'25',
style: Theme.of(context).textTheme.headline6,
),
),
),
bottomItem: Container(
color: Colors.green,
child: ListTile(
title: Text(
'25',
style: Theme.of(context).textTheme.headline6,
),
),
),
showBottom: false,
));
}
Widget _buildSelectorButton(int id, String t) {
return InkWell(
onTap: () {
setState(() {
selectedId = id;
});
},
child: Container(
alignment: Alignment.center,
width: 56,
height: 21,
child: Text(
'$t',
style: TextStyle(color: id == selectedId ? Colors.white : Colors.black),
),
decoration: BoxDecoration(
color: id == selectedId ? Colors.black : Colors.white,
borderRadius: BorderRadius.circular(20),
),
),
);
}
}
I have the following FutureBuilder and I am trying to display a loading spinner when the connection state is in waiting status but am getting alot of exception regarding size. Not sure where to include the size since my spinner already has a size.
return Scaffold(
backgroundColor: Colors.grey[100],
appBar: AppBar(
backgroundColor: Colors.grey[100],
elevation: 0,
brightness: Brightness.light,
leading: Icon(null),
actions: <Widget>[
IconButton(
onPressed: () {},
icon: Icon(
Icons.shopping_basket,
color: Colors.grey[800],
),
)
],
),
body: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: EdgeInsets.symmetric(horizontal: 20.0),
child: FutureBuilder(
future: _screenFuture,
// ignore: missing_return
builder: (context, snap) {
if (snap.error != null &&
!snap.error
.toString()
.contains('NoSuchMethodError')) {
return Center(child: Text('Something went wrong!'));
} else if (snap.hasData) {
var categoriesData = Provider.of<Categories>(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
FadeAnimation(
1,
Text(
'Food Delivery',
style: TextStyle(
color: Colors.grey[80],
fontWeight: FontWeight.bold,
fontSize: 30),
)),
SizedBox(
height: 20,
),
Container(
height: 50,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: categoriesData.items.length,
itemBuilder: (ctx, i) => FadeAnimation(
1,
makeCategory(
isActive: true,
title: categoriesData.items
.toList()[i]
.title)))),
SizedBox(
height: 10,
),
],
);
} else if (snap.connectionState ==
ConnectionState.waiting) {
return Center(child: Loading());
}
})),
SizedBox(
height: 30,
)
],
),
),
);
Loading spinner class
class Loading extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: SpinKitFadingCircle(
color: Colors.black,
size: 30,
)
);
}
}
Exceptions I am getting: I see that it is pointing to line 7 of my loading spinner but I am honestly not sure what to make of it.
════════ Exception caught by rendering library ═════════════════════════════════
The following assertion was thrown during performResize():
'package:flutter/src/widgets/overlay.dart': Failed assertion: line 720 pos 12: 'constraints.biggest.isFinite': is not true.
2
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=2_bug.md
The relevant error-causing widget was
MaterialApp
lib\widgets\loading.dart:7
When the exception was thrown, this was the stack
#2 _RenderTheatre.computeDryLayout
package:flutter/…/widgets/overlay.dart:720
#3 RenderBox.performResize
package:flutter/…/rendering/box.dart:2332
#4 RenderObject.layout
package:flutter/…/rendering/object.dart:1758
#5 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:116
#6 RenderObject.layout
package:flutter/…/rendering/object.dart:1779
...
The following RenderObject was being processed when the exception was fired: _RenderTheatre#d0b0d NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
RenderObject: _RenderTheatre#d0b0d NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
arentData: <none> (can use size)
constraints: BoxConstraints(0.0<=w<=320.0, 0.0<=h<=Infinity)
size: MISSING
skipCount: 0
textDirection: ltr
onstage 1: RenderIgnorePointer#7e525 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: not positioned; offset=Offset(0.0, 0.0)
constraints: MISSING
size: MISSING
ignoring: false
ignoringSemantics: implicitly false
child: RenderBlockSemantics#115dd NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
blocks semantics of earlier render objects below the common boundary
size: MISSING
blocking: true
child: RenderExcludeSemantics#791f1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
size: MISSING
excluding: true
child: RenderSemanticsGestureHandler#fab4a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
size: MISSING
behavior: opaque
gestures: tap
onstage 2: RenderSemanticsAnnotations#e679a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: not positioned; offset=Offset(0.0, 0.0)
constraints: MISSING
size: MISSING
child: RenderOffstage#31df1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
size: MISSING
offstage: false
child: RenderSemanticsAnnotations#12c91 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
size: MISSING
child: RenderRepaintBoundary#93c1c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: <none>
constraints: MISSING
size: MISSING
usefulness ratio: no metrics collected yet (never painted)
no offstage children
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
BoxConstraints forces an infinite height.
The relevant error-causing widget was
MaterialApp
lib\widgets\loading.dart:7
════════════════════════════════════════════════════════════════════════════════
After removing materialApp in loading spinner, I am now getting this exception:
════════ Exception caught by widgets library ═══════════════════════════════════
The following assertion was thrown building SpinKitFadingCircle(state: _SpinKitFadingCircleState#75158(ticker active)):
No Directionality widget found.
Stack widgets require a Directionality widget ancestor to resolve the 'alignment' argument.
The default value for 'alignment' is AlignmentDirectional.topStart, which requires a text direction.
The specific widget that could not find a Directionality ancestor was: Stack
alignment: AlignmentDirectional.topStart
fit: loose
dirty
The ownership chain for the affected widget is: "Stack ← SizedBox ← Center ← SpinKitFadingCircle ← ColoredBox ← Container ← Loading ← Center ← MyApp ← [root]"
Typically, the Directionality widget is introduced by the MaterialApp or WidgetsApp widget at the top of your application widget tree. It determines the ambient reading direction and is used, for example, to determine how to lay out text, how to interpret "start" and "end" values, and to resolve EdgeInsetsDirectional, AlignmentDirectional, and other *Directional objects.
Instead of providing a Directionality widget, another solution would be passing a non-directional 'alignment', or an explicit 'textDirection', to the Stack.
from the error message, I guess if you wrapped SpinKitFadingCircle inside a Directionality it might work! if it didn't, we need more info about the SpinKitFadingCircle widget.
class Loading extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: Directionality(
textDirection: TextDirection.rtl,
child: SpinKitFadingCircle(
color: Colors.black,
size: 30,
),
),
);
}
}
I'm a newbie who just started Flutter.
I want to use CustomScrollView as a child of Row/Column Widget
It works very well when CustomScrollView is root.
But as soon as I put it into Row Widget's child, it spouted an error.
Couldn't CustomScrollview be used as a child of Row widget?
if so, please tell me the reason, and What is the best alternative?
Or if there is an error in my code, I want you to correct it.
What I want to make
my CustomScrollViewWidget
I don't know if this is what you want, but here's my error.
══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
'package:flutter/src/rendering/viewport.dart': Failed assertion: line 1758 pos 16:
'constraints.hasBoundedHeight': 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
The relevant error-causing widget was:
CustomScrollView
The following RenderObject was being processed when the exception was fired: RenderShrinkWrappingViewport#0344f relayoutBoundary=up14 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
needs compositing
creator: ShrinkWrappingViewport ← IgnorePointer-[GlobalKey#e4530] ← Semantics ← _PointerListener ←
Listener ← _GestureSemantics ←
RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#a61b3] ← _PointerListener ← Listener
← _ScrollableScope ← _ScrollSemantics-[GlobalKey#42b3c] ← RepaintBoundary ← ⋯
parentData: <none> (can use size)
constraints: BoxConstraints(unconstrained)
size: MISSING
axisDirection: right
crossAxisDirection: down
offset: ScrollPositionWithSingleContext#46fe1(offset: 0.0, range: null..null, viewport: null,
ScrollableState, ClampingScrollPhysics -> RangeMaintainingScrollPhysics, IdleScrollActivity#66c28,
ScrollDirection.idle)
This RenderObject had the following child:
child 0: RenderSliverList#42dfb NEEDS-LAYOUT NEEDS-PAINT
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderShrinkWrappingViewport#0344f relayoutBoundary=up14 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1702 pos 12: 'hasSize'
The relevant error-causing widget was
CustomScrollView
lib\0. TestCode.dart:31
════════════════════════════════════════════════════════════════════════════════
Here is my code!
class WrapVisit extends StatefulWidget {
WrapVisitState createState() => WrapVisitState();
}
class WrapVisitState extends State<WrapVisit> {
#override
Widget build(BuildContext context) {
return new Container(
padding: EdgeInsets.all(10),
color: Colors.white,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
new Text(
"브랜드관",
textAlign: TextAlign.left,
style: TextStyle(fontWeight: FontWeight.bold),
),
new Container(
margin: EdgeInsets.all(5),
child: new Text(
"전체보기",
textAlign: TextAlign.right,
style: TextStyle(
fontSize: 10,
color: Colors.black,
),
),
),
CustomScrollView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
slivers: [
SliverList(
delegate: SliverChildListDelegate(
[
... SliverListChildWidgets ...
],
),
),
],
),
],
),
],
),
);
}
}
Column doesn't like children with unbounded height. To fix it, set CustomScrollView's shrinkWrap parameter to true.
You need to wrap the scroll view in either a sized box or container first. It needs a parent with set dimensions. There’s a couple widgets that don’t work in rows/columns unless you put them inside a sized parent first.
Maybe one of you already came across these problems. I spent numerous hours with trying to get the ListView (I also tried ExpansionPanelList) into a container that pans from the right edge into the screen (help menu) over the existing widgets. I have already created a mock-up starting with a basic ListView and then added feature by feature again. But now I am stuck and the error message is not of much help (to me).
Those exceptions are thrown as soon as I add the AnimatedPositioned. The main message seems to be an issue with constraints.hasBoundedWidth': is not true.
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
'package:flutter/src/rendering/viewport.dart': Failed assertion: line 1754 pos 16: 'constraints.hasBoundedWidth': 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
The relevant error-causing widget was:
ListView file:///Users/holger/IdeaProjects/math/lib/tmp.dart:496:40
When the exception was thrown, this was the stack:
#2 RenderShrinkWrappingViewport.performLayout (package:flutter/src/rendering/viewport.dart:1754:16)
#3 RenderObject.layout (package:flutter/src/rendering/object.dart:1775:7)
#4 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#5 RenderObject.layout (package:flutter/src/rendering/object.dart:1775:7)
#6 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
...
The following RenderObject was being processed when the exception was fired: RenderShrinkWrappingViewport#a1875 relayoutBoundary=up7 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(0.0<=w<=Infinity, 0.0<=h<=716.8)
... size: MISSING
... axisDirection: down
... crossAxisDirection: right
... offset: ScrollPositionWithSingleContext#20c01(offset: 0.0, range: null..null, viewport: null, ScrollableState, AlwaysScrollableScrollPhysics -> BouncingScrollPhysics, IdleScrollActivity#3e990, ScrollDirection.idle)
RenderObject: RenderShrinkWrappingViewport#a1875 relayoutBoundary=up7 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: <none> (can use size)
constraints: BoxConstraints(0.0<=w<=Infinity, 0.0<=h<=716.8)
size: MISSING
axisDirection: down
crossAxisDirection: right
offset: ScrollPositionWithSingleContext#20c01(offset: 0.0, range: null..null, viewport: null, ScrollableState, AlwaysScrollableScrollPhysics -> BouncingScrollPhysics, IdleScrollActivity#3e990, ScrollDirection.idle)
... child 0: RenderSliverPadding#078d5 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: layoutOffset=None
... constraints: MISSING
... geometry: null
... padding: EdgeInsets.zero
... textDirection: ltr
... child: RenderSliverList#fd0a6 NEEDS-LAYOUT NEEDS-PAINT
... parentData: paintOffset=Offset(0.0, 0.0)
... constraints: MISSING
... geometry: null
... no children current live
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderBox was not laid out: RenderShrinkWrappingViewport#a1875 relayoutBoundary=up7 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1713 pos 12: 'hasSize'
The relevant error-causing widget was:
ListView file:///Users/holger/IdeaProjects/math/lib/tmp.dart:496:40
The lower part of the exception message is repeated multiple times, maybe once for every animation step. Then the messages finish with those below, where the reference container is the one of AnimatedPositiones > IgnorePointer > Container
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during paint():
RenderBox was not laid out: RenderDecoratedBox#a83d8
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1713 pos 12: 'hasSize'
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
The relevant error-causing widget was:
Container file:///Users/holger/IdeaProjects/math/lib/tmp3.dart:474:32
When the exception was thrown, this was the stack:
#2 RenderBox.size (package:flutter/src/rendering/box.dart:1713:12)
#3 RenderDecoratedBox.paint (package:flutter/src/rendering/proxy_box.dart:2067:12)
#4 RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2307:7)
#5 PaintingContext.paintChild (package:flutter/src/rendering/object.dart:191:13)
#6 RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:133:15)
...
The following RenderObject was being processed when the exception was fired: RenderDecoratedBox#a83d8
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(w=331.2, h=716.8)
... size: MISSING
... decoration: BoxDecoration
... color: Color(0xffffffff)
... configuration: ImageConfiguration(bundle: PlatformAssetBundle#b6597(), devicePixelRatio: 3.0, locale: en_US, textDirection: TextDirection.ltr, platform: iOS)
RenderObject: RenderDecoratedBox#a83d8
needs compositing
parentData: <none> (can use size)
constraints: BoxConstraints(w=331.2, h=716.8)
size: MISSING
decoration: BoxDecoration
color: Color(0xffffffff)
configuration: ImageConfiguration(bundle: PlatformAssetBundle#b6597(), devicePixelRatio: 3.0, locale: en_US, textDirection: TextDirection.ltr, platform: iOS)
... child: RenderFlex#28045 NEEDS-PAINT
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(w=331.2, h=716.8)
... size: MISSING
... direction: horizontal
... mainAxisAlignment: start
... mainAxisSize: max
... crossAxisAlignment: center
... textDirection: ltr
... verticalDirection: down
... textBaseline: alphabetic
... child 1: RenderPadding#b537d relayoutBoundary=up1 NEEDS-PAINT
... parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
... constraints: BoxConstraints(0.0<=w<=Infinity, 0.0<=h<=716.8)
... size: Size(59.0, 716.8)
... padding: EdgeInsets(3.0, 0.0, 0.0, 0.0)
... textDirection: ltr
... child: RenderFlex#4c2a2 relayoutBoundary=up2 NEEDS-PAINT
... parentData: offset=Offset(3.0, 0.0) (can use size)
... constraints: BoxConstraints(0.0<=w<=Infinity, 0.0<=h<=716.8)
... size: Size(56.0, 716.8)
... direction: vertical
... mainAxisAlignment: spaceEvenly
... mainAxisSize: max
... crossAxisAlignment: center
... verticalDirection: down
... child 1: RenderSemanticsGestureHandler#c07e2 relayoutBoundary=up3 NEEDS-PAINT
... parentData: offset=Offset(0.0, 330.4); flex=null; fit=null (can use size)
... constraints: BoxConstraints(unconstrained)
... size: Size(56.0, 56.0)
... gestures: tap
... child 2: _RenderScrollSemantics#80100 relayoutBoundary=up1 NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
... constraints: BoxConstraints(0.0<=w<=Infinity, 0.0<=h<=716.8)
... semantic boundary
... size: MISSING
... child: RenderPointerListener#695c7 relayoutBoundary=up2 NEEDS-PAINT
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(0.0<=w<=Infinity, 0.0<=h<=716.8)
... size: MISSING
... behavior: deferToChild
... listeners: signal
... child: RenderSemanticsGestureHandler#db442 relayoutBoundary=up3 NEEDS-PAINT
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(0.0<=w<=Infinity, 0.0<=h<=716.8)
... size: MISSING
... gestures: <none>
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderBox was not laid out: RenderDecoratedBox#a83d8
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1713 pos 12: 'hasSize'
The relevant error-causing widget was:
Container file:///Users/holger/IdeaProjects/math/lib/tmp3.dart:474:32
The ListView looks like this, it shows headers of different tags and each can be expanded to show detail information.
AnimatedPositioned(duration: Duration(milliseconds: 800),
left: _drawerLeft,
top:5,
child: IgnorePointer(ignoring: (_drawerLeft <= MediaQuery.of(context).size.width / 3 ? false:true),
child: Container(
height:0.8*1 * MediaQuery.of(context).size.height, width:0.8 * MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
CupertinoButton(
child: Icon(fwdBtn),
onPressed: () {
setState(() {
_drawerLeft = 1 * MediaQuery.of(context).size.width;
controller.reverse();
});
},
),
ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: usedTagData.length, itemBuilder: (BuildContext context, int index) {
return Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(usedTagData[index].header, style: TextStyle(color: CupertinoColors.link)),
CupertinoButton(
child: Icon(dwnBtn),
onPressed: () {
setState(() {
usedTagData[index].isExpanded = !usedTagData[index].isExpanded;
});
},
),
],
),
(usedTagData[index].isExpanded ?
Text(usedTagData[index].content)
:
Container()
),
]
);
}
),
],
),
)),
)
The AnimatedPositioned is a widget of
return Container(
height: MediaQuery.of(context).size.height,
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Do you have any idea how to go forward on this or do the exception messages provide any hint to you?
The only way you would get ListView to work with Row is to set a predefined width. Your ListView tries to expand infinitely so you should constrain it by setting a predefined width.
Here is an example:
Row(
children:[
SizedBox(
width:200,
child:ListView()
),
]),