簡體   English   中英

如何在 flutter 中制作類似於 appbar 的 Whatsapp

[英]How to make Whatsapp like appbar in flutter

我正在創建一個應用程序,我需要在其中實現像 AppBar 這樣的 WhatsApp,即在向下滾動時隱藏應用程序欄並在反向時顯示。

您可以使用SliverAppBarCustomScrollView來實現此效果。 示例實現:

Widget build(BuildContext context) {
  return Scaffold(
    body: CustomScrollView(
      slivers: <Widget>[
        SliverAppBar(
          pinned: false,
          snap: false,
          floating: false,
          expandedHeight: 160.0,
          flexibleSpace: const FlexibleSpaceBar(
            title: Text('AppBar'),
          ),
        ),
        SliverList(
          delegate: SliverChildBuilderDelegate(
            (BuildContext context, int index) {
              return Container(
                color: index.isOdd ? Colors.white : Colors.black12,
                height: 100.0,
                child: Center(
                  child: Text('$index', textScaleFactor: 5),
                ),
              );
            },
            childCount: 50,
          ),
        ),
      ],
    ),
  );
}

暫無
暫無

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

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