颤抖地在顶部和底部将小部件添加到列表视图 [英] flutter add widgets on top and bottom to a listview

查看:33
本文介绍了颤抖地在顶部和底部将小部件添加到列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将一些小部件添加到列表视图的前面.... 我进行搜索并发现使用了展开式,例如:

Trying to add some widgets to before of a listview.... I searched and found to use expanded like:

  return Scaffold(
    appBar: AppBar(
      title: Text('Test Listview'),
    ),
    body: Container(
      padding: const EdgeInsets.all(10.0),
      child: Column(
        children: <Widget>[
          Text('header'),
          Expanded(
            child: ListView.builder(
              itemCount: providerApp.domains.length,
              itemBuilder: (BuildContext context, int index) {
                return Container( ......

但是这里的问题是Text('header')将得到修复,以某种方式使小部件与listview一起滚动...

But the issue here is that the Text('header') will be fixed, looking for some way where the the widget scrolls together with listview...

谢谢!!!

推荐答案

您可以通过在列表视图内使用listview实现此目的,下面是示例代码,请检查

You can achieve this by using listview inside list view, below is sample code please check

 body: ListView(
    children: <Widget>[
      Container(
        height: 40,
        color: Colors.deepOrange,
        child: Center(
          child: Text(
            'Header',
            style: TextStyle(color: Colors.white, fontSize: 16),
          ),
        ),
      ),
      ListView.builder(
        physics: ScrollPhysics(),
        shrinkWrap: true,
        itemCount: 50,
        itemBuilder: (BuildContext context, int index) {
          return Container(
            color: Colors.lime,
            height: 60,
            child: Center(
              child: Text(
                'Child $index',
                style: TextStyle(color: Colors.black, fontSize: 16),
              ),
            ),
          );
        },
      ),
      Container(
        height: 40,
        color: Colors.deepOrange,
        child: Center(
          child: Text(
            'Footer',
            style: TextStyle(color: Colors.white, fontSize: 16),
          ),
        ),
      ),
    ],
  ),

这篇关于颤抖地在顶部和底部将小部件添加到列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