Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter SliverAppBar中的FlexibleSpace没有隐藏它';当我向下滚动时,将显示内容_Flutter_Dart_Flutter Layout_Flutter Sliver_Sliverappbar - Fatal编程技术网

Flutter SliverAppBar中的FlexibleSpace没有隐藏它';当我向下滚动时,将显示内容

Flutter SliverAppBar中的FlexibleSpace没有隐藏它';当我向下滚动时,将显示内容,flutter,dart,flutter-layout,flutter-sliver,sliverappbar,Flutter,Dart,Flutter Layout,Flutter Sliver,Sliverappbar,问题是: 为什么向下滚动时,flexibleSpace中的内容没有隐藏 这是我的代码: class Home extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: CustomScrollView( physics: PageScrollPhysics(), slivers: [ SliverAppBar

问题是:

为什么向下滚动时,
flexibleSpace
中的内容没有隐藏

这是我的代码:

class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
  return Scaffold(
    body: CustomScrollView(
      physics: PageScrollPhysics(),
      slivers: [
        SliverAppBar(
          title: Text('Dashboard'),
          actions: [
            CircleAvatar(
              backgroundColor: Colors.transparent,
              backgroundImage: NetworkImage('https://i.pinimg.com/originals/da/51/c2/da51c26fe3398b0f8314fee17a98e0e7.jpg'),
            ),
            SizedBox(width: 10.0),
          ],
          floating: false,
          pinned: true,
          expandedHeight: 300.0,
          flexibleSpace: Stack(
            children: <Widget>[
              Positioned.fill(
                child: Image.network(
                  "https://images.wallpapersden.com/image/download/colorful-neon-bubbles_a2dtaWmUmZqaraWkpJRmbmdlrWZlbWU.jpg",
                  fit: BoxFit.cover,
                )
              ),
              Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Text('Join as our member now,\nget discount upto 70%', style: TextStyle(color: Colors.white),),
                    SizedBox(height: 8.0),
                    RaisedButton(
                      child: Text('Subscribe now', style: TextStyle(color: Colors.red),),
                      onPressed: () {},
                    )
                  ],
                ),
              )
            ],
          ),
        ),
        SliverList(
        delegate: SliverChildListDelegate([
          Container(
            height: 500.0,
              ),
            ]),
          )
        ],
      ),
    );
  }
}

