0

嗨,我正在尝试构建和 UI

标题

IMG

描述

但是因为我的标题是 2 大,主要是 2 行,所以EXCEPTION CAUGHT BY RENDERING LIBRARY 我的代码如下:

Widget _buildRowItem() {
    final Row mainRow = new Row(
      mainAxisAlignment: MainAxisAlignment.start,
      children: <Widget>[
        new Text(_feed.getTitle(),
            maxLines: 2, softWrap: true, textAlign: TextAlign.start),
      ],
    );
    final Container container = new Container(
      child: mainRow,
      padding: const EdgeInsets.all(4.0),
      color: Colors.teal,
    );

    return container;
  }

输出: 在此处输入图像描述

4

3 回答 3

1

你的方法几乎就在那里!

添加一个灵活的包装器并完成。

在此处输入图像描述

  Widget _buildRowItem() {
final Row mainRow = new Row(
  mainAxisAlignment: MainAxisAlignment.start,
  children: <Widget>[
    new Flexible(child: new Text('some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text ',
        maxLines: 2, softWrap: true, textAlign: TextAlign.start))

  ],
);
final Container container = new Container(
  child: mainRow,
  padding: const EdgeInsets.all(4.0),
  color: Colors.teal,
);

return container;

}

于 2018-04-15T10:55:50.843 回答
0

谢谢你,我很感激你的回复,

在这之间解决了我的问题

Widget _buildRowItem() {
    final Column column = new Column(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: <Widget>[
        new Text(_feed.getTitle(),
            textAlign: TextAlign.start,
            softWrap: true,
            maxLines: 2,
            overflow: TextOverflow.ellipsis),
        new Container(height: 8.0),
        new Image.network(
          _feed.getImageUrl(),
          height: 164.0,
          fit: BoxFit.fitWidth,
        )
      ],
    );
    final Container container =
        new Container(padding: const EdgeInsets.all(8.0), child: column);

    return new Card(child: container);
  }

用户界面: 在此处输入图像描述

于 2018-04-16T05:31:44.687 回答
0
you can use here Extended or Flexible with container specific hight

for example

 Container(
            width: MediaQuery.of(context).size.width / 1.3,
            height: MediaQuery.of(context).size.height/3.5,
            padding: EdgeInsets.all(0.5),
            child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                verticalDirection: VerticalDirection.down,
                textDirection: TextDirection.ltr,
                mainAxisSize: MainAxisSize.max,
                crossAxisAlignment: CrossAxisAlignment.start,
                children:
                List.generate(mEmiMessagesList.length, (index) {
                  return Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Wrap(
                        children: <Widget>[
                          Text(
                            mEmiMessagesList[index].mValue,
                            textDirection: TextDirection.ltr,
                          )
                        ],
                      ),
                    ],
                  );
                })),
          ),
于 2019-04-29T10:05:13.567 回答