Flutter-如何在列表视图内将小部件居中
我正在努力将小部件放在内部居中listView。
我试过了,但Text('ABC')没有垂直居中。我该如何实现?
new Scaffold(  appBar: new AppBar(),
  body: new ListView(
    padding: const EdgeInsets.all(20.0),
    children: [
      new Center(
        child: new Text('ABC')
      )
    ]
  )
);
回答:
垂直居中和水平居中:
Scaffold(  appBar: new AppBar(),
  body: Center(
    child: new ListView(
      shrinkWrap: true,
        padding: const EdgeInsets.all(20.0),
        children: [
          Center(child: new Text('ABC'))
        ]
    ),
  ),
);
仅垂直中心
Scaffold(  appBar: new AppBar(),
  body: Center(
    child: new ListView(
      shrinkWrap: true,
        padding: const EdgeInsets.all(20.0),
        children: [
          new Text('ABC')
        ]
    ),
  ),
);
以上是 Flutter-如何在列表视图内将小部件居中 的全部内容, 来源链接: utcz.com/qa/434647.html








