【问题标题】:Appbar hide/show like iOS StyleAppbar 隐藏/显示,如 iOS 风格
【发布时间】:2020-06-11 08:40:28
【问题描述】:

我想在 ListVIew 的第一个子项像 iOS 样式一样滚动时显示 AppBar(尤其是在 iOS 的本机 Books 应用程序中的行为)。 iOS 中的许多应用程序确实具有此功能,因此我认为这是 iOS 中的常见行为。但我不知道如何将其应用于具有 Material Style 的 Flutter。有谁知道这个问题的解决方案? 下面的 GIF 显示了我想要实现的行为: Behavior with Appbar iOS Style

【问题讨论】:

标签: flutter flutter-listview flutter-appbar


【解决方案1】:

是的,您可以在 MaterialApp 中使用 SliverAppBar 和脚手架主体部分的 CustomScrollView 来实现。 您可以使用 SliverAppBar 代替普通的 appBar 您将使用的小部件应位于
银名单( 委托:SliverChildListDelegate( []))

return Scaffold(


  body: CustomScrollView(
    slivers: <Widget>[
      SliverAppBar(
        expandedHeight: 300,
        pinned: true,
        flexibleSpace: FlexibleSpaceBar(
          title: Text(
           "Reading Now",
            style: TextStyle(
              fontSize: 20,
              color: Colors.white,
              fontWeight: FontWeight.w500,
            ),
            textAlign: TextAlign.end,
          ),
          background: Image.network(
              https://i.stack.imgur.com/1lN0b.png,
              fit: BoxFit.fill,
            ),
        ),
      ),
      SliverList(
        delegate: SliverChildListDelegate(
          [


//widgets which you are going to use inside the listview you can use them in 
//sliverList
                ]
              ),//SliverChildListDelegate
          ),//SliverList
    ],//sliver Widgets
  ),//customScrollView

【讨论】:

  • 但是区别在于使用的ScorllView这里我用的是CustomScrollView而不是NestedScrollVIew
  • 在AppBar的背景中,您可以使用您选择的任何颜色或使用图像
猜你喜欢
  • 1970-01-01
  • 2020-09-25
  • 1970-01-01
  • 2013-05-13
  • 1970-01-01
  • 2021-10-11
  • 1970-01-01
  • 1970-01-01
  • 2016-12-13
相关资源
最近更新 更多