如何在颤动中创建自定义条子?

时间:2019-10-22 18:08:30

标签: user-interface flutter dart responsive-design

我想在银条应用程序栏下创建一个自定义容器,如图像中的右屏幕

https://cdn.dribbble.com/users/1720296/screenshots/6918712/dribbble_blog_2x.jpg

1 个答案:

答案 0 :(得分:0)

您可以将自定义标头与SliverPersistentHeaderDelegate

一起使用

这是您的自定义SliverPersistentHeaderDelegate

class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {

  @override
  double get minExtent => 100;
  @override
  double get maxExtent => 300;

  @override
  Widget build(
      BuildContext context, double shrinkOffset, bool overlapsContent) {
    return Container(
      ...
    );
  }

  @override
  bool shouldRebuild(_SliverAppBarDelegate oldDelegate) {
    return false;
  }
}

并像这样使用它

SliverPersistentHeader(
  delegate: _SliverAppBarDelegate(
    ...
  ),
  pinned: true,
),