First of all, I know what causes this Exception.
I have a ListView with multiple Widgets in it, but I only want to display one and keep the others loaded.
It's working very well, but I keep getting the RenderBox Exception (Because of flex 0 i think) in the console which is distracating while debugging.
How can I surpress this Exception without, not-rendering the Widgets?
Widget build(BuildContext context) {
int showPage = 0;
return ListView(
key: someKey,
children: [
Expanded(
flex: showPage == 0 ? 1 : 0,
child: CustomWidget1,
),
Expanded(
flex: showPage == 1 ? 1 : 0,
child: CustomWidget2,
),
Expanded(
flex: showPage == 2 ? 1 : 0,
child: CustomWidget3,
),
]
);
}
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderCustomPaint#b7941 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1785 pos 12: 'hasSize'
The relevant error-causing widget was
ListView-[Null#007db]
════════════════════════════════════════════════════════════════════════════════
question from:
https://stackoverflow.com/questions/65601596/flutter-suppress-exception-renderbox-was-not-laid-out 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…