Реализация сворачивающейся панели инструментов во флаттере - PullRequest
1 голос
/ 29 июня 2019

Я пытаюсь реализовать сворачивающуюся панель инструментов в моем приложении, используя панель SliverApp, но проблема в том, что SliverAppBar перекрывает мой контент, когда SliverAppBar свернут, я прилагаю gif для большего понимания,

содержимое на зеленом фоне идет под панелью инструментов, я хочу, чтобы все потенциальные клиенты были признательны.

  @override
  Widget build(BuildContext context) {
    // TODO: implement buildr
    var _tabs = {"1", "2", "3"};
    return Scaffold(
      backgroundColor: Colors.white,
      body: NestedScrollView(
          headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
            return <Widget>[
              SliverOverlapAbsorber(
                  handle:
                      NestedScrollView.sliverOverlapAbsorberHandleFor(context),
                  child: SliverAppBar(
                    expandedHeight: 250.0,
                    floating: false,
                    pinned: true,
                    flexibleSpace: FlexibleSpaceBar(
                        centerTitle: true,
                        background: Container(
                          decoration: BoxDecoration(
                            shape: BoxShape.rectangle,
                            image: DecorationImage(
                              fit: BoxFit.fill,
                              image: CachedNetworkImageProvider(
                                  newsPost.photos[0].url),
                            ),
                          ),
                        )),
                    forceElevated: innerBoxIsScrolled,
                  ))
            ];
          },
          body: SafeArea(
            top: false,
            bottom: false,
            child: Builder(
              builder: (BuildContext context) {
                return CustomScrollView(
                  slivers: <Widget>[
                    SliverOverlapInjector(
                      handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
                          context),
                    ),
                    SliverPadding(
                      padding: const EdgeInsets.all(8.0),
                      sliver: SliverFillRemaining(child: _getBody()),
                    ),
                  ],
                );
              },
            ),
          )),
    );
  }

enter image description here

...