Why is simple Stack code from Flutter website is giving Error? - flutter

import 'package:flutter/material.dart';
void main() {
runApp(StackApp());
}
Simple Class Stack I am trying to use the stack to overlay rectangles one above the other
class StackApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Container(
width: 100,
height: 100,
color: Colors.red,
),
Container(
width: 90,
height: 90,
color: Colors.green,
),
Container(
width: 80,
height: 80,
color: Colors.blue,
),
],
);
}
}
I am getting this error message
I/flutter ( 8912): (elided 10 frames from class _AssertionError, package dart:async, and package dart:async-patch)
I/flutter ( 8912):
I/flutter ( 8912): The following RenderObject was being processed when the exception was fired:
RenderStack#322e9 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
I/flutter ( 8912): creator: Stack ← StackApp ← [root]
I/flutter ( 8912): parentData:
I/flutter ( 8912): constraints: BoxConstraints(w=411.4, h=866.3)
I/flutter ( 8912): size: MISSING
I/flutter ( 8912): alignment: AlignmentDirectional.topStart
I/flutter ( 8912): textDirection: null
I/flutter ( 8912): fit: loose
I/flutter ( 8912): overflow: clip
I/flutter ( 8912): This RenderObject had the following descendants (showing up to depth 5):
I/flutter ( 8912): child 1: RenderConstrainedBox#49f71 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 8912): child: RenderDecoratedBox#2c55a NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 8912): child 2: RenderConstrainedBox#c71ea NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 8912): child: RenderDecoratedBox#4ad6c NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 8912): child 3: RenderConstrainedBox#5304a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 8912): child: RenderDecoratedBox#9516e NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 8912):
════════════════════════════════════════════════════════════════════════════════════════════════════

You need to wrap your app in a MaterialApp, CupertinoApp or WidgetsApp. This is almost mandatory. But if you don't want to use one of these for some reason, then set alignment in your Stack like alignment: Alignment.topLeft to fix this.

Related

How to add Column widget to Row widget in Flutter?

