【问题标题】:Problem rendering widgets above expanded listview in a column问题在列中展开的列表视图上方呈现小部件
【发布时间】:2019-08-02 00:32:47
【问题描述】:

我正在尝试渲染一个列(在 CupertinoPageScaffold 内),其中列在展开的列表视图之前和之后具有(在子项中)小部件。渲染列表视图之后的小部件,但不渲染列表视图之前的小部件。 Link to image with rendered screen

class TestWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        Container(
          constraints: BoxConstraints(
            minHeight: 50.0,
          ),
          child: Center(
            child: Text(
              'Top label',
              style: TextStyle(
                  fontSize: 22.0,
                  fontWeight: FontWeight.bold,
                  color: Colors.teal),
            ),
          ),
        ),
        Expanded(
          child: ListView.separated(
            itemCount: 20,
            separatorBuilder: (context, index) {
              return Divider();
            },
            itemBuilder: (context, index) {
              return Material(
                child: ListTile(
                  leading: CircleAvatar(),
                  title: Text('Test title'),
                ),
              );
            },
          ),
        ),
        Container(
          constraints: BoxConstraints(
            minHeight: 50.0,
          ),
          child: Center(
            child: Text(
              'Bottom label',
              style: TextStyle(
                  fontSize: 22.0,
                  fontWeight: FontWeight.bold,
                  color: Colors.teal),
            ),
          ),
        ),
      ],
    );
  }
}

【问题讨论】:

    标签: flutter dart flutter-layout


    【解决方案1】:

    只需在SafeArea 中添加您的TestWidget

    
    SafeArea(
     child: TestWidget()
    );
    
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-20
      • 1970-01-01
      • 2016-07-16
      • 1970-01-01
      相关资源
      最近更新 更多