Make scrollable Text inside container in Flutter

為{幸葍}努か 提交于 2019-12-22 01:24:12

问题


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?


回答1:


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"))),


来源:https://stackoverflow.com/questions/55515671/make-scrollable-text-inside-container-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!