1

問題:

ここに画像の説明を入力 ここに画像の説明を入力

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,
              ),
            ]),
          )
        ],
      ),
    );
  }
}

編集:これを試しましたが、うまくいきませんでした。

bottom: PreferredSize(
  preferredSize: Size.fromHeight(0),
  child: ... 

ここに画像の説明を入力 ここに画像の説明を入力

4

1 に答える 1

5

次のように、 FlexibleSpaceBarを追加してからStack、その として追加しますbackground

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,
              ),
            ]),
          )
        ],
      ),
    );
  }
}
于 2020-12-02T08:35:10.797 に答える