2

当我尝试在一行中添加listview.builder时出现异常

我的代码:

return new Scaffold(
  appBar: new AppBar(
    // Here we take the value from the MyHomePage object that was created by
    // the App.build method, and use it to set our appbar title.
    title: new Text(widget.title),
  ),
  body: Row(children: <Widget>[
      ListView.builder(
        shrinkWrap: true,

        scrollDirection: Axis.vertical,
        itemCount: 3,
        itemBuilder: (BuildContext context, int index) {
          return Text('data');
        },
      )
     // This trailing comma makes auto-formatting nicer for build methods.
  ],)
);

例外:

══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 5949): The following assertion was thrown during performLayout():
I/flutter ( 5949): 'package:flutter/src/rendering/viewport.dart': Failed assertion: line 1597 pos 16:
I/flutter ( 5949): 'constraints.hasBoundedWidth': is not true.
I/flutter ( 5949): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter ( 5949): more information in this error message to help you determine and fix the underlying cause.
4

1 回答 1

1

Wrap Expanded 然后添加到 list.builder > Physics: const NeverScrollableScrollPhysics(),

于 2020-01-16T13:29:54.937 回答