Reputation: 25
main.dart
.......
final _widgetOptions = [Post(), Cat(), Fav(), Editors()];
..........
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: IndexedStack(index: currentIndex, children: _widgetOptions), //so on
post.dart
import 'package:flutter/material.dart';
class Cat extends StatefulWidget {
@override
_CatState createState() => _CatState();
}
class _CatState extends State<Cat> {
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: <Widget>[
Text("Latest Posts"),
ListView.builder(
itemBuilder: (context, index) {
return Text("DEMO DATA");
},
itemCount: 2,
)
],
));
}
}
when i try to return a column with having children TEXT and ListView.builder the execution gets stop with error msg " ════════ Exception caught by rendering library ═════════════════════════════════ RenderBox was not laid out: RenderSemanticsGestureHandler#abd36 relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 'package:flutter/src/rendering/box.dart': Failed assertion: line 1694 pos 12: 'hasSize'"
Upvotes: 1
Views: 513
Reputation: 406
you can try this to solve your problem.
class Cat extends StatefulWidget {
@override
_CatState createState() => _CatState();
}
class _CatState extends State<Cat> {
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Text("Latest Posts"),
Expanded(
child:ListView.builder(
itemBuilder: (context, index) {
return Text("DEMO DATA");
},
itemCount: 100,
)
)
],
);
}
}
Upvotes: 0