如何使Flutter中的Expanded滚动文本

时间:2019-11-05 12:21:09

标签: android ios flutter mobile

我正在忙于使用包含信息的闪存卡构建应用程序,但遇到了一个愚蠢的问题,我似乎无法弄清。

要提供上下文,卡片小部件当前如下所示:

https://i.stack.imgur.com/7Bmrc.png

如您所见,文本被截断。我曾尝试将Expanded更改为SingleChildScrollView,但最终遇到这种情况:

https://i.stack.imgur.com/nj2jC.png

我知道解决方案可能很简单,但是我已经摆弄了几个小时

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10),
      decoration: BoxDecoration(
        color: Colors.indigo,
        borderRadius: BorderRadius.circular(20),
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              Image.asset(
                getCategoryImage(),
                width: 50
              ),
              Container(width: 10),
              Text(
                title,
                style: TextStyle(
                  fontFamily: "Estherilla",
                  fontSize: 30,
                  color: Colors.white
                ),
              )
            ],
          ),
          SingleChildScrollView(
            child: Padding(
              padding: const EdgeInsets.symmetric(vertical: 25),
              child: Text(
                content,
                style: TextStyle(
                  fontSize: 25,
                  color: Colors.white
                ),
              ),
            )
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: <Widget>[
              Text(
                "#$author",
                style: TextStyle(
                  fontFamily: "Estherilla",
                  color: Colors.white,
                  fontSize: 20
                ),
              )
            ],
          )
        ],
      ),
    );
  }

我们将不胜感激

1 个答案:

答案 0 :(得分:2)

SingleChildScrollView包裹在这样的Expanded小部件中

 Column(
   ...

   Expanded(
     child: SingleChildScrollView(...)
   ),

   ...
 )