I want to add Column widget to Row widget.
I have a data structure as follows:
Scaffold
- Padding
- SingleChildScrollView
- Column
- Row
- CircleAvatar
- Column (The Column I am talking about below)
- Text
- Row
- Expanded
- MaterialButton
- Expanded
- Container
- Expanded
- MaterialButton
- ListTile
When adding a Column to a Row, I get an error:
════════ Exception caught by rendering library ═════════════════════════════════
The following assertion was thrown during performLayout():
RenderFlex children have non-zero flex but incoming width constraints are unbounded.
When a row is in a parent that does not provide a finite width constraint, for example if it is in a horizontal scrollable, it will try to shrink-wrap its children along the horizontal 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 horizontal 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#acbae relayoutBoundary=up15 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
constraints: BoxConstraints(unconstrained)
size: MISSING
direction: horizontal
mainAxisAlignment: start
mainAxisSize: max
crossAxisAlignment: center
textDirection: ltr
verticalDirection: down
child 1: RenderConstrainedBox#404ec NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0); flex=3; fit=FlexFit.tight
constraints: MISSING
size: MISSING
additionalConstraints: BoxConstraints(w=180.0, h=50.0)
child: RenderSemanticsAnnotations#4f838 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
semantic boundary
size: MISSING
child: _RenderInputPadding#04251 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
size: MISSING
child: RenderConstrainedBox#3337d NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0)
constraints: MISSING
size: MISSING
additionalConstraints: BoxConstraints(88.0<=w<=Infinity, 36.0<=h<=Infinity)
child 2: RenderLimitedBox#593aa NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
constraints: MISSING
size: MISSING
maxWidth: 0.0
maxHeight: 0.0
child: RenderConstrainedBox#d1172 NEEDS-LAYOUT NEEDS-PAINT
parentData: <none>
constraints: MISSING
size: MISSING
additionalConstraints: BoxConstraints(biggest)
child 3: RenderConstrainedBox#42764 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0); flex=3; fit=FlexFit.tight
constraints: MISSING
size: MISSING
additionalConstraints: BoxConstraints(w=180.0, h=50.0)
child: RenderSemanticsAnnotations#7ec96 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
semantic boundary
size: MISSING
child: _RenderInputPadding#6aa1f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
size: MISSING
child: RenderConstrainedBox#e1f60 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0)
constraints: MISSING
size: MISSING
additionalConstraints: BoxConstraints(88.0<=w<=Infinity, 36.0<=h<=Infinity)
The creator information is set to: Row ← Column ← Row ← Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#10aed] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#23575] ← Listener ← _ScrollableScope ← ⋯
The nearest ancestor providing an unbounded width constraint is: RenderFlex#ede32 relayoutBoundary=up13 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
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
Row
When the exception was thrown, this was the stack
#0 RenderFlex.performLayout.<anonymous closure>
#1 RenderFlex.performLayout
#2 RenderObject.layout
#3 RenderBox.layout
#4 ChildLayoutHelper.layoutChild
#5 RenderFlex._computeSizes
#6 RenderFlex.performLayout
#7 RenderObject.layout
#8 RenderBox.layout
#9 ChildLayoutHelper.layoutChild
#10 RenderFlex._computeSizes
#11 RenderFlex.performLayout
#12 RenderObject.layout
#13 RenderBox.layout
#14 ChildLayoutHelper.layoutChild
#15 RenderFlex._computeSizes
#16 RenderFlex.performLayout
#17 RenderObject.layout
#18 RenderBox.layout
#19 _RenderSingleChildViewport.performLayout
#20 RenderObject.layout
#21 RenderBox.layout
#22 RenderProxyBoxMixin.performLayout
#23 RenderObject.layout
#24 RenderBox.layout
#25 RenderProxyBoxMixin.performLayout
#26 RenderObject.layout
#27 RenderBox.layout
#28 RenderProxyBoxMixin.performLayout
#29 RenderObject.layout
#30 RenderBox.layout
#31 RenderProxyBoxMixin.performLayout
#32 RenderObject.layout
#33 RenderBox.layout
#34 RenderProxyBoxMixin.performLayout
#35 RenderObject.layout
#36 RenderBox.layout
#37 RenderProxyBoxMixin.performLayout
#38 RenderObject.layout
#39 RenderBox.layout
#40 RenderProxyBoxMixin.performLayout
#41 RenderObject.layout
#42 RenderBox.layout
#43 RenderProxyBoxMixin.performLayout
#44 RenderCustomPaint.performLayout
#45 RenderObject.layout
#46 RenderBox.layout
#47 RenderProxyBoxMixin.performLayout
#48 RenderObject.layout
#49 RenderBox.layout
#50 RenderPadding.performLayout
#51 RenderObject.layout
#52 RenderBox.layout
#53 MultiChildLayoutDelegate.layoutChild
#54 _ScaffoldLayout.performLayout
#55 MultiChildLayoutDelegate._callPerformLayout
#56 RenderCustomMultiChildLayoutBox.performLayout
#57 RenderObject._layoutWithoutResize
#58 PipelineOwner.flushLayout
#59 RendererBinding.drawFrame
#60 WidgetsBinding.drawFrame
#61 RendererBinding._handlePersistentFrameCallback
#62 SchedulerBinding._invokeFrameCallback
#63 SchedulerBinding.handleDrawFrame
#64 SchedulerBinding._handleDrawFrame
#68 _invoke (dart:ui/hooks.dart:150:10)
#69 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:318:5)
#70 _drawFrame (dart:ui/hooks.dart:115:31)
(elided 3 frames from dart:async)
The following RenderObject was being processed when the exception was fired: RenderFlex#acbae relayoutBoundary=up15 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
RenderObject: RenderFlex#acbae relayoutBoundary=up15 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
constraints: BoxConstraints(unconstrained)
size: MISSING
direction: horizontal
mainAxisAlignment: start
mainAxisSize: max
crossAxisAlignment: center
textDirection: ltr
verticalDirection: down
child 1: RenderConstrainedBox#404ec NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0); flex=3; fit=FlexFit.tight
constraints: MISSING
size: MISSING
additionalConstraints: BoxConstraints(w=180.0, h=50.0)
child: RenderSemanticsAnnotations#4f838 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
semantic boundary
size: MISSING
child: _RenderInputPadding#04251 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
size: MISSING
child: RenderConstrainedBox#3337d NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0)
constraints: MISSING
size: MISSING
additionalConstraints: BoxConstraints(88.0<=w<=Infinity, 36.0<=h<=Infinity)
child 2: RenderLimitedBox#593aa NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
constraints: MISSING
size: MISSING
maxWidth: 0.0
maxHeight: 0.0
child: RenderConstrainedBox#d1172 NEEDS-LAYOUT NEEDS-PAINT
parentData: <none>
constraints: MISSING
size: MISSING
additionalConstraints: BoxConstraints(biggest)
child 3: RenderConstrainedBox#42764 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0); flex=3; fit=FlexFit.tight
constraints: MISSING
size: MISSING
additionalConstraints: BoxConstraints(w=180.0, h=50.0)
child: RenderSemanticsAnnotations#7ec96 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
semantic boundary
size: MISSING
child: _RenderInputPadding#6aa1f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
size: MISSING
child: RenderConstrainedBox#e1f60 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0)
constraints: MISSING
size: MISSING
additionalConstraints: BoxConstraints(88.0<=w<=Infinity, 36.0<=h<=Infinity)
════════════════════════════════════════════════════════════════════════════════
…
My code:
Row(
children: [
CircleAvatar(
backgroundImage: NetworkImage(userAvatarUrl),
),
Column(
children: [
Text(userName),
Row(
children: …,
),
],
),
],
),
Feel free to leave a comment if you need more information.
How to add Column widget to Row widget? I would appreciate any help. Thank you in advance!
If the children inside the Row inside the Column can be Expanded, then consider wrapping the Column in an Expanded like so:
Row(
children: [
CircleAvatar(
backgroundImage: NetworkImage(userAvatarUrl),
),
Expanded(
child: Column(
children: [
Text(userName),
Row(
children: …,
),
],
),
)
],
),

