I have an alert dialog with a list inside. For some weird reason, I am getting a an error because of a size property
var jobTypes = [
{"Job type": jobTypeHm, "Active": true},
{"Job type": jobTypeLs, "Active": false},
{"Job type": jobTypePm, "Active": false},
{"Job type": jobTypeRm, "Active": false},
{"Job type": jobTypeRf, "Active": false},
{"Job type": jobTypeEl, "Active": false},
];
Future _displayJobTypeAlert(BuildContext context) {
return showDialog(
context: context,
builder: (context) {
String contentText = "Content of Dialog";
return StatefulBuilder(
builder: (context, setState) {
return SizedBox(
height: 300,
child: AlertDialog(
title: Text("Title of Dialog"),
content: ListView.builder(
itemCount: jobTypes.length,
itemBuilder: (context, index) {
return ListTile(
title: Text('${jobTypes[index]["Job type"]}'),
);
},
),
),
);
},
);
},
);
}
I get the following error:
Restarted application in 534ms.
D/EGL_emulation(20775): app_time_stats: avg=1214.46ms min=22.72ms max=3597.70ms count=3
W/DynamiteModule(20775): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule(20775): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller(20775): Failed to load providerinstaller module: No acceptable module com.google.android.gms.providerinstaller.dynamite found. Local version is 0 and remote version is 0.
D/TrafficStats(20775): tagSocket(100) with statsTag=0xffffffff, statsUid=-1
D/EGL_emulation(20775): app_time_stats: avg=375.60ms min=9.08ms max=1987.43ms count=6
D/EGL_emulation(20775): app_time_stats: avg=81.23ms min=13.30ms max=891.21ms count=14
════════ Exception caught by rendering library ═════════════════════════════════
The following assertion was thrown during performLayout():
RenderViewport does not support returning intrinsic dimensions.
Calculating the intrinsic dimensions would require instantiating every child of the viewport, which defeats the point of viewports being lazy.
If you are merely trying to shrink-wrap the viewport in the main axis direction, consider a RenderShrinkWrappingViewport render object (ShrinkWrappingViewport widget), which achieves that effect without implementing the intrinsic dimension API.
The relevant error-causing widget was
AlertDialog
When the exception was thrown, this was the stack
#0 RenderViewportBase.debugThrowIfNotCheckingIntrinsics.<anonymous closure>
#1 RenderViewportBase.debugThrowIfNotCheckingIntrinsics
#2 RenderViewportBase.computeMaxIntrinsicWidth
#3 RenderBox._computeIntrinsicDimension.<anonymous closure>
#4 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#5 RenderBox._computeIntrinsicDimension
#6 RenderBox.getMaxIntrinsicWidth
#7 RenderProxyBoxMixin.computeMaxIntrinsicWidth
#8 RenderBox._computeIntrinsicDimension.<anonymous closure>
#9 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#10 RenderBox._computeIntrinsicDimension
#11 RenderBox.getMaxIntrinsicWidth
#12 RenderProxyBoxMixin.computeMaxIntrinsicWidth
#13 RenderBox._computeIntrinsicDimension.<anonymous closure>
#14 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#15 RenderBox._computeIntrinsicDimension
#16 RenderBox.getMaxIntrinsicWidth
#17 RenderProxyBoxMixin.computeMaxIntrinsicWidth
#18 RenderBox._computeIntrinsicDimension.<anonymous closure>
#19 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#20 RenderBox._computeIntrinsicDimension
#21 RenderBox.getMaxIntrinsicWidth
#22 RenderProxyBoxMixin.computeMaxIntrinsicWidth
#23 RenderBox._computeIntrinsicDimension.<anonymous closure>
#24 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#25 RenderBox._computeIntrinsicDimension
#26 RenderBox.getMaxIntrinsicWidth
#27 RenderProxyBoxMixin.computeMaxIntrinsicWidth
#28 RenderBox._computeIntrinsicDimension.<anonymous closure>
#29 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#30 RenderBox._computeIntrinsicDimension
#31 RenderBox.getMaxIntrinsicWidth
#32 RenderProxyBoxMixin.computeMaxIntrinsicWidth
#33 RenderBox._computeIntrinsicDimension.<anonymous closure>
#34 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#35 RenderBox._computeIntrinsicDimension
#36 RenderBox.getMaxIntrinsicWidth
#37 RenderProxyBoxMixin.computeMaxIntrinsicWidth
#38 RenderBox._computeIntrinsicDimension.<anonymous closure>
#39 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#40 RenderBox._computeIntrinsicDimension
#41 RenderBox.getMaxIntrinsicWidth
#42 RenderProxyBoxMixin.computeMaxIntrinsicWidth
#43 RenderCustomPaint.computeMaxIntrinsicWidth
#44 RenderBox._computeIntrinsicDimension.<anonymous closure>
#45 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#46 RenderBox._computeIntrinsicDimension
#47 RenderBox.getMaxIntrinsicWidth
#48 RenderProxyBoxMixin.computeMaxIntrinsicWidth
#49 RenderBox._computeIntrinsicDimension.<anonymous closure>
#50 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#51 RenderBox._computeIntrinsicDimension
#52 RenderBox.getMaxIntrinsicWidth
#53 RenderProxyBoxMixin.computeMaxIntrinsicWidth
#54 RenderBox._computeIntrinsicDimension.<anonymous closure>
#55 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#56 RenderBox._computeIntrinsicDimension
#57 RenderBox.getMaxIntrinsicWidth
#58 RenderPadding.computeMaxIntrinsicWidth
#59 RenderBox._computeIntrinsicDimension.<anonymous closure>
#60 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#61 RenderBox._computeIntrinsicDimension
#62 RenderBox.getMaxIntrinsicWidth
#63 RenderFlex.computeMaxIntrinsicWidth.<anonymous closure>
#64 RenderFlex._getIntrinsicSize
#65 RenderFlex.computeMaxIntrinsicWidth
#66 RenderBox._computeIntrinsicDimension.<anonymous closure>
#67 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#68 RenderBox._computeIntrinsicDimension
#69 RenderBox.getMaxIntrinsicWidth
#70 RenderIntrinsicWidth._computeSize
#71 RenderIntrinsicWidth.performLayout
#72 RenderObject.layout
#73 RenderBox.layout
#74 RenderProxyBoxMixin.performLayout
#75 RenderObject.layout
#76 RenderBox.layout
#77 RenderProxyBoxMixin.performLayout
#78 RenderObject.layout
#79 RenderBox.layout
#80 RenderProxyBoxMixin.performLayout
#81 RenderCustomPaint.performLayout
#82 RenderObject.layout
#83 RenderBox.layout
#84 RenderProxyBoxMixin.performLayout
#85 _RenderCustomClip.performLayout
#86 RenderObject.layout
#87 RenderBox.layout
#88 RenderConstrainedBox.performLayout
#89 RenderObject.layout
#90 RenderBox.layout
#91 RenderPositionedBox.performLayout
#92 RenderObject.layout
#93 RenderBox.layout
#94 RenderPadding.performLayout
#95 RenderObject.layout
#96 RenderBox.layout
#97 RenderConstrainedBox.performLayout
#98 RenderObject.layout
#99 RenderBox.layout
#100 RenderPadding.performLayout
#101 RenderObject.layout
#102 RenderBox.layout
#103 RenderPadding.performLayout
#104 RenderObject.layout
#105 RenderBox.layout
#106 RenderProxyBoxMixin.performLayout
#107 RenderObject.layout
#108 RenderBox.layout
#109 RenderProxyBoxMixin.performLayout
#110 RenderObject.layout
#111 RenderBox.layout
#112 RenderProxyBoxMixin.performLayout
#113 RenderObject.layout
#114 RenderBox.layout
#115 RenderProxyBoxMixin.performLayout
#116 RenderObject.layout
#117 RenderBox.layout
#118 RenderProxyBoxMixin.performLayout
#119 RenderObject.layout
#120 RenderBox.layout
#121 RenderProxyBoxMixin.performLayout
#122 RenderObject.layout
#123 RenderBox.layout
#124 RenderProxyBoxMixin.performLayout
#125 RenderObject.layout
#126 RenderBox.layout
#127 RenderProxyBoxMixin.performLayout
#128 RenderOffstage.performLayout
#129 RenderObject.layout
#130 RenderBox.layout
#131 RenderProxyBoxMixin.performLayout
#132 RenderObject.layout
#133 RenderBox.layout
#134 _RenderTheatre.performLayout
#135 RenderObject._layoutWithoutResize
#136 PipelineOwner.flushLayout
#137 RendererBinding.drawFrame
#138 WidgetsBinding.drawFrame
#139 RendererBinding._handlePersistentFrameCallback
#140 SchedulerBinding._invokeFrameCallback
#141 SchedulerBinding.handleDrawFrame
#142 SchedulerBinding._handleDrawFrame
#143 _invoke (dart:ui/hooks.dart:148:13)
#144 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:318:5)
#145 _drawFrame (dart:ui/hooks.dart:115:31)
The following RenderObject was being processed when the exception was fired: RenderIntrinsicWidth#c9923 relayoutBoundary=up6 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
RenderObject: RenderIntrinsicWidth#c9923 relayoutBoundary=up6 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none> (can use size)
constraints: BoxConstraints(280.0<=w<=312.7, 0.0<=h<=711.3)
size: MISSING
stepWidth: null
stepHeight: null
child: RenderFlex#66394 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none>
constraints: MISSING
size: MISSING
direction: vertical
mainAxisAlignment: start
mainAxisSize: min
crossAxisAlignment: stretch
verticalDirection: down
child 1: RenderPadding#a35af NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
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: RenderSemanticsAnnotations#5e60b NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0)
constraints: MISSING
semantic boundary
size: MISSING
child: RenderParagraph#fac88 NEEDS-LAYOUT NEEDS-PAINT
parentData: <none>
constraints: MISSING
size: MISSING
textAlign: start
textDirection: ltr
softWrap: wrapping at box width
overflow: clip
locale: en_US
maxLines: unlimited
child 2: RenderPadding#263c7 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.loose
constraints: MISSING
size: MISSING
padding: EdgeInsets(24.0, 20.0, 24.0, 24.0)
textDirection: ltr
child: RenderSemanticsAnnotations#99975 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: offset=Offset(0.0, 0.0)
constraints: MISSING
semantic boundary
size: MISSING
child: RenderRepaintBoundary#51add NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: <none>
constraints: MISSING
size: MISSING
usefulness ratio: no metrics collected yet (never painted)
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderIntrinsicWidth#c9923 relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 2001 pos 12: 'hasSize'
The relevant error-causing widget was
AlertDialog
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#b6791 relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 2001 pos 12: 'hasSize'
The relevant error-causing widget was
AlertDialog
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: _RenderInkFeatures#484c6 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 2001 pos 12: 'hasSize'
The relevant error-causing widget was
AlertDialog
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderCustomPaint#4c909 relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 2001 pos 12: 'hasSize'
The relevant error-causing widget was
AlertDialog
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPhysicalShape#a87b9 relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 2001 pos 12: 'hasSize'
The relevant error-causing widget was
AlertDialog
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
'package:flutter/src/rendering/shifted_box.dart': Failed assertion: line 361 pos 12: 'child!.hasSize': is not true.
The relevant error-causing widget was
AlertDialog
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPhysicalShape#a87b9 relayoutBoundary=up2
'package:flutter/src/rendering/box.dart':
Failed assertion: line 2001 pos 12: 'hasSize'
The relevant error-causing widget was
AlertDialog
════════════════════════════════════════════════════════════════════════════════
I know I can hardcopy the buttons on the alert and it would work, but thats a terrible approach. is there a better way to do this or should I just hard copy these values?
Try to wrap your ListView inside SizedBox or Container and give it to specific heifgt and width, add shrinkWrap: true, inside ListView.builder()