Layout 颤振:如何设置滑杆的高度?

Layout 颤振:如何设置滑杆的高度?,layout,flutter,appbar,Layout,Flutter,Appbar,我正在尝试使用SliverAppBar。手机设备的布局很好。然而,当我使用iPad测试布局时,AppBar的高度似乎没有改变,它无法正确显示标题文本 当我关闭AppBar时: 我也尝试过将bottom属性添加到SliverAppBar,但它也不起作用 bottom: PreferredSize( preferredSize: Size.fromHeight(60.0), child: Text(''),

我正在尝试使用SliverAppBar。手机设备的布局很好。然而,当我使用iPad测试布局时,AppBar的高度似乎没有改变,它无法正确显示标题文本

当我关闭AppBar时:

我也尝试过将bottom属性添加到SliverAppBar,但它也不起作用

bottom: PreferredSize(                       
   preferredSize: Size.fromHeight(60.0),      
   child: Text(''),                           
),  
结果如下所示:

标题文本仍然受到不可见高度的限制

我的代码:

new SliverAppBar(
        expandedHeight: Adapt.px(220.0),
        floating: false,
        elevation: 0.0,
        pinned: true,
        primary: true,
        centerTitle: true,
        title: Text("TITLE",
            style: TextStyle(
                color: Colors.white,
                fontSize: Adapt.px(45.0),
                fontFamily: "pinfon",
                fontWeight: FontWeight.w900,
                letterSpacing: 1.0)),
        backgroundColor: Colors.black45,
        brightness: Brightness.dark,
        bottom: PreferredSize(                       
            preferredSize: Size.fromHeight(60.0),      
            child: Text(''),                           
          ), 
        flexibleSpace: new FlexibleSpaceBar(
          background: Opacity(
            opacity: 0.5,
            child: new Stack(
              fit: StackFit.expand,
              children: <Widget>[
                new Image.asset(
                    "assets/images/back.jpg",
                    fit: BoxFit.fitWidth,
                  ),
              ],
            ),
          ),
        ),
      ),
新滑动条(
扩展高度:Adapt.px(220.0),
浮动:假,
标高:0.0,
对,,
小学:对,
标题:对,
标题:文本(“标题”,
样式:TextStyle(
颜色:颜色,白色,
fontSize:Adapt.px(45.0),
fontFamily:“pinfon”,
fontWeight:fontWeight.w900,
字母间距:1.0),
背景颜色:Colors.black45,
亮度:亮度。暗,
底部:首选尺寸(
首选尺寸:尺寸。从高度(60.0),
子项:文本(“”),
), 
flexibleSpace:新的FlexibleSpaceBar(
背景:不透明度(
不透明度:0.5,
子:新堆栈(
fit:StackFit.expand,
儿童:[
新形象资产(
“assets/images/back.jpg”,
适合:BoxFit.fitWidth,
),
],
),
),
),
),

我已经测试了您提供的示例代码,在使用iPad Air-4代-14.0仿真器时,布局似乎运行良好

不过,我无法看到您的完整代码。我刚刚重用了您提供的最少代码,并创建了一个完整的示例来查看输出

以下是我的示例代码:

import 'package:flutter/material.dart';

void main() => runApp(SilverAppBarExample());

class SilverAppBarExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: CustomScrollView(
          slivers: <Widget>[
            new SliverAppBar(
              expandedHeight: 220.0,
              floating: false,
              elevation: 0.0,
              pinned: true,
              primary: true,
              centerTitle: true,
              title: Text("TITLE",
                  style: TextStyle(
                      color: Colors.white,
                      fontSize: 45.0,
                      fontFamily: "pinfon",
                      fontWeight: FontWeight.w900,
                      letterSpacing: 1.0)),
              backgroundColor: Colors.black45,
              brightness: Brightness.dark,
              bottom: PreferredSize(
                preferredSize: Size.fromHeight(60.0),
                child: Text(''),
              ),
              flexibleSpace: new FlexibleSpaceBar(
                background: Opacity(
                  opacity: 0.5,
                  child: new Stack(
                    fit: StackFit.expand,
                    children: <Widget>[
                      new Image.asset(
                        "assets/background.jpg",
                        fit: BoxFit.fitWidth,
                      ),
                    ],
                  ),
                ),
              ),
            ),
            new SliverList(
                delegate: new SliverChildListDelegate(_buildList(50))),
          ],
        ),
      ),
    );
  }

  List _buildList(int count) {
    List<Widget> listItems = List();

    for (int i = 0; i < count; i++) {
      listItems.add(new Padding(
          padding: new EdgeInsets.all(20.0),
          child: new Text('Item ${i.toString()}',
              style: new TextStyle(fontSize: 25.0))));
    }

    return listItems;
  }
}
导入“包装:颤振/材料.省道”;
void main()=>runApp(silverAppBareExample());
类SilverAppBarExample扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回材料PP(
家:脚手架(
正文:自定义滚动视图(
条子:[
新滑杆(
扩展高度:220.0,
浮动:假,
标高:0.0,
对,,
小学:对,
标题:对,
标题:文本(“标题”,
样式:TextStyle(
颜色:颜色,白色,
字体大小:45.0,
fontFamily:“pinfon”,
fontWeight:fontWeight.w900,
字母间距:1.0),
背景颜色:Colors.black45,
亮度:亮度。暗,
底部:首选尺寸(
首选尺寸:尺寸。从高度(60.0),
子项:文本(“”),
),
flexibleSpace:新的FlexibleSpaceBar(
背景:不透明度(
不透明度:0.5,
子:新堆栈(
fit:StackFit.expand,
儿童:[
新形象资产(
“assets/background.jpg”,
适合:BoxFit.fitWidth,
),
],
),
),
),
),
新名单(
委托:新建SliverChildListDelegate(_buildList(50)),
],
),
),
);
}
列表\u构建列表(整数计数){
列表项=列表();
for(int i=0;i
使用iPad Air的输出-第四代-14.0仿真器

扩大:

缩小:

似乎
滑动条
工作正常

我还用iPhone模拟器对其进行了验证

iPhone SE-第二代-14.0

扩大:

缩小:

以下是一个实时输出:


如果您能提供您所创建的全部代码,我们将能够在我们这边检查它。

您为sliverappbar编写了什么代码?您是否使用expandedHeight:。你也可以上传你的代码吗?是的,我使用了expandedHeight,代码已经上传了。