Why is my widget screen not displaying content?

I have this page I'm trying to design in XD :
and when I ran the application to render in , the bottom side with content containing the tab did not display and I get these errors but I don't know what they exactly mean :
I/flutter (22774): The following RenderObject was being processed when the exception was fired: RenderViewport#cc2f4 NEEDS-LAYOUT
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE: I/flutter (22774): needs
compositing I/flutter (22774): creator: Viewport ←
IgnorePointer-[GlobalKey#1f28b] ← Semantics ← _PointerListener ←
Listener ← I/flutter (22774): _GestureSemantics ←
RawGestureDetector-[LabeledGlobalKey#0f747] ←
I/flutter (22774): _PointerListener ← Listener ← _ScrollableScope
← _ScrollSemantics-[GlobalKey#03bee] ← I/flutter (22774):
RepaintBoundary ← ⋯ I/flutter (22774): parentData: (can use
size) I/flutter (22774): constraints: BoxConstraints(0.0<=w<=360.0,
0.0<=h<=Infinity) I/flutter (22774): size: MISSING I/flutter (22774): axisDirection: left I/flutter (22774):
crossAxisDirection: down I/flutter (22774): offset:
_PagePosition#dd846(offset: null, range: null..null, viewport: null, ScrollableState, I/flutter (22774): _ForceImplicitScrollPhysics ->
PageScrollPhysics -> PageScrollPhysics -> ClampingScrollPhysics ->
I/flutter (22774): ClampingScrollPhysics ->
RangeMaintainingScrollPhysics, IdleScrollActivity#2467d, I/flutter
(22774): ScrollDirection.idle) I/flutter (22774): anchor: 0.0
I/flutter (22774): This RenderObject had the following descendants
(showing up to depth 5): I/flutter (22774): center child:
_RenderSliverFractionalPadding#2da9f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): child:
RenderSliverFillViewport#a0715 NEEDS-LAYOUT NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774):
════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (22774): Another exception was thrown: RenderBox was not
laid out: RenderViewport#cc2f4 NEEDS-LAYOUT NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATEI/flutter (22774): Another exception was
thrown: RenderBox was not laid out: RenderViewport#cc2f4 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another exception was
thrown: RenderBox was not laid out: RenderIgnorePointer#d6f43
relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter (22774): Another exception was thrown: RenderBox was not
laid out: RenderSemanticsAnnotations#55aed relayoutBoundary=up9
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another
exception was thrown: RenderBox was not laid out:
RenderPointerListener#891d5 relayoutBoundary=up8 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another exception was
thrown: RenderBox was not laid out:
RenderSemanticsGestureHandler#40649 relayoutBoundary=up7 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another exception was
thrown: RenderBox was not laid out: RenderPointerListener#0e00a
relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter (22774): Another exception was thrown: RenderBox was not
laid out: _RenderScrollSemantics#61006 relayoutBoundary=up5
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another
exception was thrown: RenderBox was not laid out:
RenderRepaintBoundary#782fb relayoutBoundary=up4 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another exception was
thrown: RenderBox was not laid out: RenderCustomPaint#3bc15
relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter (22774): Another exception was thrown: RenderBox was not
laid out: RenderRepaintBoundary#e1816 relayoutBoundary=up2 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another exception was
thrown: RenderBox was not laid out: RenderFlex#20580
relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter (22774): Another exception was thrown: NoSuchMethodError:
The method '>' was called on null.
my code is : paybills.dart file (main widget displaying both tabs)
import 'package:flutter/material.dart';
import '../../constans/constants.dart';
import 'first_tab.dart';
import 'second_tab.dart';
class PayBills extends StatefulWidget {
#override
_PayBillsState createState() => _PayBillsState();
}
class _PayBillsState extends State<PayBills>
with SingleTickerProviderStateMixin {
TabController _controller;
#override
void initState() {
super.initState();
_controller = TabController(vsync: this, length: 2);
}
#override
void dispose() {
_controller.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
centerTitle: true,
elevation: 0,
title: Text(
'تسديد فاتورة',
style: TextStyle(
color: leaderLogo,
fontSize: 24,
fontFamily: 'Calibri',
),
),
),
body: Container(
child: Column(children: [
Container(
height: 93,
width: 378,
child: Align(
alignment: Alignment.topCenter,
child: TabBar(
controller: _controller,
tabs: [
Tab(
child: Center(
child: Text(
'فواتير مستحقة',
style: TextStyle(
color: Colors.black,
),
),
),
),
Tab(
child: Center(
child: Text(
'فواتير مدفوعة',
style: TextStyle(
color: Colors.black,
),
),
),
),
],
),
),
),
TabBarView(
controller: _controller,
children: [
PayBillsList(),
SecondTab(),
],
),
]),
),
);
}
}
and this is firsttab.dart file displaying the first tab :
import 'package:flutter/material.dart';
import '../../constans/constants.dart';
class BillDetails extends StatelessWidget {
final String billName;
final String billImage;
final String billDate;
const BillDetails({Key key, this.billName, this.billImage, this.billDate})
: super(key: key);
#override
Widget build(BuildContext context) {
return Card(
child: ListTile(
leading: Container(
width: 40,
height: 40,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(billImage),
fit: BoxFit.fill,
)),
),
title: Text(
billName,
style: TextStyle(
fontFamily: 'Calibri',
fontSize: 16,
color: Colors.black,
),
),
subtitle: Text(
billDate,
style: TextStyle(
fontFamily: 'Calibri',
fontSize: 12,
color: Colors.black,
),
),
trailing: PayButton(),
),
);
}
}
class PayBillsList extends StatelessWidget {
final List<BillDetails> billsList = [
BillDetails(
billName: 'فاتورة كهرباء',
billImage: 'assets/images/electricity.png',
billDate: '30 / 4 / 2020',
),
BillDetails(
billName: 'فاتورة مياه',
billImage: 'assets/images/water.png',
billDate: '30 / 4 / 2020',
),
];
#override
Widget build(BuildContext context) {
return Container(
width: 378,
height: 93,
decoration: BoxDecoration(
border: Border.all(
width: 1,
color: Colors.grey,
),
shape: BoxShape.circle,
),
child: ListView.builder(
itemBuilder: (context, index) {
return BillDetails(
billName: billsList.elementAt(index).billName,
billImage: billsList.elementAt(index).billImage,
billDate: billsList.elementAt(index).billDate,
);
},
shrinkWrap: true,
itemCount: billsList.length,
scrollDirection: Axis.vertical,
),
);
}
}
class PayButton extends StatelessWidget {
const PayButton({
Key key,
}) : super(key: key);
#override
Widget build(BuildContext context) {
return ButtonTheme(
minWidth: 80,
height: 40,
child: RaisedButton(
onPressed: () {},
color: raisedButtonColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: Center(
child: Text(
//Login button text properties
'دفع',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: 'Calibri',
)),
),
),
);
}
}

