gaurav kerkar
gaurav kerkar

Reputation: 147

How to make two widgets sticky

I'm working on a flutter project, where in I want to make two widgets to be sticky on scroll.

EDIT: I have a sticky app bar, a sticky tab bar, and within the tab body, I want a sticky widget.

enter image description here

Upvotes: 1

Views: 1183

Answers (3)

Md. Yeasin Sheikh
Md. Yeasin Sheikh

Reputation: 63594

You can use sliver_tools multisliver

class WidgetThatReturnsASliver extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CustomScrollView(slivers: [
      MultiSliver(
        pushPinnedChildren: false, // defaults to false
        children: <Widget>[
          SliverPinnedHeader(
            child: Text("pinnded header"),
          ),
          SliverToBoxAdapter(
            child: Container(
              height: 899,
            ),
          ),
          SliverPinnedHeader(
            child: Text("pinnded header2"),
          ),
          SliverToBoxAdapter(
            child: Container(
              height: 899,
            ),
          ),
        ],
      ),
    ]);
  }
}

Upvotes: 1

IonicFireBaseApp
IonicFireBaseApp

Reputation: 1230

Do something like this

body:Column(
Children:[Sticky Widget1,
          Sticky Widget2,       
         Expended(child:Listview(children: 
                [ScrollableWidget1,ScrollableWidget2,...]
                ))]
)

All the best!!!

Upvotes: 0

Nikhith sunil
Nikhith sunil

Reputation: 285

I thing you can use SliverAppBar to achieve it

Upvotes: 0

Related Questions