I'm trying to create a scrollable Text inside a view:
// other widgets,
SingleChildScrollView(
child: Container(
height: 200,
child: Text(
"Long text here which is longer than the container height"))),
// other widgets
The text is longer than the height of its parent container, but for some reason the text is not scrollable although it is wrapped inside SingleChildScrollView
. Any idea what I'm doing wrong?
Just change Column widget to ListView widget — and that's all. Your container becomes scrollable.
We can make the text scrollable in flutter using these 2 widgets: Expanded Class: A widget that expands a child of a Row, Column, or Flex so that the child fills the available space. SingleChildScrollView Class: A box in which a single widget can be scrolled.
See the example below. TextEditingController _editTextController = TextEditingController(); // Initialise a scroll controller. ScrollController _scrollController = ScrollController(); Then, add it to the TextField widget and wrap this widget in a Scrollbar !
Try to add scrollDirection
(horizontal):
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Container(
height: 200,
child: Text(
"Long text here which is longer than the container height")))
Default is vertical.
Or if you want to have with your height then you have to change the order (SingleChildScrollView
inside Container
):
Container(
height: 200,
child: SingleChildScrollView(
child: Text(
"Long text here which is longer than the container height")))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With