How to add grid view and other view in same page?
I try with listview but it is showing error
I/flutter (10293): Another exception was thrown:
'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed
assertion: line 461 pos 12: 'child.hasSize': is not true. I/flutter
(10293): Another exception was thrown: NoSuchMethodError: The getter
'scrollOffsetCorrection' was called on null. I/flutter (10293):
Another exception was thrown: NoSuchMethodError: The method
'debugAssertIsValid' was called on null. I/flutter (10293): Another
exception was thrown: NoSuchMethodError: The getter 'visible' was
called on null
body:ListView(
children: <Widget>[
Text("checking"),
Container(
child: GridView.count(
crossAxisCount: 3,
childAspectRatio: .6,
children: _list.map((p) => ProductManagment(p)).toList(),
),
)
],
)
Another attempt
body:ListView(
children: <Widget>[
Text("checking"),
GridView.count(
crossAxisCount: 3,
childAspectRatio: .6,
children: _list.map((p) => ProductManagment(p)).toList(),
)
],
)
again error
I/flutter (10293): Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#f955c relayoutBoundary=up6 NEEDS-PAINT
I/flutter (10293): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#a9147 relayoutBoundary=up5 NEEDS-PAINT
I/flutter (10293): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#4a4c9 relayoutBoundary=up4 NEEDS-PAINT
I/flutter (10293): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 461 pos 12: 'child.hasSize': is not true.
I/flutter (10293): Another exception was thrown: NoSuchMethodError: The getter 'scrollOffsetCorrection' was called on null.
I/flutter (10293): Another exception was thrown: NoSuchMethodError: The method 'debugAssertIsValid' was called on null.
I/flutter (10293): Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.
I think you should just set height of the Container or warp it by Expanded widget. And tell what happen?. Might be size is missing thats way error occurred.
EDITED :
body:ListView(
children: <Widget>[
Text("checking"),
Container(
height: 300.0
child: GridView.count(
crossAxisCount: 3,
childAspectRatio: .6,
children: _list.map((p) => ProductManagment(p)).toList(),
),
)
],
)
Set height: 300.0 in container. (You can set height/width as per your requirement or try with Expanded widget)
Related
I have been recently getting this errors in my GridView, but only when running it on Real Devices(Happens with Android and iPhone devices).
Errors:
════════ Exception caught by rendering library ═════════════════════════════════
The following assertion was thrown during performLayout():
Leading widget consumes entire tile width. Please use a sized widget, or consider replacing ListTile with a custom widget (see https://api.flutter.dev/flutter/material/ListTile-class.html#material.ListTile.4)
'package:flutter/src/material/list_tile.dart':
Failed assertion: line 1722 pos 7: 'tileWidth != leadingSize.width || tileWidth == 0.0'
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
ListTile
When the exception was thrown, this was the stack
#2 _RenderListTile.performLayout
#3 RenderObject.layout
#4 RenderPadding.performLayout
#5 RenderObject.layout
#6 RenderPadding.performLayout
...
The following RenderObject was being processed when the exception was fired: _RenderListTile#3da4d NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
RenderObject: _RenderListTile#3da4d NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0) (can use size)
constraints: BoxConstraints(w=68.0, h=54.7)
size: MISSING
leading: RenderParagraph#bed81 relayoutBoundary=up1 NEEDS-PAINT
parentData: offset=Offset(0.0, 0.0) (can use size)
constraints: BoxConstraints(0.0<=w<=68.0, 0.0<=h<=54.7)
size: Size(68.0, 32.0)
textAlign: center
textDirection: ltr
softWrap: wrapping at box width
overflow: clip
locale: en_US
maxLines: unlimited
text: TextSpan
debugLabel: ((englishLike body1 2014).merge(blackMountainView bodyText2)).copyWith
inherit: false
color: Color(0xdd000000)
family: Roboto
size: 14.0
weight: 400
baseline: alphabetic
decoration: TextDecoration.none
"No parking spot"
title: RenderConstrainedBox#fbbdc NEEDS-LAYOUT NEEDS-PAINT
parentData: offset=Offset(0.0, 0.0)
constraints: MISSING
size: MISSING
additionalConstraints: BoxConstraints(unconstrained)
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: _RenderListTile#3da4d 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPadding#0b1e1 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPadding#0be47 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#459a2 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPointerListener#91e94 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#c896d 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderMouseRegion#0b93c 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#16727 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
Card-[<'No parking spot'>]
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#55a96 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
Card-[<'No parking spot'>]
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: _RenderInkFeatures#3a146 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
Card-[<'No parking spot'>]
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderCustomPaint#0921c 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
Card-[<'No parking spot'>]
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPhysicalShape#377a7 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
Card-[<'No parking spot'>]
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPadding#4b4f6 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
Card-[<'No parking spot'>]
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#00a52 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
GridView
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderRepaintBoundary#b4962 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
GridView
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
Leading widget consumes entire tile width. Please use a sized widget, or consider replacing ListTile with a custom widget (see https://api.flutter.dev/flutter/material/ListTile-class.html#material.ListTile.4)
'package:flutter/src/material/list_tile.dart':
Failed assertion: line 1722 pos 7: 'tileWidth != leadingSize.width || tileWidth == 0.0'
The relevant error-causing widget was
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: _RenderListTile#d708a 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPadding#b33e9 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPadding#a83e1 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#96675 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPointerListener#d189c 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#1e85d 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderMouseRegion#ec538 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
ListTile
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#31b1d 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
Card-[<'More Than 5 Totes'>]
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#d4c29 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
Card-[<'More Than 5 Totes'>]
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: _RenderInkFeatures#d2bdf 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
Card-[<'More Than 5 Totes'>]
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderCustomPaint#c0642 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
Card-[<'More Than 5 Totes'>]
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPhysicalShape#c75f1 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
Card-[<'More Than 5 Totes'>]
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPadding#44309 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
Card-[<'More Than 5 Totes'>]
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#0cbe8 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
GridView
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderRepaintBoundary#e40ed 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
GridView
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 544 pos 12: 'child.hasSize': is not true.
The relevant error-causing widget was
GridView
════════════════════════════════════════════════════════════════════════════════
This the code where I am building this GridView.
Widget build(BuildContext context) {
return Column(children: [
Expanded(
child: GridView.builder(
//physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
//scrollDirection: Axis.vertical,
itemCount: 6,
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 3),
),
itemBuilder: (BuildContext context, int index) {
return Card(
key: ValueKey(options[index].description),
margin: const EdgeInsets.all(10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
// The color depends on this is selected or not
color: options[index].isSelected == true
? Colors.amber
: Colors.white,
child: ListTile(
onTap: () {
// if this item isn't selected yet, "isSelected": false -> true
// If this item already is selected: "isSelected": true -> false
setState(() {
options[index].isSelected = !options[index].isSelected;
//selectedItems[index] = options[index].description;
selectedItems[index] = options[index].description;
});
},
leading: Text(
options[index].description.toString(),
textAlign: TextAlign.center,
),
/*title: Text(
options[index].description,
),*/
));
},
),
),
ElevatedButton(
//onPressed: () => insertText('Drop \n', textController),
//onPressed: () => showModalOptions(context),
onPressed: () => {
InsertText().insertText(
'Drop Number: ' + widget.dropsController.text + '\n',
widget.textController),
for (var i = 0; i < selectedItems.length; i++)
{
if (selectedItems[i].isNotEmpty)
if (i == 0)
{
InsertText().insertText(
selectedItems[i] + ' + ', widget.textController),
}
else if (i != selectedItems.length)
{
InsertText().insertText(
selectedItems[i] + ' ', widget.textController)
}
},
setState(() {
for (var i = 0; i < options.length; i++) {
options[i].isSelected = false;
selectedItems[i] = '';
}
})
},
child: Text('Add Drop'),
),
]);
This is where I am calling on Main.dart
#override
Widget build(BuildContext context) {
return MaterialApp(
home: DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
title: Text('Driver Notes'),
bottom: TabBar(
tabs: [
Icon(Icons.notes),
Icon(Icons.ac_unit),
],
),
),
body: TabBarView(children: [
// Action Tab
Column(
children: [
Row(children: [
Container(
child: SizedBox(
width: 150,
child: TextField(
decoration: InputDecoration(labelText: 'Starting Date'),
controller: startDate,
onTap: _startDatePicker,
),
),
),
SizedBox(
width: 150,
child: TextField(
decoration: InputDecoration(labelText: 'Starting Time'),
controller: startTime,
onTap: _startTimePicker,
),
),
]),
Row(children: [
SizedBox(
width: 150,
child: TextField(
decoration: InputDecoration(labelText: 'Finising Date'),
controller: finishDate,
onTap: _finishDatePicker,
),
),
SizedBox(
width: 150,
child: TextField(
decoration: InputDecoration(labelText: 'Finising Time'),
controller: finishTime,
onTap: _finishTimePicker,
),
),
]),
TextField(
decoration: InputDecoration(labelText: 'Drop Number'),
keyboardType: TextInputType.number,
controller: dropController,
),
Expanded(
child: ReasonSelection(textController, dropController),
),
],
),
// Result Tab
NotesTab(
textController, startDate, startTime, finishDate, finishTime),
]),
),
),
);
}
}
Running on Android emulator:
I have tried some solutions like using Expanded, SizedBox, setting shrinkWrap to true, no sucess until now.
Any idea of what is happening or how to fix it?
Thanks.
I think you can use CustomScrollView and add slivers for this case
I was trying to have another widget in my flutter page so instead of having a container I used (column /list view )
this is the code (main things have red line )
enter image description here
now Im getting these errors
child: RenderPointerListener#c3ba4 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData:
constraints: MISSING
size: MISSING
behavior: deferToChild
listeners: down
child: ChartContainerRenderObject#c7bf3 NEEDS-LAYOUT NEEDS-PAINT
parentData:
constraints: MISSING
semantic boundary
size: MISSING
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderPadding object was given an infinite size during layout.
The relevant error-causing widget was
SafeArea
lib\dept.dart:62
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
A RenderFlex overflowed by Infinity pixels on the bottom.
The relevant error-causing widget was
Column
lib\dept.dart:60
the issue was solved by adding height:value to the container
child: ListView(
shrinkWrap: true,
children: [
Container(
height: 400,
child: SafeArea(.......)),
Container(child:new Text("palestine");))
This issue can be solved by adding Flexible to your widget.
I'm still very new to flutter and I'm trying to create a comment list section where the child comment can be nested in the parent comment.
What I did was create a ListView inside a dynamic ListView in this case I used a 3rd party library PagewiseListView for lazy loading. But there was some error in building the List.
#override
Widget build(BuildContext context) {
return Scaffold(
body: pageWiseBuilder(context, _story.kids ?? [], PAGE_SIZE),
);
}
Widget pageWiseBuilder(BuildContext context, List<int> list, int pageSize) {
if (list != null && list.length > 0) {
return PagewiseListView(
padding: EdgeInsets.all(15.0),
pageSize: pageSize,
itemBuilder: this.itemBuilder,
pageFuture: (pageIndex) =>
_repository.fetchComments(list, pageIndex * pageSize, pageSize),
);
} else {
return Container();
}
}
Widget itemBuilder(BuildContext context, Comment entry, int index) {
return Column(
children: <Widget>[
ListTile(
title: Text(entry.by ??= ""),
subtitle: Html(
data: unescape.convert(entry.text ??= ""),
useRichText: true,
onLinkTap: (url) {
_launchURL(url);
},
showImages: true,
renderNewlines: true,
),
),
Divider(),
Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: SizedBox(height: 200.0,
child: ListView.builder(
physics: ClampingScrollPhysics(),
shrinkWrap: true,
itemCount: 5,
itemBuilder: (context, index) {
return Padding(
padding: EdgeInsets.only(top: 8.0),
child: Text('Nested list item $index'),
);
},
),
),
),
],
),
],
);
}
I/flutter ( 885): Another exception was thrown: RenderFlex children
have non-zero flex but incoming height constraints are unbounded.
I/flutter ( 885): Another exception was thrown: RenderBox was not
laid out: RenderFlex#a1031 relayoutBoundary=up6 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 885): Another exception was thrown: RenderBox was not
laid out: RenderFlex#11980 relayoutBoundary=up5 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 885): Another exception was thrown: RenderFlex children
have non-zero flex but incoming height constraints are unbounded.
I/flutter ( 885): Another exception was thrown: RenderBox was not
laid out: RenderFlex#a33b5 relayoutBoundary=up6 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 885): Another exception was thrown: RenderBox was not
laid out: RenderFlex#48c2a relayoutBoundary=up5 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 885): Another exception was thrown: RenderBox was not
laid out: RenderRepaintBoundary#d6726 relayoutBoundary=up4 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 885): Another exception was thrown:
'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed
assertion: line 549 pos 12: 'child.hasSize': is not true.
I/flutter ( 885): Another exception was thrown: NoSuchMethodError:
The method '>' was called on null.
I/flutter ( 885): Another exception was thrown:
'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed
assertion: line 549 pos 12: 'child.hasSize': is not true.
Your ListView must be wrapped with a Widget that has at least the height.
Container(
height: 100,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[],
),
),
I think you need to remove any Flexible in your code, It works for me.
I have the following Table inside Card. Since I added the padding widget, I get the following error:
I/flutter (19671): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (19671): The following assertion was thrown during performLayout():
I/flutter (19671): 'package:flutter/src/rendering/table.dart': Failed assertion: line 882 pos 16: 'tableWidth >=
I/flutter (19671): targetWidth': is not true.
I/flutter (19671):
I/flutter (19671): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (19671): more information in this error message to help you determine and fix the underlying cause.
I/flutter (19671): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (19671): https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (19671):
I/flutter (19671): When the exception was thrown, this was the stack:
I/flutter (19671): #2 RenderTable._computeColumnWidths (package:flutter/src/rendering/table.dart:882:16)
I/flutter (19671): #3 RenderTable.performLayout (package:flutter/src/rendering/table.dart:1000:33)
code:
body: Container(
padding: EdgeInsets.all(5.0), margin: EdgeInsets.all(10.0),
child: Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Table(
children: list)
])
)
)
Why adding the padding widget throws this error?
How I can add padding and margin for my Card?
Because of 2 it won't account for growth in the container based on the padding, it will pad inward causing the inners to overflow. Just use the provided properties from Container.
Container has a padding and margin property which can be applied. You don't nee to wrap your Containers child with padding.
Container(
child: Text(),
padding: EdgeInsets.all(5.0),
margin: EdgeInsets.all(10.0)
)
See Container-class for more properties that can be used
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()
],
),