Search code snippets, questions, articles...

Add a single widget as a sliver in Flutter

Scaffold(
  body: CustomScrollView(
    slivers: <Widget>[
      SliverToBoxAdapter(
        child: Container(
          child: Text('This is a single widget'),
        ),
      )
    ],
  ),
);

If you want to add a single widget or child as slivers, you can use SliverToBoxAdapter sliver widget and pass your widget as its child.

This will only add a particular widget if there is a requirement. Like if you want to add a heading before sliverlist widget you can use it for that purpose.

Search Index Data (The code snippet can also be found with below search text)

Add a single text or container as sliver in Flutter
Was this helpful?
0 Comments
Programming Feeds
Learn something new everyday on Devsheet