Flutter 滚动时如何在颤振中隐藏顶部appbar

Flutter 滚动时如何在颤振中隐藏顶部appbar,flutter,Flutter,当我们试图从身体向上滚动时,如何隐藏应用程序栏。我有自定义的应用程序栏,我想隐藏应用程序栏时,我试图从身体滚动。我试了很多,但没有成功 Scaffold( appBar: PreferredSize( child: ClipPath( clipper: CustomAppBar(), child: Container( child: Column( mainAxisAlignment: MainAxisA

当我们试图从身体向上滚动时,如何隐藏应用程序栏。我有自定义的应用程序栏,我想隐藏应用程序栏时,我试图从身体滚动。我试了很多,但没有成功

Scaffold(
  appBar: PreferredSize(
      child: ClipPath(
        clipper: CustomAppBar(),
        child: Container(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                ' Bike Guru',
                style: GoogleFonts.caveatBrush(
                  fontSize: 40,
                  color: Colors.black,
                  fontWeight: FontWeight.bold,
                ),
              ),
            ],
          ),
        ),
      ),
      preferredSize: Size.fromHeight(kToolbarHeight + 150))
脚手架(
appBar:首选大小(
孩子:克利帕斯(
裁剪器:CustomAppBar(),
子:容器(
子:列(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
正文(
“自行车大师”,
样式:GoogleFonts.caveatBrush(
尺寸:40,
颜色:颜色,黑色,
fontWeight:fontWeight.bold,
),
),
],
),
),
),
首选大小:大小。起始高度(kToolbarHeight+150))

试试这一款,对我有用

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: NestedScrollView(
        headerSliverBuilder: (context, innerBoxIsScrolled) {
          return <Widget>[
            SliverAppBar(
              backgroundColor: Colors.transparent,
              title: Center(
                child: PreferredSize(
                    child: ClipPath(
                      clipper: CustomAppBar(),
                      child: Container(
                        width: MediaQuery.of(context).size.width,
                        height: 60,
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: <Widget>[
                            Text(
                              ' Bike Guru',
                            ),
                          ],
                        ),
                      ),
                    ),
                    preferredSize: Size.fromHeight(kToolbarHeight + 150)),
              ),
              floating: false,
              pinned: false,
            ),
          ];
        },
        body: Center(
          child: Text("Sample Text"), // Actual body content
        ),
      ),
    );
  }
@覆盖
小部件构建(构建上下文){
返回脚手架(
正文:嵌套滚动视图(
headerSliverBuilder:(上下文,InnerBoxIsCrowled){
返回[
滑杆(
背景颜色:颜色。透明,
标题:中心(
孩子:首选尺寸(
孩子:克利帕斯(
裁剪器:CustomAppBar(),
子:容器(
宽度:MediaQuery.of(context).size.width,
身高:60,
子:列(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
正文(
“自行车大师”,
),
],
),
),
),
preferredSize:Size.fromHeight(kToolbarHeight+150)),
),
浮动:假,
错,,
),
];
},
正文:中(
child:Text(“示例文本”),//实际正文内容
),
),
);
}

试试这一款,对我有用

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: NestedScrollView(
        headerSliverBuilder: (context, innerBoxIsScrolled) {
          return <Widget>[
            SliverAppBar(
              backgroundColor: Colors.transparent,
              title: Center(
                child: PreferredSize(
                    child: ClipPath(
                      clipper: CustomAppBar(),
                      child: Container(
                        width: MediaQuery.of(context).size.width,
                        height: 60,
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: <Widget>[
                            Text(
                              ' Bike Guru',
                            ),
                          ],
                        ),
                      ),
                    ),
                    preferredSize: Size.fromHeight(kToolbarHeight + 150)),
              ),
              floating: false,
              pinned: false,
            ),
          ];
        },
        body: Center(
          child: Text("Sample Text"), // Actual body content
        ),
      ),
    );
  }
@覆盖
小部件构建(构建上下文){
返回脚手架(
正文:嵌套滚动视图(
headerSliverBuilder:(上下文,InnerBoxIsCrowled){
返回[
滑杆(
背景颜色:颜色。透明,
标题:中心(
孩子:首选尺寸(
孩子:克利帕斯(
裁剪器:CustomAppBar(),
子:容器(
宽度:MediaQuery.of(context).size.width,
身高:60,
子:列(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
正文(
“自行车大师”,
),
],
),
),
),
preferredSize:Size.fromHeight(kToolbarHeight+150)),
),
浮动:假,
错,,
),
];
},
正文:中(
child:Text(“示例文本”),//实际正文内容
),
),
);
}

您尝试了吗?我尝试了,但未能成功查看。我尝试了,但自定义应用程序栏不会显示,只会显示一个简单的矩形应用程序栏。您尝试了吗?我尝试了,但未能成功查看。我尝试了,但自定义应用程序栏不会显示,只会显示一个简单的矩形应用程序栏。自定义显示不会显示矩形应用程序栏正在显示ar..添加backgroundColor:Colors.transparent in SliverappBar结果是左上角的小自定义形状栏仅用于增加高度和宽度..?在容器中指定高度和宽度()自定义显示未显示正在显示的矩形应用程序栏..添加背景颜色:颜色。在SliverAppBar中透明结果是左上角的小自定义形状栏仅用于增加高度和宽度..?在容器中指定高度和宽度()