Проблема рендеринга флаттера - PullRequest
0 голосов
/ 16 мая 2018

Я новичок в разработке мобильных устройств Flutter.У меня есть файл DART, который получает данные JSON с моего локального хоста.Теперь я хочу показать данные в виде списка.

Но я получаю следующее в журналах

I/flutter (23058):   EXCEPTION CAUGHT BY RENDERING LIBRARY 
I/flutter (23058): The following message was thrown during layout:
I/flutter (23058): A RenderFlex overflowed by 242 pixels on the right.

Ниже приведен мой код для отображения вида

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Timeline"),
        backgroundColor: Colors.orange,
      ),
      body: ListView.builder(
        shrinkWrap: true,
        itemCount: data == null ? 0 : data.length,
        itemBuilder: (BuildContext context, int index) {
          return Container(
            child: Center(
              child: Row(
                children: <Widget>[
                  new Card(
                    child: new Container(
                      padding: EdgeInsets.all(8.0),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          new Text(
                            data[index]["text"],
                            softWrap: true,
                            style: new TextStyle(
                              fontFamily: 'Hind',
                              fontSize: 17.0, color: Colors.black87
                            )
                          ),
                        ],
                      ),
                    ),
                  ),
                ],
              ),
            ),
          );
        },
      ),
    );
  }

This is the screenshot of the rendered screen

1 Ответ

0 голосов
/ 16 мая 2018

Оберните свою карту в Расширенный виджет.

return Container(
            child: Center(
              child: Row(
                children: <Widget>[
                  Expanded(
                    child: new Card(
                      child: new Container(
                        padding: EdgeInsets.all(8.0),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            new Text(data[index],
                                softWrap: true,
                                //overflow: TextOverflow.ellipsis,
                                style: new TextStyle(
                                    fontFamily: 'Hind',
                                    fontSize: 17.0,
                                    color: Colors.black87)),
                          ],
                        ),
                      ),
                    ),
                  )
                ],
              ),
            ),
          );

ScreenShot enter image description here

...