Flutter: getting ListView in animated, positioned container being part of a stack

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()
),
]),

Every child of a RenderCustomMultiChildLayoutBox must have an ID in its parent data

I am trying to replace flutter's red screen with my own screen( a loading screen). But the app crashes when it is triggered. Here is how I am replacing the screen
ErrorWidget.builder = (FlutterErrorDetails details) => Scaffold(
appBar: AppBar(
title: Text("Loading"),
),
body: Positioned(
child:Loading()
),
);
And the loading widget is
Container(
child: Center(
child: SpinKitFadingCube(
color: Colors.white,
size: 50.0,
)
),
color: Colors.white.withOpacity(0.8),
);
The stacktrace is
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4952 pos 16: 'child is! ParentDataElement<ParentData>': is not true.
The relevant error-causing widget was:
Scaffold file:///C:/Users/Hemant/AndroidStudioProjects/discountapp/lib/main.dart:10:58
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
Incorrect use of ParentDataWidget.
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
Incorrect use of ParentDataWidget.
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
Every child of a RenderCustomMultiChildLayoutBox must have an ID in its parent data.
The relevant error-causing widget was:
Scaffold file:///C:/Users/Hemant/AndroidStudioProjects/discountapp/lib/main.dart:10:58
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
Every child of a RenderCustomMultiChildLayoutBox must have an ID in its parent data.
The following child has no ID: _RenderColoredBox#1154c NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0); id=null
... constraints: MISSING
... size: MISSING
... behavior: opaque
The relevant error-causing widget was:
Scaffold file:///C:/Users/Hemant/AndroidStudioProjects/discountapp/lib/main.dart:10:58
When the exception was thrown, this was the stack:
#0 MultiChildLayoutDelegate._callPerformLayout.<anonymous closure> (package:flutter/src/rendering/custom_layout.dart:228:13)
#1 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:234:10)
#2 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:401:14)
#3 RenderObject.layout (package:flutter/src/rendering/object.dart:1776:7)
#4 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
...
The following RenderObject was being processed when the exception was fired: RenderCustomMultiChildLayoutBox#ea7eb relayoutBoundary=up6
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=646.8)
... size: Size(392.7, 646.8)
RenderObject: RenderCustomMultiChildLayoutBox#ea7eb relayoutBoundary=up6
needs compositing
parentData: <none> (can use size)
constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=646.8)
size: Size(392.7, 646.8)
... child 1: _RenderColoredBox#1154c NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0); id=null
... constraints: MISSING
... size: MISSING
... behavior: opaque
... child: RenderPositionedBox#4cf2c NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: <none>
... constraints: MISSING
... size: MISSING
... alignment: center
... textDirection: ltr
... widthFactor: expand
... heightFactor: expand
... child: RenderPositionedBox#79ddb NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0)
... constraints: MISSING
... size: MISSING
... alignment: center
... textDirection: ltr
... widthFactor: expand
... heightFactor: expand
... child: RenderConstrainedBox#ba168 NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0)
... constraints: MISSING
... size: MISSING
... additionalConstraints: BoxConstraints(w=50.0, h=50.0)
... child 2: RenderConstrainedBox#26ec0 NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.appBar
... constraints: MISSING
... size: MISSING
... additionalConstraints: BoxConstraints(0.0<=w<=Infinity, 0.0<=h<=56.0)
... child: RenderSemanticsAnnotations#95f4f NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: <none>
... constraints: MISSING
... semantic boundary
... size: MISSING
... child: RenderAnnotatedRegion<SystemUiOverlayStyle>#5aedc NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: <none>
... constraints: MISSING
... size: MISSING
... child: RenderPhysicalModel#177a3 NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: <none>
... constraints: MISSING
... size: MISSING
... elevation: 4.0
... color: MaterialColor(primary value: Color(0xff2196f3))
... shadowColor: MaterialColor(primary value: Color(0xff2196f3))
... shape: BoxShape.rectangle
... borderRadius: BorderRadius.zero
... child 3: RenderStack#c7c1d NEEDS-LAYOUT NEEDS-PAINT
... parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.floatingActionButton
... constraints: MISSING
... size: MISSING
... alignment: centerRight
... textDirection: ltr
... fit: loose
... child 1: RenderTransform#9b142 NEEDS-LAYOUT NEEDS-PAINT
... parentData: not positioned; offset=Offset(0.0, 0.0)
... constraints: MISSING
... size: MISSING
... transform matrix: [0] 0.0,0.0,0.0,0.0
[1] 0.0,0.0,0.0,0.0
[2] 0.0,0.0,1.0,0.0
[3] 0.0,0.0,0.0,1.0
... origin: null
... alignment: center
... textDirection: ltr
... transformHitTests: true
... child: RenderTransform#9f5b2 NEEDS-LAYOUT NEEDS-PAINT
... parentData: <none>
... constraints: MISSING
... size: MISSING
... transform matrix: [0] 0.7,0.7,0.0,0.0
[1] -0.7,0.7,0.0,0.0
[2] 0.0,0.0,1.0,0.0
[3] 0.0,0.0,0.0,1.0
... origin: null
... alignment: center
... textDirection: ltr
... transformHitTests: true
════════════════════════════════════════════════════════════════════════════════════════════════════
W/libEGL (22033): EGLNativeWindowType 0x7019d6f010 disconnect failed
I have tried replacing the loading screen with a simple Text Widget. Same Thing happens. I found out how to do this from another stackoverflow post. Any help will be appreciated
Things you can try,
Wrap the Positioned() Widget with a stack.
Provide width and height constraints to Container
Stack(
children: [
Positioned(top: 10,child: Loading(.....))
],
),
Not sure why you need positioning Widget but, above is the way to go.
Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Center(
child: SpinKitFadingCube(
color: Colors.white,
size: 50.0,
)
),
color: Colors.white.withOpacity(0.8),
);
And this is how you should have it constrained(Example).

