Sumit Shukla
Sumit Shukla

Reputation: 4494

Status bar turns transparent while scrolling SliverAppBar in flutter

Here is code:

Scaffold(
    CustomScrollView(
        slivers: <Widget>[
          SliverAppBar(
            title: Text("Home"),
            floating: false,
            pinned: false,
            snap: false,
          ),
          SliverList(
            delegate: SliverChildListDelegate(SOME_LIST_DATA),
          ),
        ],
      )
)

Upvotes: 3

Views: 2853

Answers (3)

Tarique Anowar
Tarique Anowar

Reputation: 130

Use SafeArea. It's easy and convenient. Below is the official doc link.

https://api.flutter.dev/flutter/widgets/SafeArea-class.html

Upvotes: 0

SHAFI TPM
SHAFI TPM

Reputation: 39

wrap your widget with SafeArea, it works for me...

Upvotes: 0

Mike
Mike

Reputation: 398

From what I understand the color of the status bar is changed automatically depending on the AppBar Brightness see: https://api.flutter.dev/flutter/services/SystemChrome/setSystemUIOverlayStyle.html.

But if as i suspect what you want to achieve is to keep the status bar the default color of your AppBar you can do this (although i don't particularly recommend it):

SystemChrome.setSystemUIOverlayStyle(
        SystemUiOverlayStyle(statusBarColor: Theme.of(context).primaryColor));

Of course you can change the Theme.of(context).primaryColor by any color you wish.

Upvotes: 1

Related Questions