This is the error that I got
> Another exception was thrown: BoxConstraints forces an infinite width.
>
> Another exception was thrown: RenderBox was not laid out:
> _RenderListTile#bfb7d relayoutBoundary=up18 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> RenderPadding#9ad87 relayoutBoundary=up17 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> RenderPadding#24132 relayoutBoundary=up16 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> RenderSemanticsAnnotations#09519 relayoutBoundary=up15 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> RenderPointerListener#6e77f relayoutBoundary=up14 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> RenderSemanticsAnnotations#39ab6 relayoutBoundary=up13 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> RenderMouseRegion#77c75 relayoutBoundary=up12 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> RenderSemanticsAnnotations#39f2d relayoutBoundary=up11 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> RenderSemanticsAnnotations#e877e relayoutBoundary=up10 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> _RenderInkFeatures#8f433 relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> RenderCustomPaint#ded6d relayoutBoundary=up8 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> RenderPhysicalShape#9e5aa relayoutBoundary=up7 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> RenderPadding#ef085 relayoutBoundary=up6 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> RenderSemanticsAnnotations#e3df0 relayoutBoundary=up5 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown: RenderBox was not laid out:
> RenderRepaintBoundary#88219 relayoutBoundary=up4 NEEDS-PAINT
> NEEDS-COMPOSITING-BITS-UPDATE
>
> Another exception was thrown:
> 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed
> assertion: line 544 pos 12: 'child.hasSize': is not true.
And this is the code :
return Container(
height: size.height,
width: size.width,
child: Stack(alignment: Alignment.center, children: <Widget>[
Container(
width: 300,
height: 100,
margin: EdgeInsets.only(bottom: 490, right: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(19),
topRight: Radius.circular(19),
bottomLeft: Radius.circular(19),
bottomRight: Radius.circular(19)),
boxShadow: [
BoxShadow(
color: Color.fromARGB(255, 185, 203, 203).withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset: Offset(0, 3), // changes position of shadow
),
],
),
),
Container(
margin: EdgeInsets.only(bottom: 550, right: 140),
child: Text(
"Filter by Patient",
style: TextStyle(color: Colors.teal, fontSize: 17),
),
),
Container(
//list image profile
width: 200,
height: 80,
margin: EdgeInsets.only(bottom: 650, right: 140),
child: StreamBuilder<QuerySnapshot>(
stream: db.collection("patient").snapshots(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
List value = snapshot.data!.docs;
if (snapshot.data == null) {
return Container(child: Center(child: Text("Loading...")));
} else {
return ListView.builder(
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
print(snapshot.data!.docs);
return Card(
child: ListTile(
leading: CircleAvatar(
backgroundImage:
NetworkImage(value[index]['imageURL']),
),
));
});
}
},
),
)
]));
The issue rise using ListTile inside horizontal list, on listView parent you are using width:200 and it can be set on ListTile width. You can wrap Card or ListTile with a sized widget by providing width, and it will solve the issue.
itemBuilder: (context, index) {
return SizedBox(
width: 200,
child: Card(
child: ListTile(
I will encourage you to check LayoutBuilder for using sizes and ui/layout
Check this video to learn more about Unbounded height/ width.
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 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 have this page I'm trying to design in XD :
and when I ran the application to render in , the bottom side with content containing the tab did not display and I get these errors but I don't know what they exactly mean :
I/flutter (22774): The following RenderObject was being processed when the exception was fired: RenderViewport#cc2f4 NEEDS-LAYOUT
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE: I/flutter (22774): needs
compositing I/flutter (22774): creator: Viewport ←
IgnorePointer-[GlobalKey#1f28b] ← Semantics ← _PointerListener ←
Listener ← I/flutter (22774): _GestureSemantics ←
RawGestureDetector-[LabeledGlobalKey#0f747] ←
I/flutter (22774): _PointerListener ← Listener ← _ScrollableScope
← _ScrollSemantics-[GlobalKey#03bee] ← I/flutter (22774):
RepaintBoundary ← ⋯ I/flutter (22774): parentData: (can use
size) I/flutter (22774): constraints: BoxConstraints(0.0<=w<=360.0,
0.0<=h<=Infinity) I/flutter (22774): size: MISSING I/flutter (22774): axisDirection: left I/flutter (22774):
crossAxisDirection: down I/flutter (22774): offset:
_PagePosition#dd846(offset: null, range: null..null, viewport: null, ScrollableState, I/flutter (22774): _ForceImplicitScrollPhysics ->
PageScrollPhysics -> PageScrollPhysics -> ClampingScrollPhysics ->
I/flutter (22774): ClampingScrollPhysics ->
RangeMaintainingScrollPhysics, IdleScrollActivity#2467d, I/flutter
(22774): ScrollDirection.idle) I/flutter (22774): anchor: 0.0
I/flutter (22774): This RenderObject had the following descendants
(showing up to depth 5): I/flutter (22774): center child:
_RenderSliverFractionalPadding#2da9f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): child:
RenderSliverFillViewport#a0715 NEEDS-LAYOUT NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774):
════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (22774): Another exception was thrown: RenderBox was not
laid out: RenderViewport#cc2f4 NEEDS-LAYOUT NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATEI/flutter (22774): Another exception was
thrown: RenderBox was not laid out: RenderViewport#cc2f4 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another exception was
thrown: RenderBox was not laid out: RenderIgnorePointer#d6f43
relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter (22774): Another exception was thrown: RenderBox was not
laid out: RenderSemanticsAnnotations#55aed relayoutBoundary=up9
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another
exception was thrown: RenderBox was not laid out:
RenderPointerListener#891d5 relayoutBoundary=up8 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another exception was
thrown: RenderBox was not laid out:
RenderSemanticsGestureHandler#40649 relayoutBoundary=up7 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another exception was
thrown: RenderBox was not laid out: RenderPointerListener#0e00a
relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter (22774): Another exception was thrown: RenderBox was not
laid out: _RenderScrollSemantics#61006 relayoutBoundary=up5
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another
exception was thrown: RenderBox was not laid out:
RenderRepaintBoundary#782fb relayoutBoundary=up4 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another exception was
thrown: RenderBox was not laid out: RenderCustomPaint#3bc15
relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter (22774): Another exception was thrown: RenderBox was not
laid out: RenderRepaintBoundary#e1816 relayoutBoundary=up2 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE I/flutter (22774): Another exception was
thrown: RenderBox was not laid out: RenderFlex#20580
relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter (22774): Another exception was thrown: NoSuchMethodError:
The method '>' was called on null.
my code is : paybills.dart file (main widget displaying both tabs)
import 'package:flutter/material.dart';
import '../../constans/constants.dart';
import 'first_tab.dart';
import 'second_tab.dart';
class PayBills extends StatefulWidget {
#override
_PayBillsState createState() => _PayBillsState();
}
class _PayBillsState extends State<PayBills>
with SingleTickerProviderStateMixin {
TabController _controller;
#override
void initState() {
super.initState();
_controller = TabController(vsync: this, length: 2);
}
#override
void dispose() {
_controller.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
centerTitle: true,
elevation: 0,
title: Text(
'تسديد فاتورة',
style: TextStyle(
color: leaderLogo,
fontSize: 24,
fontFamily: 'Calibri',
),
),
),
body: Container(
child: Column(children: [
Container(
height: 93,
width: 378,
child: Align(
alignment: Alignment.topCenter,
child: TabBar(
controller: _controller,
tabs: [
Tab(
child: Center(
child: Text(
'فواتير مستحقة',
style: TextStyle(
color: Colors.black,
),
),
),
),
Tab(
child: Center(
child: Text(
'فواتير مدفوعة',
style: TextStyle(
color: Colors.black,
),
),
),
),
],
),
),
),
TabBarView(
controller: _controller,
children: [
PayBillsList(),
SecondTab(),
],
),
]),
),
);
}
}
and this is firsttab.dart file displaying the first tab :
import 'package:flutter/material.dart';
import '../../constans/constants.dart';
class BillDetails extends StatelessWidget {
final String billName;
final String billImage;
final String billDate;
const BillDetails({Key key, this.billName, this.billImage, this.billDate})
: super(key: key);
#override
Widget build(BuildContext context) {
return Card(
child: ListTile(
leading: Container(
width: 40,
height: 40,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(billImage),
fit: BoxFit.fill,
)),
),
title: Text(
billName,
style: TextStyle(
fontFamily: 'Calibri',
fontSize: 16,
color: Colors.black,
),
),
subtitle: Text(
billDate,
style: TextStyle(
fontFamily: 'Calibri',
fontSize: 12,
color: Colors.black,
),
),
trailing: PayButton(),
),
);
}
}
class PayBillsList extends StatelessWidget {
final List<BillDetails> billsList = [
BillDetails(
billName: 'فاتورة كهرباء',
billImage: 'assets/images/electricity.png',
billDate: '30 / 4 / 2020',
),
BillDetails(
billName: 'فاتورة مياه',
billImage: 'assets/images/water.png',
billDate: '30 / 4 / 2020',
),
];
#override
Widget build(BuildContext context) {
return Container(
width: 378,
height: 93,
decoration: BoxDecoration(
border: Border.all(
width: 1,
color: Colors.grey,
),
shape: BoxShape.circle,
),
child: ListView.builder(
itemBuilder: (context, index) {
return BillDetails(
billName: billsList.elementAt(index).billName,
billImage: billsList.elementAt(index).billImage,
billDate: billsList.elementAt(index).billDate,
);
},
shrinkWrap: true,
itemCount: billsList.length,
scrollDirection: Axis.vertical,
),
);
}
}
class PayButton extends StatelessWidget {
const PayButton({
Key key,
}) : super(key: key);
#override
Widget build(BuildContext context) {
return ButtonTheme(
minWidth: 80,
height: 40,
child: RaisedButton(
onPressed: () {},
color: raisedButtonColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: Center(
child: Text(
//Login button text properties
'دفع',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: 'Calibri',
)),
),
),
);
}
}
This is the error i am getting
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderViewport#a644c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
The relevant error-causing widget was
Carousel
lib\Screen\test.dart:63
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderViewport#a644c NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
The relevant error-causing widget was
Carousel
lib\Screen\test.dart:63
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderIgnorePointer#a9a36 relayoutBoundary=up14 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
This is my code
body: ListView(
// scrollDirection: Axis.vertical,
children: <Widget>[
Padding(
padding: EdgeInsets.only(
left: SizeConfig.safeBlockHorizontal * 5,
top: SizeConfig.safeBlockHorizontal * 5,
right: SizeConfig.safeBlockHorizontal * 5),
child: Material(
borderRadius: BorderRadius.circular(24.0),
child: SizedBox(
width: SizeConfig.safeBlockHorizontal * 80,
height: SizeConfig.safeBlockHorizontal * 100,
child: StreamBuilder<QuerySnapshot>(
stream: Firestore.instance.collection('About').snapshots(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data.documents.length,
itemBuilder: (BuildContext context, int index) {
_listOfImages = [];
for (int i = 0;
i < snapshot.data.documents[index].data['image'].length;
i++
)
{
_listOfImages.add(NetworkImage(snapshot
.data.documents[index].data['image'][i]));
}
return Carousel(
// boxFit: BoxFit.contain,
dotBgColor: Colors.transparent,
dotIncreasedColor: Colors.grey,
dotSize: 6.0,
images: _listOfImages,
);
Trying to make a Flutter CupertinoPicker work on Flutter 1.7. No fancy stuff, just the basic code inside a Scaffold body...
Only using the mandatory elements...tried even sample code of other people, nothing works.
CupertinoPicker(
itemExtent: 30.0,
onSelectedItemChanged: (int idx) {
setState(() {
_prayer.rebuild((b) =>
b..category = listOfStrings[idx]);
});
},
children: List<Widget>.generate(
listOfStrings.length,
(int i) {
return Text('Dummy Text');
},
),
)
flutter: Another exception was thrown: RenderFlex children have non-zero flex but incoming height constraints are unbounded.
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#fdf27 relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#052f5 relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderBox was not laid out: RenderPadding#0d6c9 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: Another exception was thrown: RenderFlex children have non-zero flex but incoming height constraints are unbounded.
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#fdf27 relayoutBoundary=up3 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#052f5 relayoutBoundary=up2 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPadding#0d6c9 relayoutBoundary=up1 NEEDS-PAINT
flutter: Another exception was thrown: NoSuchMethodError: The method '>' was called on null.
Android Picker works...
Is there a need that the parent Widget should be Cupertino based or something ?
Expanded(
child:
CupertinoPicker(
backgroundColor: Colors.white,
onSelectedItemChanged: (index) {
},
itemExtent: 50.0,
children:new List<Widget>.generate(
companyList.length, (int index) {
return new Center(
child: new Text(
"${companyList[index]}",
style: TextStyle(fontSize: 16,fontFamily:
'HelveticaRegular'),),
);})
))
You can fix it in two ways. As the answer is in the logcat RenderFlex.
We need to provide the height either using Container
Container(
height: 200.0,
child: CupertinoPicker(
itemExtent: 30.0,
onSelectedItemChanged: (int idx) {
setState(() {
_prayer.rebuild((b) =>
b..category = listOfStrings[idx]);
});
},
children: List<Widget>.generate(
listOfStrings.length,
(int i) {
return Text('Dummy Text');
},
),
)
)
Or
Using the Expanded in case of Row and Column
Expanded(
child: CupertinoPicker(
itemExtent: 30.0,
onSelectedItemChanged: (int idx) {
setState(() {
_prayer.rebuild((b) =>
b..category = listOfStrings[idx]);
});
},
children: List<Widget>.generate(
listOfStrings.length,
(int i) {
return Text('Dummy Text');
},
),
)
)