3

I want a widget to be place below the app while scrolling the screen . The screen contains a floating app bar with flexible space ( sliverappbar) and below it one conatiner which have any container or tab view . The video in the link is the example of the effect i wanted.

ankit jain
  • 33
  • 1
  • 1
  • 3

2 Answers2

15

Alright, I think I understand you now. You'll need to implement a CustomScrollView

CustomScrollView(
              slivers: <Widget>[
                SliverAppBar(
                    // Your appbar goes here
                    ),
                SliverPersistentHeader(
                  pinned: true,
                  delegate: PersistentHeader(
                    widget: Row(
                      // Format this to meet your need
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: <Widget>[
                        Text('Hello World'),
                        Text('Hello World'),
                        Text('Hello World'),
                      ],
                    ),
                  ),
                ),
              ],
            ),

Create a new class for the Persistent header, which extends a SliverPersistentHeaderDelegate as shown:

class PersistentHeader extends SliverPersistentHeaderDelegate {
  final Widget widget;

  PersistentHeader({this.widget});

  @override
  Widget build(
      BuildContext context, double shrinkOffset, bool overlapsContent) {
    return Container(
      width: double.infinity,
      height: 56.0,
      child: Card(
        margin: EdgeInsets.all(0),
        color: Colors.white,
        elevation: 5.0,
        child: Center(child: widget),
      ),
    );
  }

  @override
  double get maxExtent => 56.0;

  @override
  double get minExtent => 56.0;

  @override
  bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
    return true;
  }
}

Let me know if you encounter any other issue.

Chichebe
  • 580
  • 5
  • 12
1

I have an idea of a solution to your particular problem, having recently implemented something quite similar or identical to what you want, but I can't find the link you talked about to the video of the effect you're trying to achieve. Could you edit and upload the link to the video so I can view to enable me to render the precise solution to your problem?

Chichebe
  • 580
  • 5
  • 12
  • https://drive.google.com/file/d/1PhEBRzoZgYhKrJ5xK2xe2ebOWqw2_8vW/view?usp=drivesdk <---- as this is not the exact the want i wanted but you can see in this video below appbar there is widget which is pin above the list view . – ankit jain Apr 24 '20 at 17:26