Related
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 make a application in flutter.
It's simple. In the principal layout exist an stack. In the first level are a background (what its a simple gradient), and in the second lever are the "body" of the application.
In this body of application i have a column (To put one item below another). this column are divided by separate widgets. One is for the "tile", and other is for a ListView, this ListView will show information from a database, but in this moment i only create 10 items for an example.
The code is this:
//This for a homepage
#override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Stack(
children: [
Background(),
HomeBody(),
],
),
);
The background (are in another file, in the homepage are imported):
#override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
stops: [0.2, 0.8],
colors: [
Color(0xff2E305F),
Color(0xff202333),
],
)),
);
And this is the "body":
#override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
PageTitle(),
Changes(),
],
),
);
}
}
class PageTitle extends StatelessWidget {
const PageTitle({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 20),
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: 25,
),
Text(
'Biggest Title',
style: TextStyle(
color: Colors.white,
fontSize: 55.0,
fontWeight: FontWeight.bold,
),
),
SizedBox(
//height: 1,
),
Text(
'low subtitle',
style: TextStyle(
color: Colors.white,
fontSize: 14.0,
fontWeight: FontWeight.w300,
),
),
],
),
),
);
}
}
class Changes extends StatelessWidget {
const Changes({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return ListView(
children: [
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
],
);
}
}
The error is:
═══════ Exception caught by rendering library ═════════════════════════════════
The following assertion was thrown during performResize():
Vertical viewport was given unbounded height.
Viewports expand in the scrolling direction to fill their container. In this case, a vertical viewport was given an unlimited amount of vertical space in which to expand. This situation typically happens when a scrollable widget is nested inside another scrollable widget.
If this widget is always nested in a scrollable widget there is no need to use a viewport because there will always be enough vertical space for the children. In this case, consider using a Column instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size the height of the viewport to the sum of the heights of its children.
The relevant error-causing widget was
ListView
lib/widgets/home_body_screen.dart:64
When the exception was thrown, this was the stack
#0 RenderViewport.computeDryLayout.<anonymous closure>
package:flutter/…/rendering/viewport.dart:1369
#1 RenderViewport.computeDryLayout
package:flutter/…/rendering/viewport.dart:1430
#2 RenderBox.performResize
package:flutter/…/rendering/box.dart:2332
#3 RenderObject.layout
package:flutter/…/rendering/object.dart:1758
#4 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:116
...
The following RenderObject was being processed when the exception was fired: RenderViewport#33c99 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
RenderObject: RenderViewport#33c99 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
offset: ScrollPositionWithSingleContext#b9cb0(offset: 0.0, range: null..null, viewport: null, ScrollableState, AlwaysScrollableScrollPhysics -> ClampingScrollPhysics -> RangeMaintainingScrollPhysics, IdleScrollActivity#03740, ScrollDirection.idle)
anchor: 0.0
center child: RenderSliverPadding#e0507 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: paintOffset=Offset(0.0, 0.0)
constraints: MISSING
geometry: null
padding: EdgeInsets.zero
textDirection: ltr
child: RenderSliverList#2982b NEEDS-LAYOUT NEEDS-PAINT
parentData: paintOffset=Offset(0.0, 0.0)
constraints: MISSING
geometry: null
no children current live
RenderBox was not laid out: RenderViewport#33c99 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1930 pos 12: 'hasSize'
The relevant error-causing widget was
ListView
lib/widgets/home_body_screen.dart:64
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderViewport#33c99 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1930 pos 12: 'hasSize'
The relevant error-causing widget was
ListView
lib/widgets/home_body_screen.dart:64
I'm a newest in flutter, i understand some things, but not all.
My opinion is: "this error is caused by her possition, yeah, its scrollable but he does not know where ends". Sorry if i wrong.
thanks all!
To use ListView inner SingleChildScrollView, you need to disable scrolling property of ListView.
ListView(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
primary: false,
children: []
)
I want to write the available devices under the image that is shown like this:
If I remove the image part I get only available devices but i need to add image as well above the BLE devices.
But I am getting an error if I run my code:
Performing hot reload...
Syncing files to device Redmi Note 8 Pro...
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during performResize():
Vertical viewport was given unbounded height.
Viewports expand in the scrolling direction to fill their container. In this case, a vertical viewport was given an unlimited amount of vertical space in which to expand. This situation typically happens when a scrollable widget is nested inside another scrollable widget.
If this widget is always nested in a scrollable widget there is no need to use a viewport because there will always be enough vertical space for the children. In this case, consider using a Column instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size the height of the viewport to the sum of the heights of its children.
The relevant error-causing widget was:
ListView file:///F:/epicare/lib/BluetoothScanningDevices.dart:113:12
When the exception was thrown, this was the stack:
#0 RenderViewport.computeDryLayout.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1365:15)
#1 RenderViewport.computeDryLayout (package:flutter/src/rendering/viewport.dart:1426:6)
#2 RenderBox.performResize (package:flutter/src/rendering/box.dart:2342:12)
#3 RenderObject.layout (package:flutter/src/rendering/object.dart:1763:9)
#4 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
...
The following RenderObject was being processed when the exception was fired: RenderViewport#6aa27 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
... size: MISSING
... axisDirection: down
... crossAxisDirection: right
... offset: ScrollPositionWithSingleContext#5f4da(offset: 0.0, range: null..null, viewport: null, ScrollableState, AlwaysScrollableScrollPhysics -> ClampingScrollPhysics -> RangeMaintainingScrollPhysics, IdleScrollActivity#9b3a7, ScrollDirection.idle)
... anchor: 0.0
RenderObject: RenderViewport#6aa27 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: <none> (can use size)
constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
size: MISSING
axisDirection: down
crossAxisDirection: right
offset: ScrollPositionWithSingleContext#5f4da(offset: 0.0, range: null..null, viewport: null, ScrollableState, AlwaysScrollableScrollPhysics -> ClampingScrollPhysics -> RangeMaintainingScrollPhysics, IdleScrollActivity#9b3a7, ScrollDirection.idle)
anchor: 0.0
... center child: RenderSliverPadding#47e11 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: paintOffset=Offset(0.0, 0.0)
... constraints: MISSING
... geometry: null
... padding: EdgeInsets.all(8.0)
... textDirection: ltr
... child: RenderSliverList#673c8 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: RenderViewport#6aa27 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1940 pos 12: 'hasSize'
The relevant error-causing widget was:
ListView file:///F:/epicare/lib/BluetoothScanningDevices.dart:113:12
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderBox was not laid out: RenderViewport#6aa27 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1940 pos 12: 'hasSize'
The relevant error-causing widget was:
ListView file:///F:/epicare/lib/BluetoothScanningDevices.dart:113:12
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderBox was not laid out: RenderIgnorePointer#d974c relayoutBoundary=up20 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1940 pos 12: 'hasSize'
The relevant error-causing widget was:
ListView file:///F:/epicare/lib/BluetoothScanningDevices.dart:113:12
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#6e459 relayoutBoundary=up19 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1940 pos 12: 'hasSize'
The relevant error-causing widget was:
ListView file:///F:/epicare/lib/BluetoothScanningDevices.dart:113:12
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderBox was not laid out: RenderPointerListener#0c15f relayoutBoundary=up18 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1940 pos 12: 'hasSize'
The relevant error-causing widget was:
ListView file:///F:/epicare/lib/BluetoothScanningDevices.dart:113:12
═════════════════════════════════════════════════════════════════════════════════════════════════
My code is:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'BluetoothConnectBand.dart';
import 'BluetoothConnectedSuccess.dart';
import 'package:flutter_blue/flutter_blue.dart';
class BluetoothScanningDevices extends StatefulWidget {
#override
_BluetoothScanningDevicesState createState() => _BluetoothScanningDevicesState();
}
class _BluetoothScanningDevicesState extends State<BluetoothScanningDevices> {
FlutterBlue flutterBlueInstance = FlutterBlue.instance;
final List<BluetoothDevice> devicesList = new List<BluetoothDevice>();
_addDeviceTolist(final BluetoothDevice device) {
if (!devicesList.contains(device)) {
setState(() {
devicesList.add(device);
});
}
}
#override
void initState() {
super.initState();
FlutterBlue.instance.connectedDevices
.asStream()
.listen((List<BluetoothDevice> devices) {
for (BluetoothDevice device in devices) {
_addDeviceTolist(device);
}
});
FlutterBlue.instance.scanResults.listen((List<ScanResult> results) {
for (ScanResult result in results) {
_addDeviceTolist(result.device);
}
});
FlutterBlue.instance.startScan();
}
ListView _buildListViewOfDevices() {
Size size = MediaQuery.of(context).size;
List<Container> containers = new List<Container>();
for (BluetoothDevice device in devicesList) {
containers.add(
Container(
width: size.width,
child: RaisedButton(
padding: EdgeInsets.symmetric(vertical:10.0, horizontal: 15.0),
elevation: 5.0,
color: Colors.white,
onPressed: (){
Navigator.push(
context,
MaterialPageRoute(
builder: (context){
return BluetoothConnectedSuccess();
},
),
);
},
child:Column(
children: [
Align(
alignment: Alignment.centerLeft,
child: Text(
device.name == '' ? '(Unknown Device)' : device.name,
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.w600,
fontFamily: 'Montserrat',
),
),
),
Align(
alignment: Alignment.centerLeft,
child: Text(
device.id.toString(),
style: TextStyle(
fontSize: 13.0,
color: Colors.black,
fontWeight: FontWeight.w500,
fontFamily: 'Montserrat',
)
),
),
],
),
),
),
);
}
return ListView(
padding: const EdgeInsets.all(8),
children: <Widget>[
...containers,
],
);
}
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
appBar: AppBar(
backgroundColor: const Color(0xffE5E0A1),
elevation: 0,
centerTitle: true,
title: Text("Connect Band",
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
fontFamily: 'Montserrat',
fontWeight: FontWeight.normal,
),
) ,
leading: IconButton(icon: Icon(Icons.arrow_back,color: Colors.black,),onPressed: (){
Navigator.push(
context,
MaterialPageRoute(builder: (context){
return BluetoothConnectBand();
},
),
);
},
),
actions: [
Padding(
padding: EdgeInsets.only(right: 5.0),
child: FlatButton(
onPressed: () {
},
child: Text(
"Search",
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.normal,
fontFamily: 'Montserrat',
),
),
),
)
],
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: size.height*0.4,
width: size.width,
color: const Color(0xffE5E0A1),
child: Image.asset('assets/images/bluetooth.png',)
),
Container(
width: size.width,
padding: EdgeInsets.symmetric(vertical: 20),
child: Text(
"Scanning Available Devices...",
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.w400,
fontFamily: 'Montserrat',
),
textAlign: TextAlign.center,
),
),
SingleChildScrollView(
child: _buildListViewOfDevices(),
)
],
),
);
}
}
Please help me out by telling me how can I write the available BLE devices under the image as shown in the picture attached
P.S: I am new to Flutter
As the logs show, the error is on line 113. I’m guessing this is caused by the ListView from _buildListViewOfDevices.
First, there is no need to wrap this ListView with SingleChildScrollView, the list view is scrollable already.
Second, instead, wrap the ListView with Expanded. This is tells the ListView to simply take up all remaining screen space in your Column widget.
Set shrinkWrap property of your ListView in _buildListViewOfDevices() function to true. This might work.
You can also remove SingleChildScrollView before the ListView. There is no need for it, ListView is already scrollable.
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,
)))
])),
],
),
),
],
),
),
],
);