error occurs rendering and expanded - column widgets flutter - flutter

I'm getting a lot of errors regarding the rendering and I think its the way I'm using column and expanded and scroll view but i cant figure out how to fix it, I've tried different solutions but it still produces different errors
(elided 6 frames from class _AssertionError, class
_RawReceivePortImpl, class _Timer, and dart:async-patch) The following RenderObject was being processed when the exception was fired:
RenderFlex#357da relayoutBoundary=up12 NEEDS-LAYOUT NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE RenderObject: RenderFlex#357da
relayoutBoundary=up12 NEEDS-LAYOUT NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
child 1: RenderPositionedBox#2911a relayoutBoundary=up13 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<=392.7, 0.0<=h<=Infinity)
size: Size(392.7, 36.0)
alignment: Alignment.center
textDirection: ltr
widthFactor: expand
heightFactor: expand
child: RenderSemanticsAnnotations#3a796 relayoutBoundary=up14 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(178.4, 0.0) (can use size)
constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
size: Size(36.0, 36.0)
child: RenderConstrainedBox#b58da relayoutBoundary=up15 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE parentData: <none> (can use
size)
constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
size: Size(36.0, 36.0)
additionalConstraints: BoxConstraints(36.0<=w<=Infinity, 36.0<=h<=Infinity)
child: RenderCustomPaint#a2388 relayoutBoundary=up16 NEEDS-PAINT
parentData: <none> (can use size)
constraints: BoxConstraints(36.0<=w<=392.7, 36.0<=h<=Infinity)
size: Size(36.0, 36.0)
painter: _CircularProgressIndicatorPainter#971dd()
and there is more like this
and these are the errors that i get
The relevant error-causing widget was SingleChildScrollView
The relevant error-causing widget was Container The relevant
error-causing widget was Scaffold
'package:flutter/src/rendering/object.dart': Failed assertion: line
1840 pos 12: '!_debugDoingThisLayout': is not true. The relevant
error-causing widget was Column
and its like along list of errors like these
this is chatScreen class
class ChatScreen extends StatelessWidget{
final user = FirebaseAuth.instance.currentUser!;
final String chatWithName;
final Future<bool> flag;
ChatScreen(this.chatWithName, this.flag);
Widget build(BuildContext context){
return Scaffold(
appBar: AppBar(title: Text(chatWithName), centerTitle: true,),
body: Container(
height: 200,
child: SingleChildScrollView(
child: Column(
children: <Widget>[
// Expanded(
// child: messages()),
messages(),
newMessage(flag),
],
) ,
)
),
);
}
}
this is in class newMessage
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(top: 8),
padding: EdgeInsets.all(8),
child: Row(
children: <Widget>[
Expanded(
child: TextField(
controller: _controller,
onChanged: (value) {
setState(() {
_enterdMessage = value;
});
},
)
),
IconButton(
//onPressed: _enterdMessage.trim().isEmpty ? null : _sendMessage,
onPressed: (){
if(_enterdMessage.trim().isEmpty == true){
return null;
}
else{
if(widget.roomExist==true){
notFirstTime();
}else{
if(widget.roomExist==false){
firstTime();
}
}
}
},
icon: Icon(Icons.send))
],
),
);
}
}
this is class messages
Widget build(BuildContext context) {
return FutureBuilder<User>(
future: Future.value(FirebaseAuth.instance.currentUser),
builder: (context, futureSnapshot){
if(futureSnapshot.connectionState == ConnectionState.waiting){
return Center(child: CircularProgressIndicator(),);
}
return StreamBuilder <QuerySnapshot>(
stream: firestore.collection('chats').orderBy('timeStamp', descending: true).snapshots(),
builder:(ctx, chatSnapshot){
if(chatSnapshot.connectionState == ConnectionState.waiting){
return Center(child: CircularProgressIndicator(),);
}
final chatdocs = chatSnapshot.data!.docs;
//i think here is where we check if they have the same roomid or not
return ListView.builder(
shrinkWrap: true,
reverse: true,
itemCount: chatdocs.length,
itemBuilder: (ctx, index) => messageBubble(
chatdocs[index]['text'],
chatdocs[index]['userId'] == futureSnapshot.data!.uid, //this is the error- udemy 335 minute 7:26
//chatdocs[index]['username'],
),
);
}
);
} );
}
}

