I have my listView that works correctly without the Row code, but I need to place a textfield and a button under the last element of the ListView. both at the same height. that's why I thought about using Row. but if I try to write it under my listView and start the app, I don't see anything, not even the listView. as an error it is only reported to me:
The relevant error-causing widget was:
ListView file:///Users/apple/Desktop/Work%202021/toduba-merchant/lib/tabs/home_tab.dart:95:22
When the exception was thrown, this was the stack:
#0 RenderViewportBase._paintContents (package:flutter/src/rendering/viewport.dart:649:25)
#1 RenderViewportBase.paint (package:flutter/src/rendering/viewport.dart:641:7)
#2 RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2322:7)
#3 PaintingContext._repaintCompositedChild (package:flutter/src/rendering/object.dart:140:11)
#4 PaintingContext.repaintCompositedChild (package:flutter/src/rendering/object.dart:100:5)
...
The following RenderObject was being processed when the exception was fired: RenderViewport#ba090
... needs compositing
... parentData: (can use size)
... constraints: BoxConstraints(w=375.0, h=474.9)
... layer: OffsetLayer#32030 DETACHED
... engine layer: Null#007db
... offset: Offset(0.0, 0.0)
... size: Size(375.0, 474.9)
... axisDirection: down
... crossAxisDirection: right
... offset: ScrollPositionWithSingleContext#d8a7b(offset: 0.0, range: null..null, viewport: 474.9, ScrollableState, BouncingScrollPhysics -> RangeMaintainingScrollPhysics, IdleScrollActivity#f75ff, ScrollDirection.idle)
... anchor: 0.0
RenderObject: RenderViewport#ba090
needs compositing
parentData: (can use size)
constraints: BoxConstraints(w=375.0, h=474.9)
layer: OffsetLayer#32030 DETACHED
engine layer: Null#007db
offset: Offset(0.0, 0.0)
size: Size(375.0, 474.9)
axisDirection: down
crossAxisDirection: right
offset: ScrollPositionWithSingleContext#d8a7b(offset: 0.0, range: null..null, viewport: 474.9, ScrollableState, BouncingScrollPhysics -> RangeMaintainingScrollPhysics, IdleScrollActivity#f75ff, ScrollDirection.idle)
anchor: 0.0
... center child: RenderSliverPadding#7222a relayoutBoundary=up1 NEEDS-PAINT
... needs compositing
... parentData: paintOffset=Offset(0.0, 0.0) (can use size)
... constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.idle, scrollOffset: 0.0, remainingPaintExtent: 474.9, crossAxisExtent: 375.0, crossAxisDirection: AxisDirection.right, viewportMainAxisExtent: 474.9, remainingCacheExtent: 724.9, cacheOrigin: 0.0)
... geometry: null
... padding: EdgeInsets.all(20.0)
... textDirection: ltr
... child: RenderSliverList#9d74e relayoutBoundary=up2 NEEDS-PAINT
... needs compositing
... parentData: paintOffset=Offset(0.0, 0.0) (can use size)
... constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.idle, scrollOffset: 0.0, remainingPaintExtent: 454.9, crossAxisExtent: 335.0, crossAxisDirection: AxisDirection.right, viewportMainAxisExtent: 474.9, remainingCacheExtent: 704.9, cacheOrigin: 0.0)
... geometry: null
... currently live children: 0 to 3
... child with index 0: RenderIndexedSemantics#3b488 relayoutBoundary=up3 NEEDS-PAINT
... needs compositing
... parentData: index=0; layoutOffset=0.0 (can use size)
... constraints: BoxConstraints(w=335.0, 0.0<=h<=Infinity)
... semantic boundary
... size: Size(335.0, 29.0)
... index: 0
... child: RenderRepaintBoundary#8cd41 relayoutBoundary=up4 NEEDS-PAINT
... needs compositing
... parentData: (can use size)
... constraints: BoxConstraints(w=335.0, 0.0<=h<=Infinity)
... size: Size(335.0, 29.0)
... usefulness ratio: no metrics collected yet (never painted)
... child with index 1: RenderIndexedSemantics#c3e1f relayoutBoundary=up3 NEEDS-PAINT
... needs compositing
... parentData: index=1; layoutOffset=29.0 (can use size)
... constraints: BoxConstraints(w=335.0, 0.0<=h<=Infinity)
... semantic boundary
... size: Size(335.0, 260.0)
... index: 1
... child: RenderRepaintBoundary#16c99 relayoutBoundary=up4 NEEDS-PAINT
... needs compositing
... parentData: (can use size)
... constraints: BoxConstraints(w=335.0, 0.0<=h<=Infinity)
... size: Size(335.0, 260.0)
... usefulness ratio: no metrics collected yet (never painted)
... child with index 2: RenderIndexedSemantics#967b1 relayoutBoundary=up3 NEEDS-PAINT
... needs compositing
... parentData: index=2; layoutOffset=289.0 (can use size)
... constraints: BoxConstraints(w=335.0, 0.0<=h<=Infinity)
... semantic boundary
... size: Size(335.0, 22.0)
... index: 2
... child: RenderRepaintBoundary#348b5 relayoutBoundary=up4 NEEDS-PAINT
... needs compositing
... parentData: (can use size)
... constraints: BoxConstraints(w=335.0, 0.0<=h<=Infinity)
... size: Size(335.0, 22.0)
... usefulness ratio: no metrics collected yet (never painted)
... child with index 3: RenderIndexedSemantics#047b6 relayoutBoundary=up3 NEEDS-PAINT
... needs compositing
... parentData: index=3; layoutOffset=311.0 (can use size)
... constraints: BoxConstraints(w=335.0, 0.0<=h<=Infinity)
... semantic boundary
... size: MISSING
... index: 3
... child: RenderRepaintBoundary#af13c relayoutBoundary=up4 NEEDS-PAINT
... needs compositing
... parentData: (can use size)
... constraints: BoxConstraints(w=335.0, 0.0<=h<=Infinity)
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
return Container(
color: appColors.primaryColor,
child: ListView(
primary: false,
children: [
// TITOLO
Align(
alignment: Alignment.center,
child: Container(
child: Text(
localization.showQR,
style: Theme.of(context).primaryTextTheme.headline5.copyWith(
color: appColors.green,
fontWeight: FontWeight.bold,
),
),
),
),
Align(
alignment: Alignment.center,
child: Container(
child: qrCodeHolder
),
),
Align(
alignment: Alignment.center,
child: Container(
child: AutoSizeText(
localization.home_subLabel,
textAlign: TextAlign.center,
maxLines: 1,
style: Theme.of(context).primaryTextTheme.headline5.copyWith(
color: appColors.green,
fontWeight: FontWeight.bold,
),
),
),
),
Positioned(
//top: size.height * .02,
//right: size.width * .02,
child: Row(
children: [
TextField(
inputFormatters: [
new LengthLimitingTextInputFormatter(7),
],
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white),
),
),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 18.0,
color: Colors.black,
),
),
IconButton(
icon: Image.asset("assets/images/send.png"),
onPressed: () => showDialog(context: context, builder: (_) => PaymentDialog()),
),
Text("dfjbsdifbsdf"),
]
),
),
],
padding: EdgeInsets.all(20.0),
),
);
You need to wrap your TextField in an Expanded widget or a container with limited width.
This is because the Row assumes it can take maximum width, and the TextField and TextFormField widget by default try to take the maximum width possible.
By putting them inside each other, you'll get the error you are having.
Use this for the TextField, inside a row, it must be wrapped in Expanded or Flexible.
Row(
children: [
Expanded(
child: TextField ()
)
])
Related
Since i implemnetd the FittedBox with a Full width Image the app tells me to that i have a render error but i cant fix it.
All the other widgets have a expanded function and it all worked fine until i inserted the banner.
But even if i make it as small as 5 pixel the app tells me the same error..
How can i fix that?
I assume its the fitted box.
The Error:
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderFittedBox#d209c relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
package:flutter/…/rendering/box.dart:1
Failed assertion: line 2001 pos 12: 'hasSize'
The relevant error-causing widget was
Column
lib/…/event_details_screen/match_details.dart:45
The following RenderObject was being processed when the exception was fired: RenderFittedBox#d209c relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
RenderObject: RenderFittedBox#d209c relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
constraints: BoxConstraints(0.0<=w<=428.0, 0.0<=h<=Infinity)
size: MISSING
fit: fitWidth
alignment: Alignment.center
textDirection: ltr
child: RenderSemanticsAnnotations#a5a83 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(unconstrained)
size: Size(0.0, 0.0)
child: RenderImage#d2457 relayoutBoundary=up5 NEEDS-PAINT
parentData: (can use size)
constraints: BoxConstraints(unconstrained)
size: Size(0.0, 0.0)
image: null
alignment: Alignment.center
invertColors: false
filterQuality: low
class _DefaultDetailsState extends State<DefaultDetails> {
final double padding = EVENT_DETAILS_PADDING;
#override
Widget build(BuildContext context) {
return DetailScreen(
child: _screen(),
);
}
Widget _screen() {
return Column(
children: [
_section(
flex: 4,
child: TournamentTitleSection(
event: widget.event,
host: widget.host,
),
),
FittedBox(
fit: BoxFit.fitWidth,
child: Image.asset('assets/images/ads/mockup_ad.PNG'),
),
_section(
flex: 10,
child: DefaultDetailsSection(
event: widget.event,
host: widget.host,
),
),
_divider(),
_section(
flex: 4,
child: TimesSection(
event: widget.event,
calendarName: _calendarName,
),
),
...
The Widget _section.
Widget _section({Widget? child, int flex = 1}) {
return Expanded(
flex: flex,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: padding),
child: child ?? const SizedBox(),
),
);
}
I allready tried to wrap it in a Expanded Widget and also sized boy but nothing worked.
i have been trying to make an app that has a listview and ontap it goes to details page and shows info that got from navigator (by a datamodel)here is the code i have tried everything in the internet but it still has this two errors (its not a bug)
code
import 'package:flutter/material.dart';
import 'package:train/pages/dishdatamodel.dart';
import 'package:train/pages/dishdetail.dart';
import 'home.dart';
class Favorites extends StatefulWidget {
#override
_FavoritesState createState() => _FavoritesState();
}
class _FavoritesState extends State<Favorites> {
var itemcount =4;
static List<String> dishname = ['MEXICAN BURGER','PASTA','DESERT','ICE CREAM','BIRIYANI','EGG BIRIYANI','CHICKEN BIRIYANI'];
static List<String> dishprice = ['12\$', '20\$', '15\$', '10\$', '30\$', '35\$', '40\$'];
static List urlImages = [
'https://storage.googleapis.com/cms-storage-bucket/442072a900a8a1c2cc10.jpg''https://pixabay.com/photos/cake-piece-plate-dessert-pastry-1971552/',
'https://pixabay.com/photos/cake-piece-plate-dessert-pastry-1971552/',
'https://pixabay.com/photos/cake-piece-plate-dessert-pastry-1971552/',
'https://pixabay.com/photos/cake-piece-plate-dessert-pastry-1971552/',
'https://pixabay.com/photos/cake-piece-plate-dessert-pastry-1971552/',
'https://pixabay.com/photos/cake-piece-plate-dessert-pastry-1971552/',
];
final List<dishdatamodel>dishdata = List.generate(
dishname.length,
(index) =>dishdatamodel('${dishname[index]}', '${urlImages[index]}',
'${dishname[index]}description.......', '${dishprice[index]}'));
#override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Column(
children: [
ListView.builder(
itemCount: dishdata.length,
itemBuilder: (BuildContext context,int index){
return Card(
color: Colors.deepOrange,
child: ListTile(
title: Text(dishdata[index].name),
trailing: Text(dishdata[index].price),
leading: ConstrainedBox(
constraints: BoxConstraints(
minHeight: 40,
minWidth: 40,
maxHeight: 50,
maxWidth: 50,
),
child: Image.network(dishdata[index].imageurl),
),
onTap: (){
Navigator.of(context).push(MaterialPageRoute(builder: (context) => dishdetail(dishdatamode: dishdata[index],)));
},
),
);
})
],
),
),
);
}
}
here is the errors
======== Exception caught by widgets library =======================================================
The following RangeError was thrown building _BodyBuilder:
RangeError (index): Invalid value: Not in inclusive range 0..5: 6
The relevant error-causing widget was:
Scaffold file:///C:/Users/user/Desktop/android%20studio%20projets/train/lib/nav.dart:29:12
When the exception was thrown, this was the stack:
#0 List.[] (dart:core-patch/growable_array.dart:177:60)
#1 new _FavoritesState.<anonymous closure> (package:train/pages/favorites.dart:26:65)
#2 new _GrowableList.generate (dart:core-patch/growable_array.dart:128:28)
#3 new _FavoritesState (package:train/pages/favorites.dart:24:44)
#4 Favorites.createState (package:train/pages/favorites.dart:8:36)
====================================================================================================
======== Exception caught by rendering library =====================================================
The following assertion was thrown during performLayout():
Each child must be laid out exactly once.
The _ScaffoldLayout custom multichild layout delegate forgot to lay out the following child:
_ScaffoldSlot.body: RenderErrorBox#14191 NEEDS-LAYOUT NEEDS-PAINT
parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body
constraints: MISSING
size: MISSING
The relevant error-causing widget was:
Scaffold file:///C:/Users/user/Desktop/android%20studio%20projets/train/lib/nav.dart:29:12
When the exception was thrown, this was the stack:
#0 MultiChildLayoutDelegate._callPerformLayout.<anonymous closure> (package:flutter/src/rendering/custom_layout.dart:246:11)
#1 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:259:8)
#2 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:402:14)
#3 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1634:7)
#4 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:884:18)
...
The following RenderObject was being processed when the exception was fired: RenderCustomMultiChildLayoutBox#dc3f5 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
. needs compositing
. parentData: <none> (can use size)
. constraints: BoxConstraints(w=392.7, h=850.9)
. size: Size(392.7, 850.9)
RenderObject: RenderCustomMultiChildLayoutBox#dc3f5 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: <none> (can use size)
constraints: BoxConstraints(w=392.7, h=850.9)
size: Size(392.7, 850.9)
. child 1: RenderErrorBox#14191 NEEDS-LAYOUT NEEDS-PAINT
. parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body
. constraints: MISSING
. size: MISSING
. child 2: RenderPositionedBox#34f21 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
. needs compositing
. parentData: offset=Offset(0.0, 83.6); id=_ScaffoldSlot.body (can use size)
. constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=711.3)
. size: Size(392.7, 711.3)
. alignment: center
. textDirection: ltr
. widthFactor: expand
. heightFactor: expand
. child 3: RenderConstrainedBox#67334 relayoutBoundary=up1
. needs compositing
. parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.appBar (can use size)
. constraints: BoxConstraints(w=392.7, 0.0<=h<=850.9)
. size: Size(392.7, 83.6)
. additionalConstraints: BoxConstraints(0.0<=w<=Infinity, 0.0<=h<=83.6)
. child: RenderSemanticsAnnotations#268b5 relayoutBoundary=up2
. needs compositing
. parentData: <none> (can use size)
. constraints: BoxConstraints(w=392.7, 0.0<=h<=83.6)
. semantic boundary
. size: Size(392.7, 83.6)
. child: RenderAnnotatedRegion<SystemUiOverlayStyle>#8f8ff relayoutBoundary=up3
. needs compositing
. parentData: <none> (can use size)
. constraints: BoxConstraints(w=392.7, 0.0<=h<=83.6)
. size: Size(392.7, 83.6)
. child: RenderPhysicalModel#6f052 relayoutBoundary=up4
. needs compositing
. parentData: <none> (can use size)
. constraints: BoxConstraints(w=392.7, 0.0<=h<=83.6)
. layer: PhysicalModelLayer#4e633
. engine layer: PhysicalShapeEngineLayer#9e72c
. elevation: 4.0
. color: MaterialColor(primary value: Color(0xffff5722))
. size: Size(392.7, 83.6)
. elevation: 4.0
. color: MaterialColor(primary value: Color(0xffff5722))
. shadowColor: MaterialColor(primary value: Color(0xffff5722))
. shape: BoxShape.rectangle
. borderRadius: BorderRadius.zero
. child 4: RenderSemanticsAnnotations#b44d0 relayoutBoundary=up1 NEEDS-PAINT
. needs compositing
. parentData: offset=Offset(0.0, 794.9); id=_ScaffoldSlot.bottomNavigationBar (can use size)
. constraints: BoxConstraints(w=392.7, 0.0<=h<=850.9)
.. size: Size(392.7, 56.0)
.. child: RenderPhysicalModel#627c2 relayoutBoundary=up2 NEEDS-PAINT
.. needs compositing
.. parentData: <none> (can use size)
.. constraints: BoxConstraints(w=392.7, 0.0<=h<=850.9)
.. layer: PhysicalModelLayer#26163
.. engine layer: PhysicalShapeEngineLayer#3df82
.. elevation: 8.0
.. color: Color(0xfffafafa)
.. size: Size(392.7, 56.0)
.. elevation: 8.0
.. color: Color(0xfffafafa)
.. shadowColor: Color(0xfffafafa)
.. shape: BoxShape.rectangle
.. borderRadius: BorderRadius.zero
.. child: _RenderInkFeatures#64e29 relayoutBoundary=up3 NEEDS-PAINT
.. parentData: <none> (can use size)
.. constraints: BoxConstraints(w=392.7, 0.0<=h<=850.9)
.. size: Size(392.7, 56.0)
.. child: RenderConstrainedBox#c08b0 relayoutBoundary=up4 NEEDS-PAINT
.. parentData: <none> (can use size)
.. constraints: BoxConstraints(w=392.7, 0.0<=h<=850.9)
.. size: Size(392.7, 56.0)
.. additionalConstraints: BoxConstraints(0.0<=w<=Infinity, 56.0<=h<=Infinity)
.. child 5: RenderStack#b0601 relayoutBoundary=up1
.. parentData: offset=Offset(376.7, 778.9); id=_ScaffoldSlot.floatingActionButton (can use ize)
.. constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=850.9)
.. size: Size(0.0, 0.0)
.. alignment: centerRight
.. textDirection: ltr
.. fit: loose
.. child 1: RenderTransform#7227d relayoutBoundary=up2
.. parentData: not positioned; offset=Offset(0.0, 0.0) (can use size)
.. constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=850.9)
.. size: Size(0.0, 0.0)
.. 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#1577a relayoutBoundary=up3
.. parentData: <none> (can use size)
.. constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=850.9)
.. size: Size(0.0, 0.0)
.. 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
====================================================================================================
Wrap ListView.builder with Expanded widget, Also no need to use SingleChildScrollView.
Or You can use SingleChildScrollView with ListView.builder physics: NeverScrollableScrollPhysics(),
Or just render item inside Column like
body: SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: Column(
children: [
...dishdata.map((e) => Card(
color: Colors.deepOrange,
child: ListTile(
title: Text(e.name),
trailing: Text(e.price),
leading: ConstrainedBox(
constraints: BoxConstraints(
minHeight: 40,
minWidth: 40,
maxHeight: 50,
maxWidth: 50,
),
child: Image.network(e.imageurl),
),
onTap: () {},
),
)),
],
),
),
);
There are others error I can see from console like range error,
This error is because you didn't set a height for the ListView, simply you can wrap the list view into a Container and give it a height number,
notice that if you gonna use context.size.height, it's better to use MediaQuery.of(context).size.height
if it doesn't work, try wrapping it into an Expanded widget
I notify a very strange bug in my Flutter app. I'm using a ListView with an itemExtend value. When navigating inside the app everything is working fine – no error messages in the console. But after a Hot Reload, for example by editing and saving the code on the file on which the ListView is placed, I get many RenderRepaintBoundary errors.
This is my ListView:
return ListView.builder(
padding: EdgeInsets.only(top: 25, bottom: 20),
shrinkWrap: true,
itemExtent: 95, // Error only appears if I add itemExtent
physics: ClampingScrollPhysics(),
itemCount: entriesController.guestbookEntries.length,
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onLongPress: () async {
// Some stuff
},
child: Text("Test Widget")
);
},
);
After Hot Reload I get the following error messages in the console (But the app works as expected):
[Easy Localization] Build [Easy Localization] Init Localization
Delegate [Easy Localization] Init provider
════════ Exception caught by rendering library
═════════════════════════════════ The following _CastError was thrown
during performLayout(): Null check operator used on a null value
The relevant error-causing widget was ListView When the exception was
thrown, this was the stack
#0 RenderSliverFixedExtentBoxAdaptor.performLayout
#1 RenderObject.layout
#2 RenderSliverEdgeInsetsPadding.performLayout
#3 RenderSliverPadding.performLayout
#4 RenderObject.layout ... The following RenderObject was being processed when the exception was fired:
RenderSliverFixedExtentList#b073b relayoutBoundary=up11 NEEDS-LAYOUT
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE RenderObject:
RenderSliverFixedExtentList#b073b relayoutBoundary=up11 NEEDS-LAYOUT
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: paintOffset=Offset(0.0, 25.0) (can use size)
constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.idle, scrollOffset: 0.0,
remainingPaintExtent: Infinity, crossAxisExtent: 390.0,
crossAxisDirection: AxisDirection.right, viewportMainAxisExtent:
Infinity, remainingCacheExtent: Infinity, cacheOrigin: 0.0)
geometry: SliverGeometry(scrollExtent: 760.0, paintExtent: 760.0, maxPaintExtent: 760.0, cacheExtent: 760.0)
scrollExtent: 760.0
paintExtent: 760.0
maxPaintExtent: 760.0
cacheExtent: 760.0
currently live children: 0 to 7
child with index 0: RenderIndexedSemantics#56371 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: index=0; layoutOffset=0.0
constraints: BoxConstraints(w=390.0, h=95.0)
semantic boundary
size: Size(390.0, 95.0)
index: 0
child: RenderRepaintBoundary#1056f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
layer: OffsetLayer#9f74a
engine layer: OffsetEngineLayer#9b21b
offset: Offset(0.0, 25.0)
size: Size(390.0, 95.0)
metrics: 83.3% useful (1 bad vs 5 good)
diagnosis: this is a useful repaint boundary and should be kept
child: RenderSemanticsGestureHandler#c0c8b NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
gestures: long press
child: RenderPointerListener#c4b22 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
behavior: deferToChild
listeners: down
child with index 1: RenderIndexedSemantics#c082a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: index=1; layoutOffset=95.0
constraints: BoxConstraints(w=390.0, h=95.0)
semantic boundary
size: Size(390.0, 95.0)
index: 1
child: RenderRepaintBoundary#f5bbf NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
layer: OffsetLayer#003b7
engine layer: OffsetEngineLayer#75c0b
offset: Offset(0.0, 120.0)
size: Size(390.0, 95.0)
metrics: 83.3% useful (1 bad vs 5 good)
diagnosis: this is a useful repaint boundary and should be kept
child: RenderSemanticsGestureHandler#eee56 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
gestures: long press
child: RenderPointerListener#82ca0 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
behavior: deferToChild
listeners: down
child with index 2: RenderIndexedSemantics#dc0db NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: index=2; layoutOffset=190.0
constraints: BoxConstraints(w=390.0, h=95.0)
semantic boundary
size: Size(390.0, 95.0)
index: 2
child: RenderRepaintBoundary#394b9 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
layer: OffsetLayer#19e8a
engine layer: OffsetEngineLayer#11d00
offset: Offset(0.0, 215.0)
size: Size(390.0, 95.0)
metrics: 83.3% useful (1 bad vs 5 good)
diagnosis: this is a useful repaint boundary and should be kept
child: RenderSemanticsGestureHandler#0a954 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
gestures: long press
child: RenderPointerListener#d9fec NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
behavior: deferToChild
listeners: down
child with index 3: RenderIndexedSemantics#7cad9 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: index=3; layoutOffset=285.0
constraints: BoxConstraints(w=390.0, h=95.0)
semantic boundary
size: Size(390.0, 95.0)
index: 3
child: RenderRepaintBoundary#6e0bd NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
layer: OffsetLayer#cacc4
engine layer: OffsetEngineLayer#8785f
offset: Offset(0.0, 310.0)
size: Size(390.0, 95.0)
metrics: 83.3% useful (1 bad vs 5 good)
diagnosis: this is a useful repaint boundary and should be kept
child: RenderSemanticsGestureHandler#0f21d NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
gestures: long press
child: RenderPointerListener#90d32 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
behavior: deferToChild
listeners: down
child with index 4: RenderIndexedSemantics#98e3a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: index=4; layoutOffset=380.0
constraints: BoxConstraints(w=390.0, h=95.0)
semantic boundary
size: Size(390.0, 95.0)
index: 4
child: RenderRepaintBoundary#4b651 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
layer: OffsetLayer#4d349
engine layer: OffsetEngineLayer#3ac9d
offset: Offset(0.0, 405.0)
size: Size(390.0, 95.0)
metrics: 83.3% useful (1 bad vs 5 good)
diagnosis: this is a useful repaint boundary and should be kept
child: RenderSemanticsGestureHandler#d08c0 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
gestures: long press
child: RenderPointerListener#4d447 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
behavior: deferToChild
listeners: down
child with index 5: RenderIndexedSemantics#3c29c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: index=5; layoutOffset=475.0
constraints: BoxConstraints(w=390.0, h=95.0)
semantic boundary
size: Size(390.0, 95.0)
index: 5
child: RenderRepaintBoundary#95d2d NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
layer: OffsetLayer#0a5f6
engine layer: OffsetEngineLayer#48bb1
offset: Offset(0.0, 500.0)
size: Size(390.0, 95.0)
metrics: 83.3% useful (1 bad vs 5 good)
diagnosis: this is a useful repaint boundary and should be kept
child: RenderSemanticsGestureHandler#9d4f2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
gestures: long press
child: RenderPointerListener#41da2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
behavior: deferToChild
listeners: down
child with index 6: RenderIndexedSemantics#97f8c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: index=6; layoutOffset=570.0
constraints: BoxConstraints(w=390.0, h=95.0)
semantic boundary
size: Size(390.0, 95.0)
index: 6
child: RenderRepaintBoundary#43698 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
layer: OffsetLayer#4c73b
engine layer: OffsetEngineLayer#cf9c5
offset: Offset(0.0, 595.0)
size: Size(390.0, 95.0)
metrics: 83.3% useful (1 bad vs 5 good)
diagnosis: this is a useful repaint boundary and should be kept
child: RenderSemanticsGestureHandler#a439c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
gestures: long press
child: RenderPointerListener#c1b95 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
behavior: deferToChild
listeners: down
child with index 7: RenderIndexedSemantics#af472 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: index=7; layoutOffset=665.0
constraints: BoxConstraints(w=390.0, h=95.0)
semantic boundary
size: Size(390.0, 95.0)
index: 7
child: RenderRepaintBoundary#af250 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
layer: OffsetLayer#45ab6
engine layer: OffsetEngineLayer#f6a96
offset: Offset(0.0, 690.0)
size: Size(390.0, 95.0)
metrics: 83.3% useful (1 bad vs 5 good)
diagnosis: this is a useful repaint boundary and should be kept
child: RenderSemanticsGestureHandler#aac55 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
gestures: long press
child: RenderPointerListener#428a8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: (can use size)
constraints: BoxConstraints(w=390.0, h=95.0)
size: Size(390.0, 95.0)
behavior: deferToChild
listeners: down ════════════════════════════════════════════════════════════════════════════════
Reloaded 67 of 2009 libraries in 683ms.
Do you have an idea what happens here and why without Hot Reload everything works fine? And how to fix such an error? I tried to remove the itemExtend. Then it works and the error does not appear. But without itemExtend I have some flickering in my ListView. Looks like order changing or something else. Its very ugly. Therefore I need to itemExtend to fix it.
If you need a better view of the code context, I send you the code of the entire file. By the way. There are still no gos like handling data inside a build method. Its an old project and I'm on the way to rewrite it entirely. But this things are not responsible for the error. It is interesting, that the error does not appear when I remove "itemExtend". How is that possible?
The entire code:
class GuestGuestbookContent extends StatelessWidget {
GuestGuestbookContent({
Key key,
}) : super(key: key);
GuestbooksController get guestbooksController => Get.find();
EntriesController get entriesController => Get.find();
UsersController get usersController => Get.find();
#override
Widget build(BuildContext context) {
return SliverToBoxAdapter(
child: Container(
padding: EdgeInsets.only(bottom: 50, top: 50),
alignment: Alignment.center,
child: entriesController.obx((state) {
return Column(
children: [
Container(
child: MixinBuilder(
initState: (_) async {
await entriesController.checkGuestbookForUserEntries(
guestbooksController.currentGuestbook.value.id);
},
builder: (_) {
if (entriesController.hasUserEntry.value == true) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding:
const EdgeInsets.only(left: 25.0, right: 25),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("your_entries",
style: Get.theme.textTheme.headline4)
.tr(),
IconButton(
alignment: Alignment.centerRight,
padding: EdgeInsets.all(0),
icon: Icon(
entriesController.showOwnEntries.value ==
false
? CupertinoIcons.arrow_down
: CupertinoIcons.arrow_up,
color: Get.theme.colorScheme.primary,
size: 20,
),
onPressed: () => entriesController
.showOwnEntries.value =
!entriesController.showOwnEntries.value)
],
),
),
entriesController.showOwnEntries.value == true
? _buildUserEntries()
: Container(),
SizedBox(height: 15),
],
);
} else {
bool isOpen = true;
DateTime startDate;
if (guestbooksController
.currentGuestbook.value.startDate !=
null) {
startDate = DateTime.parse(guestbooksController
.currentGuestbook.value.startDate);
isOpen = startDate.isAtSameMomentAs(DateTime.now()) ||
startDate.isBefore(DateTime.now());
}
if (isOpen) {
return _buildAddEntryButton();
} else {
return Container(
child: Column(
children: [
Image.asset("assets/animations/clock.gif",
width:
context.isTablet ? 400 : Get.width / 2),
SizedBox(
height: 15,
),
Text("guestbook_opens_at").tr(),
SizedBox(height: 5),
Text(
DateFormat(tr("date_format"))
.format(startDate),
style: Get.theme.textTheme.headline1)
],
),
);
}
}
},
),
),
// Alle Einträge
guestbooksController.currentGuestbook.value.isPublic == true ||
_isModerator() == true
? _buildAllEntriesContainer()
: Container(),
],
);
}, onLoading: LoadingSpinner()),
),
);
}
bool _isModerator() {
return usersController.userIsModerator(
userID: usersController.ownUser.value.uid,
guestbook: guestbooksController.currentGuestbook.value);
}
CupertinoButton _buildAddEntryButton() {
return CupertinoButton(
child: Column(
children: [
Icon(
Icons.add,
size: 50,
),
Text(
"create_entry",
style:
TextStyle(color: Get.theme.colorScheme.primary, fontSize: 20),
).tr(),
SizedBox(height: 25),
],
),
onPressed: () => Get.toNamed("writeNewEntry"));
}
ListView _buildUserEntries() {
return ListView.builder(
shrinkWrap: true,
padding: EdgeInsets.only(top: 0, bottom: 10),
physics: ClampingScrollPhysics(),
itemCount: entriesController.userEntriesData.length,
itemBuilder: (BuildContext context, int index) {
final Entry entry = entriesController.userEntriesData[index];
// Manage description
String entryContent = "";
List entryContentInput = [];
if (entry.content != null) {
final parsedContent = jsonDecode(entry.content);
if (parsedContent != null) {
for (int i = 0; i < parsedContent.length; i++) {
entryContentInput.add(parsedContent[i]["insert"]);
}
entryContent = entryContentInput.join("").toString();
}
}
return GestureDetector(
onLongPress: () {
_userEntryOptions(entry);
},
child: GuestListTile(
entry: entry,
description: entryContent != null && entryContent.isNotEmpty
? entryContent
: tr("no_text_added"),
owner: entry.owner,
hasImages: entry.images != null && entry.images.isNotEmpty,
hasVideos: entry.videos != null && entry.videos.isNotEmpty,
hasPainting:
entry.paintingImage != null && entry.paintingImage.isNotEmpty,
),
);
});
}
Container _buildAllEntriesContainer() {
return Container(
child: MixinBuilder(
builder: (EntriesController controller) {
if (controller.guestbookEntriesWithoutOwn.length > 0) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(left: 25.0, right: 25),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("entries_from_all_guests",
style: Get.theme.textTheme.headline4)
.tr(),
CircleAvatar(
radius: 10,
backgroundColor: Get.theme.colorScheme.primary,
child: Text(
controller.guestbookEntriesWithoutOwn.length
.toString(),
style: TextStyle(
fontSize: 10,
color: Get.theme.colorScheme.background)),
)
],
),
),
_buildAllEntries(controller.guestbookEntriesWithoutOwn),
],
);
} else {
return Container();
}
},
),
);
}
Widget _buildAllEntries(List<Entry> entries) {
if (entries != null && entries.isNotEmpty) {
return ListView.builder(
padding: EdgeInsets.only(top: 10, bottom: 10),
physics: ClampingScrollPhysics(),
shrinkWrap: true,
itemExtent: 95,
itemCount: entries.length,
itemBuilder: (BuildContext context, int index) {
Entry entry;
if (entries.length > 0) {
entry = entries[index];
// Manage description
String entryContent = "";
List entryContentInput = [];
if (entry.content != null) {
final parsedContent = jsonDecode(entry.content);
if (parsedContent != null) {
for (int i = 0; i < parsedContent.length; i++) {
entryContentInput.add(parsedContent[i]["insert"]);
}
entryContent = entryContentInput.join("").toString();
}
}
return GestureDetector(
onLongPress: () async {
final userID = await getUid();
if (usersController.userIsModerator(
userID: userID,
guestbook:
guestbooksController.currentGuestbook.value) ==
true) {
_userEntryOptions(entry);
}
},
child: GuestListTile(
entry: entry,
description: entryContent != null &&
entryContent.isNotEmpty &&
entryContent != "\n"
? entryContent
: tr("no_content"),
owner: entry.owner,
hasImages: entry.images != null && entry.images.isNotEmpty,
hasVideos: entry.videos != null && entry.videos.isNotEmpty,
hasPainting: entry.paintingImage != null &&
entry.paintingImage.isNotEmpty,
),
);
} else {
return Container();
}
});
} else {
return Container();
}
}
void _userEntryOptions(Entry entry) {
Get.bottomSheet(CupertinoActionSheet(
actions: [
CupertinoActionSheetAction(
onPressed: () {
Get.back();
_deleteUserEntryConfirmation(entry);
},
child: Text("delete_this_entry").tr(),
isDestructiveAction: true,
)
],
));
}
void _deleteUserEntryConfirmation(Entry entry) {
Get.dialog(CupertinoAlertDialog(
title: Text("delete_my_entry_desc").tr(),
actions: [
CupertinoDialogAction(
child: Text("yes_delete_entry").tr(),
isDestructiveAction: true,
onPressed: () {
Get.back();
_deleteUserEntry(entry);
},
),
CupertinoDialogAction(
child: Text("no_not_delete_entry").tr(),
onPressed: () {
Get.back();
},
)
],
));
}
void _deleteUserEntry(Entry entry) async {
await entriesController.deleteEntireUserEntry(entry);
await MySnackbar()
.createSnackbar(message: tr("entry_deleted_successfully"), seconds: 2);
}
}
By the way: I'm using the getx package for state management. This is the reason because I can go with a Stateless widget.
Rebuild the app using the command flutter clean
You didn't provide a lot of code, but maybe you should try wrapping your ListView.builder with Expanded widget? :)
Then your code would become something like:
return Expanded(
child: ListView.builder(
padding: EdgeInsets.only(top: 25, bottom: 20),
shrinkWrap: true,
itemExtent: 95,
physics: ClampingScrollPhysics(),
itemCount: entriesController.guestbookEntries.length,
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onLongPress: () async {
// Some stuff
},
child: GuestListTile()
);
},
));
The Expanded widget consumes available space which comes in handy if used in a Column or a Row -- you can read more about it # Flutter - Expanded.
It seems your guestbookEntries from entriesController variable is null when you do hot reload. Check the value if null show some loading indicator, then show the ListView when it's not null.
Your widget doesn't show anything much, because there is no controller class code.
Use this : Your Problem will be solved
return Container(
height: double.maxfinite;
child:SingleChildScrollView(
child: ListView.builder(
padding: EdgeInsets.only(top: 25, bottom: 20),
shrinkWrap: true,
itemExtent: 95,
physics: NeverScrollableScrollPhysics(),
itemCount: entriesController.guestbookEntries.length,
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onLongPress: () async {
// Some stuff
},
child: GuestListTile()
);
},
)));
I'm having a problem which i have been trying to solve for the last 3 hours but it's pointless.
Now get to the point, I'm making an custom CupertinoDialog, everything looks good to me. Idk why is this happening. I've try multiple method on Stackoverflow but it's pointless. I hope someone can save me from this bug.
======== Exception caught by rendering library =====================================================
The following assertion was thrown during performLayout():
RenderBox was not laid out: RenderIntrinsicWidth#b0789 relayoutBoundary=up5 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1930 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=2_bug.md
The relevant error-causing widget was:
SimpleDialog file:///D:/FlutterProject/airchecker/lib/main.dart:50:29
When the exception was thrown, this was the stack:
#2 RenderBox.size (package:flutter/src/rendering/box.dart:1930:12)
#3 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:117:21)
#4 RenderObject.layout (package:flutter/src/rendering/object.dart:1779:7)
#5 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14)
#6 RenderCustomPaint.performLayout (package:flutter/src/rendering/custom_paint.dart:545:11)
...
The following RenderObject was being processed when the exception was fired: _RenderInkFeatures#383cc relayoutBoundary=up4 NEEDS-PAINT
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(280.0<=w<=331.4, 0.0<=h<=561.6)
... size: MISSING
RenderObject: _RenderInkFeatures#383cc relayoutBoundary=up4 NEEDS-PAINT
needs compositing
parentData: <none> (can use size)
constraints: BoxConstraints(280.0<=w<=331.4, 0.0<=h<=561.6)
size: MISSING
... child: RenderIntrinsicWidth#b0789 relayoutBoundary=up5 NEEDS-PAINT
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(280.0<=w<=331.4, 0.0<=h<=561.6)
... size: MISSING
... stepWidth: 56.0
... stepHeight: null
... child: RenderConstrainedBox#9892a NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: <none>
... constraints: MISSING
... size: MISSING
... additionalConstraints: BoxConstraints(280.0<=w<=Infinity, 0.0<=h<=Infinity)
... child: RenderFlex#bca83 NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: <none>
... constraints: MISSING
... size: MISSING
... direction: vertical
... mainAxisAlignment: start
... mainAxisSize: min
... crossAxisAlignment: stretch
... verticalDirection: down
... child 1: RenderPadding#27dc0 NEEDS-LAYOUT NEEDS-PAINT
... parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
... constraints: MISSING
... size: MISSING
... padding: EdgeInsets(24.0, 24.0, 24.0, 0.0)
... textDirection: ltr
... child 2: RenderRepaintBoundary#dda4c NEEDS-LAYOUT NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.loose
... constraints: MISSING
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
====================================================================================================
Here's my code:
void showAlertDialog(BuildContext context, String title, String content) {
showCupertinoDialog(
context: context,
builder: (builder) => SimpleDialog(
title: title.text.semiBold.make().centered(),
children: [
content.text.make().centered().expand(),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
width: 100,
child: OutlinedButton(
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4)),
side: BorderSide(color: Colors.red, width: 1.0), // HERE
),
side:
BorderSide(color: Colors.red, width: 1.0)), // AND HERE
onPressed: () {},
child: 'Cancel'.text.color(Colors.red).make(),
),
),
Container(
width: 100,
child: TextButton(
onPressed: () {},
child: 'OK'.text.white.make().px(15),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.red),
),
),
),
],
),
],
),
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(50.0),
child: GestureDetector(
onTap: (){
showAlertDialog(context, "tit", "Content");
},
child: ClipPath(
clipper: MyClip(),
child: Container(
width: 200,
height: 300,
color: Colors.lightGreenAccent,
),
),
),
),
);
}
}
#Nobody,
As pskink mentioned, try to use Text(content), I just replaced
title: title.text.semiBold.make().centered()
for
title: Text(title)
and
content.text.make().centered().expand()
for
Row(mainAxisAlignment: MainAxisAlignment.center,
children: [Text(content)],)
and it works, I've never used velocity_x, but it seems that's the problem
I am new to flutter, trying to add a listview to one of my route that when clicked, take me to a new route specific to each of the list card.
here's my route code:
class SecondRoute extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
title: Text('What you are in the mood for?'),
backgroundColor: Colors.lightGreen[400],
centerTitle: true,
),
body: Column(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
Text('Select a genre:',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 40,
color: Colors.black,
fontWeight: FontWeight.bold)),
//if I add ListView(...) here, I get errors
]),
);
}
}
The problem I receive is:
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
Tried to paint a RenderObject reentrantly.
The relevant error-causing widget was:
Scaffold file:///Users/User/AndroidStudioProjects/choose_a_game_for_me/lib/main.dart:102:12
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during paint():
Tried to paint a RenderObject reentrantly.
The following RenderObject was already being painted when it was painted again: RenderFlex#aafa2 relayoutBoundary=up5
... needs compositing
... parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body (can use size)
... constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=603.4)
... size: MISSING
... direction: vertical
... mainAxisAlignment: spaceEvenly
... mainAxisSize: max
... crossAxisAlignment: center
... verticalDirection: down
Since this typically indicates an infinite recursion, it is disallowed.
The relevant error-causing widget was:
Scaffold file:///Users/Users/AndroidStudioProjects/choose_a_game_for_me/lib/main.dart:102:12
When the exception was thrown, this was the stack:
#0 RenderObject._paintWithContext.<anonymous closure> (package:flutter/src/rendering/object.dart:2208:9)
#1 RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2221:6)
#2 PaintingContext.paintChild (package:flutter/src/rendering/object.dart:184:13)
#3 RenderBoxContainerDefaultsMixin.defaultPaint (package:flutter/src/rendering/box.dart:2515:15)
#4 RenderCustomMultiChildLayoutBox.paint (package:flutter/src/rendering/custom_layout.dart:404:5)
...
The following RenderObject was being processed when the exception was fired: RenderCustomMultiChildLayoutBox#8a3f0 relayoutBoundary=up4
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=683.4)
... size: Size(411.4, 683.4)
RenderObject: RenderCustomMultiChildLayoutBox#8a3f0 relayoutBoundary=up4
needs compositing
parentData: <none> (can use size)
constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=683.4)
size: Size(411.4, 683.4)
... child 1: RenderFlex#aafa2 relayoutBoundary=up5
... needs compositing
... parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body (can use size)
... constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=603.4)
... size: MISSING
... direction: vertical
... mainAxisAlignment: spaceEvenly
... mainAxisSize: max
... crossAxisAlignment: center
... verticalDirection: down
... child 1: RenderParagraph#e94b7 relayoutBoundary=up6 NEEDS-PAINT
... parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
... constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=Infinity)
... size: Size(343.0, 47.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)).merge(unknown)
... inherit: false
... color: Color(0xff000000)
... family: Roboto
... size: 40.0
... weight: 700
... baseline: alphabetic
... decoration: TextDecoration.none
... "Select a genre:"
... child 2: RenderRepaintBoundary#02cc2 relayoutBoundary=up6 NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
... constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=Infinity)
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
... child: RenderCustomPaint#cd675 relayoutBoundary=up7 NEEDS-PAINT
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=Infinity)
... size: MISSING
... child: RenderRepaintBoundary#1d1e0 relayoutBoundary=up8 NEEDS-PAINT
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=Infinity)
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
... child 2: RenderConstrainedBox#4a2e7 relayoutBoundary=up5 NEEDS-PAINT
... needs compositing
... parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.appBar (can use size)
... constraints: BoxConstraints(w=411.4, 0.0<=h<=683.4)
... size: Size(411.4, 80.0)
... additionalConstraints: BoxConstraints(0.0<=w<=Infinity, 0.0<=h<=80.0)
... child: RenderSemanticsAnnotations#997db relayoutBoundary=up6 NEEDS-PAINT
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(w=411.4, 0.0<=h<=80.0)
... semantic boundary
... size: Size(411.4, 80.0)
... child: RenderAnnotatedRegion<SystemUiOverlayStyle>#e6930 relayoutBoundary=up7 NEEDS-PAINT
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(w=411.4, 0.0<=h<=80.0)
... size: Size(411.4, 80.0)
... child: RenderPhysicalModel#35a1a relayoutBoundary=up8 NEEDS-PAINT
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(w=411.4, 0.0<=h<=80.0)
... size: Size(411.4, 80.0)
... elevation: 4.0
... color: Color(0xff9ccc65)
... shadowColor: Color(0xff9ccc65)
... shape: BoxShape.rectangle
... borderRadius: BorderRadius.zero
... child 3: RenderStack#16a71 NEEDS-LAYOUT NEEDS-PAINT
... parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.floatingActionButton
... constraints: MISSING
... size: MISSING
... alignment: centerRight
... textDirection: ltr
... fit: loose
... overflow: clip
... child 1: RenderTransform#68acc 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#9de5f 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
════════════════════════════════════════════════════════════════════════════════════════════════════
I tried making ListView its own class and then added that to my SecondRoute's body, but same error shows up.
line 102 is the Scaffold in class SecondRoute.
Thanks for your help
If you try to add a ListView inside of a Column you must wrap it inside an expanded like the following:
Column(
children: [
...
Expanded(
child: ListView(...),
),
]
)
This is because the ListView will try to take all available space, but which will cause a RenderFlex overflow. The Expanded widget essentially tells the ListView to take all of the available space and scroll down to the rest that can't fit inside of the Column.