Flutter Nested List View why Cant i use a Row?

The code below works without using Row widget but it gives an error on using a nested list View with Row how can I use a Row if that's my Use Case in the above code I have one row inside which there are two columns
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(
title: Text("Dashboard"),
actions: <Widget>[
IconButton(
icon: Icon(Icons.add_circle),
iconSize: 50.0,
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => AddMember(),
),
);
},
),
],
),
drawer: MainDrawer(),
body: Container(
decoration: BoxDecoration(
image: Background().buildBackgroundImage(),
),
child: ListView(
children: <Widget>[
Row(
children: <Widget>[
Column(
children: <Widget>[
Text("1"),
],
),
Column(
children: <Widget>[
Text("Hammad"),
ListView.builder(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return Text("data");
},
itemCount: 100,
),
],
),
],
)
],
),
),
);
} }
The code gives the following error?
I/flutter ( 6704): RenderShrinkWrappingViewport#9e1c7 relayoutBoundary=up14 NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 6704): creator: ShrinkWrappingViewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#aa619] ← Semantics ←
I/flutter ( 6704): Listener ← _GestureSemantics ←
I/flutter ( 6704): RawGestureDetector-[LabeledGlobalKey#dbe17] ←
I/flutter ( 6704): _ScrollSemantics-[GlobalKey#17359] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ←
I/flutter ( 6704): NotificationListener ← ⋯
I/flutter ( 6704): parentData: (can use size)
I/flutter ( 6704): constraints: BoxConstraints(unconstrained)
I/flutter ( 6704): size: MISSING
I/flutter ( 6704): axisDirection: down
I/flutter ( 6704): crossAxisDirection: right
I/flutter ( 6704): offset: ScrollPositionWithSingleContext#d8d3b(offset: 0.0, range: null..null, viewport: null,
I/flutter ( 6704): ScrollableState, ClampingScrollPhysics -> ClampingScrollPhysics, IdleScrollActivity#ce116,
I/flutter ( 6704): ScrollDirection.idle)
I/flutter ( 6704): This RenderObject had the following descendants (showing up to depth 5):
I/flutter ( 6704): RenderSliverPadding#a684d NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 6704): RenderSliverList#59143 NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 6704): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderShrinkWrappingViewport#9e1c7 relayoutBoundary=up14 NEEDS-PAINT
I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#0105f relayoutBoundary=up13 NEEDS-PAINT
I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#cdf64 relayoutBoundary=up12 NEEDS-PAINT
I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderPointerListener#8301a relayoutBoundary=up11 NEEDS-PAINT
I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#89bf4 relayoutBoundary=up10 NEEDS-PAINT
I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#6bd35 relayoutBoundary=up9 NEEDS-PAINT
I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#417b1 relayoutBoundary=up8 NEEDS-PAINT
I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#97f18 relayoutBoundary=up7 NEEDS-PAINT
I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#df728 relayoutBoundary=up6 NEEDS-PAINT
I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderFlex#44487 relayoutBoundary=up5 NEEDS-PAINT
I/flutter ( 6704): Another exception was thrown: RenderBox was not laid out: RenderFlex#99d5f relayoutBoundary=up4 NEEDS-PAINT
I/flutter ( 6704): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 443 pos 12: 'child.hasSize': is not true.
I/flutter ( 6704): Another exception was thrown: NoSuchMethodError: The getter 'scrollOffsetCorrection' was called on null.
I/flutter ( 6704): Another exception was thrown: NoSuchMethodError: The method 'debugAssertIsValid' was called on null.
I/flutter ( 6704): Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.
Wrap your Columns with Flexible Widget.
Flexible(
child: Column(
children: <Widget>[
Keep in mind, whenever you are working with either Row widget or Column widget, you have to give definite sizes (less than the total available space) to all other widgets, but if you are not sure about the sizes, then give definite sizes to all the widgets, which needs minimum size to look fine, and for the other widgets use Expanded widget.
Look at this code for idea
Row(
children: <Widget>[
Expanded(
//Widget that is long and can cause overflow
child: LongWidget(),
),
//Give definite Size to this widget
FixedSizedWidget()
],
),