Flutter 如何调整ListView.builder';s尺寸是否适合一个大的顶部AppBar?

Flutter 如何调整ListView.builder';s尺寸是否适合一个大的顶部AppBar?,flutter,flutter-layout,Flutter,Flutter Layout,我有一个Listview.builder正在创建一个列表,但我想让它更灵活,或者知道如何稍微缩小它以适应上面更大的应用程序栏。我目前在ListView.Builder上方的应用程序栏上遇到“底部溢出”错误,因为没有足够的空间。下面是我目前对Appbar和ListView的介绍 这是Listview @override Widget build(BuildContext context) { return Scaffold( appBar: FuelAppBar(

我有一个Listview.builder正在创建一个列表,但我想让它更灵活,或者知道如何稍微缩小它以适应上面更大的应用程序栏。我目前在ListView.Builder上方的应用程序栏上遇到“底部溢出”错误,因为没有足够的空间。下面是我目前对Appbar和ListView的介绍

这是Listview

 @override
 Widget build(BuildContext context) {
   return Scaffold(
     appBar: FuelAppBar(
       appBar: AppBar(),
     ),
     body: Container(
         height: 200,
         child: ListView.builder(
         itemCount: locations.length,
         shrinkWrap: true,
         itemBuilder: (context, index) {
           return Padding(
             padding: EdgeInsets.symmetric(vertical: 1.0, horizontal: 4.0),
             child: Card(
               color: (index % 2 == 0) ? greycolor : Colors.white,
               child: Container(
                   height: 60,
                   padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
                   child: Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                     children: <Widget>[
                       Text(locations[index].date,
                           style: TextStyle(fontSize: 20),
                           textAlign: TextAlign.left),
                       Text(locations[index].location,
                           style: TextStyle(
                               fontSize: 20, fontWeight: FontWeight.bold),
                           textAlign: TextAlign.center),
                       Text(locations[index].amount.toString(),
                           style: TextStyle(fontSize: 20),
                           textAlign: TextAlign.right)
                     ],
                   )
               ),
             ),
           );
         })),
     );
 }
@覆盖
小部件构建(构建上下文){
返回脚手架(
appBar:FuelAppBar(
appBar:appBar(),
),
主体:容器(
身高:200,
子项:ListView.builder(
itemCount:locations.length,
收缩膜:对,
itemBuilder:(上下文,索引){
返回填充(
填充:边缘设置。对称(垂直:1.0,水平:4.0),
孩子:卡片(
颜色:(索引%2==0)?灰色:Colors.white,
子:容器(
身高:60,
填充:来自LTRB(0,20,0,0)的边插入集,
孩子:排(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
文本(位置[索引])。日期,
样式:TextStyle(字体大小:20),
textAlign:textAlign.left),
文本(位置[索引])。位置,
样式:TextStyle(
fontSize:20,fontWeight:fontWeight.bold),
textAlign:textAlign.center),
文本(位置[索引].amount.toString(),
样式:TextStyle(字体大小:20),
textAlign:textAlign.right)
],
)
),
),
);
})),
);
}
这是自定义Appbar

@override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        Row(
          children: [
            Container(
              color: Colors.orange,
              margin: EdgeInsets.all(15.0),
              child: FlutterLogo(
                size: 10.0,
              ),
            ),
            Container(
              color: Colors.blue,
              margin: EdgeInsets.all(15.0),
              child: FlutterLogo(
                size: 10.0,
              ),
            ),
            Container(
              color: Colors.purple,
              margin: EdgeInsets.all(15.0),
              child: FlutterLogo(
                size: 10.0,
              ),
            ),
          ],
        ),
        Row(
            children: [
              Container(
                color: Colors.orange,
                margin: EdgeInsets.all(25.0),
                child: FlutterLogo(
                  size: 10.0,
                ),
              ),
              Container(
                color: Colors.blue,
                margin: EdgeInsets.all(25.0),
                child: FlutterLogo(
                  size: 10.0,
                ),
              ),
              Container(
                color: Colors.purple,
                margin: EdgeInsets.all(25.0),
                child: FlutterLogo(
                  size: 10.0,
                ),
              )
            ]
    ),


        Row(
            children: [
              Container(
                color: Colors.orange,
                margin: EdgeInsets.all(25.0),
                child: FlutterLogo(
                  size: 10.0,
                ),
              ),
              Container(
                color: Colors.blue,
                margin: EdgeInsets.all(25.0),
                child: FlutterLogo(
                  size: 10.0,
                ),
              ),
              Container(
                color: Colors.purple,
                margin: EdgeInsets.all(25.0),
                child: FlutterLogo(
                  size: 10.0,
                ),
              ),
            ]),
      ]);


  @override
  Size get preferredSize => new Size.fromHeight(appBar.preferredSize.height);
  }
@覆盖
小部件构建(构建上下文){
返回列(
儿童:[
划船(
儿童:[
容器(
颜色:颜色。橙色,
边距:所有边缘集(15.0),
孩子:我的标志(
尺寸:10.0,
),
),
容器(
颜色:颜色,蓝色,
边距:所有边缘集(15.0),
孩子:我的标志(
尺寸:10.0,
),
),
容器(
颜色:颜色,紫色,
边距:所有边缘集(15.0),
孩子:我的标志(
尺寸:10.0,
),
),
],
),
划船(
儿童:[
容器(
颜色:颜色。橙色,
边距:所有边缘集(25.0),
孩子:我的标志(
尺寸:10.0,
),
),
容器(
颜色:颜色,蓝色,
边距:所有边缘集(25.0),
孩子:我的标志(
尺寸:10.0,
),
),
容器(
颜色:颜色,紫色,
边距:所有边缘集(25.0),
孩子:我的标志(
尺寸:10.0,
),
)
]
),
划船(
儿童:[
容器(
颜色:颜色。橙色,
边距:所有边缘集(25.0),
孩子:我的标志(
尺寸:10.0,
),
),
容器(
颜色:颜色,蓝色,
边距:所有边缘集(25.0),
孩子:我的标志(
尺寸:10.0,
),
),
容器(
颜色:颜色,紫色,
边距:所有边缘集(25.0),
孩子:我的标志(
尺寸:10.0,
),
),
]),
]);
@凌驾
Size get preferredSize=>new Size.fromHeight(appBar.preferredSize.height);
}

谢谢大家

您可以使用PreferredSize小部件

class MainApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:首选大小(
首选尺寸:从高度开始的尺寸(136.0),
孩子:AppBar(
automaticallyImplyLeading:false,//隐藏前导小部件
flexibleSpace:CustomAppBar(),
),
),
正文:中(
孩子:文本(“呵呵”),
),
);
}
}