Reputation: 113
I have been trying a lot of ways to try to get rid of the excess space at the end of my sentence which is supposed to be unpredictable. does anyone know how to make sure the length of the widget ends at the end of the last text, especially when used with pageview or list view widget?. it works fine without the use of any scrollable widget but anytime I use a scrollable widget I have to add a height which makes it hard to define a boundary.
class FeedsDetailView extends StatelessWidget {
const FeedsDetailView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final String text2 = lorem(paragraphs: 9, words: 500);
final String text3 = lorem(paragraphs: 10, words: 1000);
final String text4 = lorem(paragraphs: 8, words: 5000);
final String text5 = lorem(paragraphs: 12, words: 500);
final textList = [
text3,
text4,
text5,
];
return Scaffold(
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(top: 45),
child: Column(
children: [
Container(
height: 380,
width: double.maxFinite,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/night building.jpeg'),
fit: BoxFit.cover,
),
),
),
const SizedBox(height: 8),
Divider(
color: Theme.of(context).colorScheme.secondary,
indent: 50,
endIndent: 50,
),
Container(
height: double.maxFinite,
child: PageView.builder(
itemCount: textList.length + 1,
itemBuilder: ((context, index) {
if (index == 0) {
return Column(
children: [
const Text('bla bla bla'),
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.only(left: 8, right: 8),
child: SizedBox(width: 350, child: Text(text3)),
),
],
);
} else {
return Column(
children: [
const Text('bla bla bla'),
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.only(left: 8, right: 8),
child: SizedBox(
width: 350,
child: Text(
textList[index - 1],
),
),
)
],
);
}
}),
),
)
],
),
),
),
);
}
}
I am also using the flutter_lorem package to generate long texts.
Upvotes: 0
Views: 547