簡體   English   中英

Flutter:如何在應用程序中滾動到頁面頂部時放大圖像?

[英]Flutter: How to enlarge an Image when scrolling to the top of a page in an app?

我有一個頁面,頂部有一個圖像,下面有一些其他小部件。 整個頁面是可滾動的。 有誰知道如何在滾動到頂部時放大圖像以創建類似於 Apple Music 中的效果?

在這里,您可以找到我正在嘗試創建的示例:

https://i.stack.imgur.com/MiYLZ.gif

嘗試使用 Sliver

final bannerHigh = 150.0;
return Scaffold(

      body: CustomScrollView(
        slivers: <Widget>[
          SliverAppBar(
            backgroundColor: Color(0xFF0084C9),
            leading: IconButton(
              icon: Icon(
                Icons.blur_on,
                color: Colors.white70,
              ),
              onPressed: () {
                Scaffold.of(context).openDrawer();
              },
            ),
            expandedHeight: bannerHigh,
            floating: true,
            pinned: true,
            flexibleSpace: FlexibleSpaceBar(
              title: Text("Your title",
                  style: TextStyle(
                      fontSize: 18,
                      color: Colors.white,
                      fontWeight: FontWeight.w600)),
              background: Image.network(
                'image url',
                fit: BoxFit.cover,
              ),
            ),
          ),
          SliverList(
            delegate: SliverChildListDelegate(
              <Widget>[

              ],
            ),
          ),
        ],
      ),
    );

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM