is flutter SliverAppbar height same for every device?

Viewed 81

I am trying to add a container with certain height to title of SliverAppBar with a certain height. I am trying to figure out how can I determine the height of the sliverAppBar and give height to the container based on that. I don't want to mess up the view with different screen sized devices. Currently height of 40 for the Iphone 12 works like how I want it to be, however I am worried that it may not look same across different devices. So my question is that is app bar height same across all devices? If not how can I dynamically get the height of the appbar ?

SliverAppBar(
              automaticallyImplyLeading: false,
              backgroundColor: Colors.blue,
              title: Container(
                color: Colors.black,
                width: size.width * 0.85,
                height: 40,
              )),
1 Answers

No app bar size is not same across all devices,

you can get the size of app by doing this

Define your app separately like this

Widget demoPage() {
  AppBar appBar = AppBar(
    title: Text('Demo'),
  );
  return Scaffold(
    appBar: appBar,
    body: /*
    page body
    */,
  );
}

And then get it's height like this

double height = appBar.preferredSize.height;
Related