我试图在视图中创建一个可滚动的文本:

// other widgets,

SingleChildScrollView(
  child: Container(
    height: 200,
    child: Text(
      "Long text here which is longer than the container height"))),

// other widgets

文本比其父容器的高度长,但由于某些原因,文本不能滚动,尽管它被包装在SingleChildScrollView内.知道我做错了什么吗?

推荐答案

try 添加scrollDirection(水平):

SingleChildScrollView(
scrollDirection: Axis.horizontal,
  child: Container(
      height: 200,
      child: Text(
          "Long text here which is longer than the container height")))

默认为垂直.

或者,如果你想要符合你的身高,那么你必须改变顺序(Container内的SingleChildScrollView):

Container(
    height: 200,
    child: SingleChildScrollView(
        child: Text(
            "Long text here which is longer than the container height")))

Dart相关问答推荐

无法在 IOS 上使用 firebase 运行Flutter应用程序

Dart 包对 git repo 子目录的依赖

Flutter:Firebase身份验证无需登录即可创建用户

在构建函数之外使用 BuildContext

执行 `dart2js` 时会生成哪些文件?为什么?

如何实现 Iterable

dart:js 和 js 包有什么区别?

自定义声音推送通知不起作用

在 Flutter 中保持响应的同时制作持久的背景图像

如何签署 Flutter 的应用程序

替换 Flutter 中的片段等小部件

如何编辑 Flutter 的 TextFormField 输入和 errorText 之间的间距

Flutter 屏幕尺寸计算

使用Flatter向Cloud Firestore添加对象

是否有必要为Flatter安装Android Studio,或者可以用什么替代Android Studio?

是什么使它成为 Dart 中的固定长度列表?

Dart MD5 字符串

如何从 Dart 中的列表中获取随机元素?

Null aware函数调用运算符

dart 折叠(Fold)与减少(Reduce)