You dont have to use multiple scrollable widget for this case. the parent widget(SingleChildScroll) already hadling the scroll event. You can return column instead of ListView widget from streamBuilder. A better option will be using CustomChildScrollView.
return Column(
children: List.generate(chatdocs.length, (index) => messageBubble(
chatdocs[index]['text'],
chatdocs[index]['userId'] == futureSnapshot.data?.uid, //this is the error- udemy 335 minute 7:26
//chatdocs[index]['username'],
),),
);

Related

Exception caught by rendering library (Fitted Box Error)

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.

Flutter ListView CastError only on Hot Reload

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()
);
},
)));

Getting renderbox not laid out exception in FutureBuilder

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,
),
),
);
}
}

Problems with a ListView

I make a application in flutter.
It's simple. In the principal layout exist an stack. In the first level are a background (what its a simple gradient), and in the second lever are the "body" of the application.
In this body of application i have a column (To put one item below another). this column are divided by separate widgets. One is for the "tile", and other is for a ListView, this ListView will show information from a database, but in this moment i only create 10 items for an example.
The code is this:
//This for a homepage
#override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Stack(
children: [
Background(),
HomeBody(),
],
),
);
The background (are in another file, in the homepage are imported):
#override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
stops: [0.2, 0.8],
colors: [
Color(0xff2E305F),
Color(0xff202333),
],
)),
);
And this is the "body":
#override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
PageTitle(),
Changes(),
],
),
);
}
}
class PageTitle extends StatelessWidget {
const PageTitle({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 20),
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: 25,
),
Text(
'Biggest Title',
style: TextStyle(
color: Colors.white,
fontSize: 55.0,
fontWeight: FontWeight.bold,
),
),
SizedBox(
//height: 1,
),
Text(
'low subtitle',
style: TextStyle(
color: Colors.white,
fontSize: 14.0,
fontWeight: FontWeight.w300,
),
),
],
),
),
);
}
}
class Changes extends StatelessWidget {
const Changes({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return ListView(
children: [
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
Text('Text0'),
],
);
}
}
The error is:
═══════ Exception caught by rendering library ═════════════════════════════════
The following assertion was thrown during performResize():
Vertical viewport was given unbounded height.
Viewports expand in the scrolling direction to fill their container. In this case, a vertical viewport was given an unlimited amount of vertical space in which to expand. This situation typically happens when a scrollable widget is nested inside another scrollable widget.
If this widget is always nested in a scrollable widget there is no need to use a viewport because there will always be enough vertical space for the children. In this case, consider using a Column instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size the height of the viewport to the sum of the heights of its children.
The relevant error-causing widget was
ListView
lib/widgets/home_body_screen.dart:64
When the exception was thrown, this was the stack
#0 RenderViewport.computeDryLayout.<anonymous closure>
package:flutter/…/rendering/viewport.dart:1369
#1 RenderViewport.computeDryLayout
package:flutter/…/rendering/viewport.dart:1430
#2 RenderBox.performResize
package:flutter/…/rendering/box.dart:2332
#3 RenderObject.layout
package:flutter/…/rendering/object.dart:1758
#4 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:116
...
The following RenderObject was being processed when the exception was fired: RenderViewport#33c99 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
RenderObject: RenderViewport#33c99 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
offset: ScrollPositionWithSingleContext#b9cb0(offset: 0.0, range: null..null, viewport: null, ScrollableState, AlwaysScrollableScrollPhysics -> ClampingScrollPhysics -> RangeMaintainingScrollPhysics, IdleScrollActivity#03740, ScrollDirection.idle)
anchor: 0.0
center child: RenderSliverPadding#e0507 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: paintOffset=Offset(0.0, 0.0)
constraints: MISSING
geometry: null
padding: EdgeInsets.zero
textDirection: ltr
child: RenderSliverList#2982b NEEDS-LAYOUT NEEDS-PAINT
parentData: paintOffset=Offset(0.0, 0.0)
constraints: MISSING
geometry: null
no children current live
RenderBox was not laid out: RenderViewport#33c99 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1930 pos 12: 'hasSize'
The relevant error-causing widget was
ListView
lib/widgets/home_body_screen.dart:64
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderViewport#33c99 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1930 pos 12: 'hasSize'
The relevant error-causing widget was
ListView
lib/widgets/home_body_screen.dart:64
I'm a newest in flutter, i understand some things, but not all.
My opinion is: "this error is caused by her possition, yeah, its scrollable but he does not know where ends". Sorry if i wrong.
thanks all!
To use ListView inner SingleChildScrollView, you need to disable scrolling property of ListView.
ListView(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
primary: false,
children: []
)

RenderBox was not laid out: RenderFlex#4a60a NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

When I running the code I find this error in the DEBUG Console as the below shown error:
Restarted application in 2,804ms.
[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
[38;5;244mThe following assertion was thrown during performLayout():[39;49m
Leading widget consumes entire tile width. Please use a sized widget.
'package:flutter/src/material/list_tile.dart':
Failed assertion: line 1353 pos 7: 'tileWidth != leadingSize.width'
[38;5;248mEither the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=BUG.md
[39;49m
[38;5;244mThe relevant error-causing widget was[39;49m
[38;5;248mListTile[39;49m
[38;5;244mWhen the exception was thrown, this was the stack[39;49m
[38;5;244m#2 _RenderListTile.performLayout[39;49m
[38;5;244m#3 RenderObject.layout[39;49m
[38;5;244m#4 RenderPadding.performLayout[39;49m
[38;5;244m#5 RenderObject.layout[39;49m
[38;5;244m#6 RenderProxyBoxMixin.performLayout[39;49m
[38;5;244m...[39;49m
[38;5;244mThe following RenderObject was being processed when the exception was fired: _RenderListTile#a7a4d relayoutBoundary=up9 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
[38;5;244mRenderObject: _RenderListTile#a7a4d relayoutBoundary=up9 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
[38;5;244mparentData: offset=Offset(0.0, 0.0) (can use size)[39;49m
[38;5;244mconstraints: BoxConstraints(w=0.0, 0.0<=h<=Infinity)[39;49m
[38;5;244msize: MISSING[39;49m
[38;5;244mtitle: RenderParagraph#47706 NEEDS-LAYOUT NEEDS-PAINT[39;49m
[38;5;244mparentData: offset=Offset(0.0, 0.0)[39;49m
[38;5;244mconstraints: MISSING[39;49m
[38;5;244msize: MISSING[39;49m
[38;5;244mtextAlign: left[39;49m
[38;5;244mtextDirection: ltr[39;49m
[38;5;244msoftWrap: wrapping at box width[39;49m
[38;5;244moverflow: clip[39;49m
[38;5;244mlocale: en_US[39;49m
[38;5;244mmaxLines: unlimited[39;49m
[38;5;244mtext: TextSpan[39;49m
[38;5;244mdebugLabel: (((englishLike subhead 2014).merge(blackCupertino subtitle1)).copyWith).merge(unknown)[39;49m
[38;5;244minherit: false[39;49m
[38;5;244mcolor: MaterialColor(primary value: Color(0xff03a9f4))[39;49m
[38;5;244mfamily: WorkSans[39;49m
[38;5;244msize: 16.0[39;49m
[38;5;244mweight: 600[39;49m
[38;5;244mbaseline: alphabetic[39;49m
[38;5;244mdecoration: TextDecoration.none[39;49m
[38;5;244m"Sign Out"[39;49m
[38;5;244mtrailing: RenderSemanticsAnnotations#705a3 relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
[38;5;244mparentData: offset=Offset(0.0, 0.0) (can use size)[39;49m
[38;5;244mconstraints: BoxConstraints(w=0.0, 0.0<=h<=56.0)[39;49m
[38;5;244msize: Size(0.0, 24.0)[39;49m
[38;5;244mchild: RenderExcludeSemantics#60a3d relayoutBoundary=up11 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
[38;5;244mparentData: <none> (can use size)[39;49m
[38;5;244mconstraints: BoxConstraints(w=0.0, 0.0<=h<=56.0)[39;49m
[38;5;244msize: Size(0.0, 24.0)[39;49m
[38;5;244mexcluding: true[39;49m
[38;5;244mchild: RenderConstrainedBox#bc3b1 relayoutBoundary=up12 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
[38;5;244mparentData: <none> (can use size)[39;49m
[38;5;244mconstraints: BoxConstraints(w=0.0, 0.0<=h<=56.0)[39;49m
[38;5;244msize: Size(0.0, 24.0)[39;49m
[38;5;244madditionalConstraints: BoxConstraints(w=24.0, h=24.0)[39;49m
[38;5;244mchild: RenderPositionedBox#c7d80 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE[39;49m
[38;5;244mparentData: <none> (can use size)[39;49m
[38;5;244mconstraints: BoxConstraints(w=0.0, h=24.0)[39;49m
[38;5;244msize: Size(0.0, 24.0)[39;49m
[38;5;244malignment: center[39;49m
[38;5;244mtextDirection: ltr[39;49m
[38;5;244mwidthFactor: expand[39;49m
[38;5;244mheightFactor: expand[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m
[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: _RenderListTile#a7a4d relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
[38;5;248mListTile[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m
[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderPadding#0b562 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
[38;5;248mListTile[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m
[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderSemanticsAnnotations#7c546 relayoutBoundary=up7 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
[38;5;248mListTile[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m
[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderPointerListener#6507d relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
[38;5;248mListTile[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m
[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderSemanticsGestureHandler#d89dc relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
[38;5;248mListTile[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m
[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderMouseRegion#b5666 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
[38;5;248mListTile[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m
[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderSemanticsAnnotations#ace43 relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
[38;5;248mColumn[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m
[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderFlex#4e86c relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
[38;5;248mContainer[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m
[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: _RenderColoredBox#3fe26 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
[38;5;248mColumn[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m
[38;5;248m════════ Exception caught by rendering library ═════════════════════════════════[39;49m
RenderBox was not laid out: RenderFlex#48686 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
[38;5;244mThe relevant error-causing widget was[39;49m
[38;5;248mScaffold[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m
and this is my full code:
import 'package:flutter/rendering.dart';
import '../providers/properties.dart';
import '../providers/cities.dart';
import '../providers/property.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../widgets/properties_grid.dart';
import '../app_theme.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({Key key}) : super(key: key);
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
int currentTab = 0;
ScrollController _scrollController = ScrollController();
bool _showBottomBar = true;
_scrollListener() {
if (_scrollController.position.userScrollDirection ==
ScrollDirection.reverse) {
setState(() {
_showBottomBar = false;
});
} else if (_scrollController.position.userScrollDirection ==
ScrollDirection.forward) {
setState(() {
_showBottomBar = true;
});
}
}
var _showOnlyFavorites = false;
AnimationController animationController;
bool multiple = true;
#override
void initState() {
animationController = AnimationController(
duration: const Duration(milliseconds: 2000), vsync: this);
_scrollController.addListener(_scrollListener);
super.initState();
}
Future<bool> getData() async {
await Future<dynamic>.delayed(const Duration(milliseconds: 0));
return true;
}
#override
void dispose() {
animationController.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
// final properties = Provider.of<Properties>(context, listen: false);
return Scaffold(
resizeToAvoidBottomPadding: false,
extendBody: true,
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {},
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: AnimatedContainer(
duration: Duration(milliseconds: 500),
child: _showBottomBar
? BottomAppBar(
elevation: 0,
shape: CircularNotchedRectangle(),
notchMargin: 10,
child: Container(
height: 60,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
MaterialButton(
padding: EdgeInsets.all(0),
minWidth: 155,
onPressed: () {
setState(() {
// currentScreen =
// Chat(); // if user taps on this dashboard tab will be active
currentTab = 1;
});
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.home,
color: currentTab == 1
? Colors.blue
: Colors.grey,
),
Text(
'Home',
style: TextStyle(
color: currentTab == 1
? Colors.blue
: Colors.grey,
),
),
],
),
)
],
),
// Right Tab bar icons
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
MaterialButton(
padding: EdgeInsets.all(0),
minWidth: 60,
onPressed: () {
setState(() {
// currentScreen =
// Settings(); // if user taps on this dashboard tab will be active
currentTab = 3;
});
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.view_list,
color: currentTab == 3
? Colors.blue
: Colors.grey,
),
Text(
'Property List',
style: TextStyle(
color: currentTab == 3
? Colors.blue
: Colors.grey,
),
),
],
),
),
MaterialButton(
padding: EdgeInsets.all(0),
minWidth: 77,
onPressed: () {
setState(() {
// currentScreen =
// Settings(); // if user taps on this dashboard tab will be active
currentTab = 4;
});
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.location_searching,
color: currentTab == 4
? Colors.blue
: Colors.grey,
),
Text(
'Map',
style: TextStyle(
color: currentTab == 4
? Colors.blue
: Colors.grey,
),
),
],
),
),
],
)
],
),
),
)
: Container(
color: Colors.white,
width: MediaQuery.of(context).size.width,
),
),
backgroundColor: AppTheme.white,
body: Stack(
children: <Widget>[
FutureBuilder<bool>(
future: getData(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
} else {
return Padding(
padding:
EdgeInsets.only(top: MediaQuery.of(context).padding.top),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
appBar(),
Expanded(
child: FutureBuilder<bool>(
future: getData(),
builder: (BuildContext context,
AsyncSnapshot<bool> snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
} else {
return ChangeNotifierProvider(
create: (context) => Properties(),
child: PropertiesGrid(_showOnlyFavorites),
);
}
},
),
),
],
),
);
}
},
),
],
),
);
}
Widget appBar() {
return SizedBox(
height: AppBar().preferredSize.height,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 8, left: 8),
child: Container(
width: AppBar().preferredSize.height - 8,
height: AppBar().preferredSize.height - 8,
),
),
Expanded(
child: Center(
child: Padding(
padding: const EdgeInsets.only(top: 4),
child:
Image.asset('assets/images/logo.png', fit: BoxFit.contain),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 8, right: 8),
child: Container(
width: AppBar().preferredSize.height - 8,
height: AppBar().preferredSize.height - 8,
color: Colors.white,
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius:
BorderRadius.circular(AppBar().preferredSize.height),
child: Icon(
Icons.location_on,
color: AppTheme.dark_grey,
),
onTap: () {
setState(() {
multiple = !multiple;
});
},
),
),
),
),
],
),
);
}
}
I hope some one could figure with me this problem and how to solve it :)...
May be I think that there's a problem with the height of the SizedBox as in this question Flutter: RenderBox was not laid out, but I tried to add the height I found the same problem...
It looks like you put your appBar() in a column. That should be in the appBar property of the Scaffold widget.
You need to use the AppBar() Widget in the Scaffold.
Scaffold(
appBar: AppBar(
title: Text('Put Screen title here'),
actions: <Widget>[IconButton(
icon: Icons.location_on,
onPressed: () {
setState(() {
multiple = !multiple;
});
}),
],
),
),
You are setting height and width of the appBar manually but you are fighting the Flutter framework by doing so.