添加一个,然后将您的
堆栈
作为其
背景
,如下所示:

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        physics: PageScrollPhysics(),
        slivers: [
          SliverAppBar(
              title: Text('Dashboard'),
              actions: [
                CircleAvatar(
                  backgroundColor: Colors.transparent,
                  backgroundImage: NetworkImage(
                      'https://i.pinimg.com/originals/da/51/c2/da51c26fe3398b0f8314fee17a98e0e7.jpg'),
                ),
                SizedBox(width: 10.0),
              ],
              floating: false,
              pinned: true,
              expandedHeight: 300.0,
              flexibleSpace: FlexibleSpaceBar(
                background: Stack(
                  children: <Widget>[
                    Positioned.fill(
                        child: Image.network(
                      "https://images.wallpapersden.com/image/download/colorful-neon-bubbles_a2dtaWmUmZqaraWkpJRmbmdlrWZlbWU.jpg",
                      fit: BoxFit.cover,
                    )),
                    Center(
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Text(
                            'Join as our member now,\nget discount upto 70%',
                            style: TextStyle(color: Colors.white),
                          ),
                          SizedBox(height: 8.0),
                          RaisedButton(
                            child: Text(
                              'Subscribe now',
                              style: TextStyle(color: Colors.red),
                            ),
                            onPressed: () {},
                          )
                        ],
                      ),
                    )
                  ],
                ),
              )),
          SliverList(
            delegate: SliverChildListDelegate([
              Container(
                height: 500.0,
              ),
            ]),
          )
        ],
      ),
    );
  }
}
class Home扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回脚手架(
正文:自定义滚动视图(
物理:物理(),
条子:[
滑杆(
标题:文本(“仪表板”),
行动:[
圆形(
背景颜色:颜色。透明,
背景图片:NetworkImage(
'https://i.pinimg.com/originals/da/51/c2/da51c26fe3398b0f8314fee17a98e0e7.jpg'),
),
尺寸箱(宽度:10.0),
],
浮动:假,
对,,
扩展高度:300.0,
flexibleSpace:FlexibleSpaceBar(
背景:堆栈(
儿童:[
定位填充(
孩子:Image.network(
"https://images.wallpapersden.com/image/download/colorful-neon-bubbles_a2dtaWmUmZqaraWkpJRmbmdlrWZlbWU.jpg",
适合:BoxFit.cover,
)),
居中(
子:列(
mainAxisAlignment:mainAxisAlignment.center,
crossAxisAlignment:crossAxisAlignment.center,
儿童:[
正文(
“立即加入成为我们的会员,\n享受高达70%的折扣”,
样式:TextStyle(颜色:Colors.white),
),
尺寸箱(高度:8.0),
升起的按钮(
子:文本(
“立即订阅”,
样式:TextStyle(颜色:Colors.red),
),
按下:(){},
)
],
),
)
],
),
)),
银表(
委托:SliverChildListDelegate([
容器(
高度:500.0,
),
]),
)
],
),
);
}
}
添加一个,然后将您的
堆栈
作为其
背景
,如下所示:

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        physics: PageScrollPhysics(),
        slivers: [
          SliverAppBar(
              title: Text('Dashboard'),
              actions: [
                CircleAvatar(
                  backgroundColor: Colors.transparent,
                  backgroundImage: NetworkImage(
                      'https://i.pinimg.com/originals/da/51/c2/da51c26fe3398b0f8314fee17a98e0e7.jpg'),
                ),
                SizedBox(width: 10.0),
              ],
              floating: false,
              pinned: true,
              expandedHeight: 300.0,
              flexibleSpace: FlexibleSpaceBar(
                background: Stack(
                  children: <Widget>[
                    Positioned.fill(
                        child: Image.network(
                      "https://images.wallpapersden.com/image/download/colorful-neon-bubbles_a2dtaWmUmZqaraWkpJRmbmdlrWZlbWU.jpg",
                      fit: BoxFit.cover,
                    )),
                    Center(
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Text(
                            'Join as our member now,\nget discount upto 70%',
                            style: TextStyle(color: Colors.white),
                          ),
                          SizedBox(height: 8.0),
                          RaisedButton(
                            child: Text(
                              'Subscribe now',
                              style: TextStyle(color: Colors.red),
                            ),
                            onPressed: () {},
                          )
                        ],
                      ),
                    )
                  ],
                ),
              )),
          SliverList(
            delegate: SliverChildListDelegate([
              Container(
                height: 500.0,
              ),
            ]),
          )
        ],
      ),
    );
  }
}
class Home扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回脚手架(
正文:自定义滚动视图(
物理:物理(),
条子:[
滑杆(
标题:文本(“仪表板”),
行动:[
圆形(
背景颜色:颜色。透明,
背景图片:NetworkImage(
'https://i.pinimg.com/originals/da/51/c2/da51c26fe3398b0f8314fee17a98e0e7.jpg'),
),
尺寸箱(宽度:10.0),
],
浮动:假,
对,,
扩展高度:300.0,
flexibleSpace:FlexibleSpaceBar(
背景:堆栈(
儿童:[
定位填充(
孩子:Image.network(
"https://images.wallpapersden.com/image/download/colorful-neon-bubbles_a2dtaWmUmZqaraWkpJRmbmdlrWZlbWU.jpg",
适合:BoxFit.cover,
)),
居中(
子:列(
mainAxisAlignment:mainAxisAlignment.center,
crossAxisAlignment:crossAxisAlignment.center,
儿童:[
正文(
“立即加入成为我们的会员,\n享受高达70%的折扣”,
样式:TextStyle(颜色:Colors.white),
),
尺寸箱(高度:8.0),
升起的按钮(
子:文本(
“立即订阅”,
样式:TextStyle(颜色:Colors.red),
),
按下:(){},
)
],
),
)
],
),
)),
银表(
委托:SliverChildListDelegate([
容器(
高度:500.0,
),
]),
)
],
),
);
}
}