What is the color of the default Scaffold body?

Viewed 6285

I want to create a AppBar which has the same color as that of the Scaffold body however I am not able to figure out the color of the body. I checked the source code of Scaffold however they don't have the Color code there either.

Is there any way I can find this out? Thanks

3 Answers

Scaffold gets its color from applied theme - usually the default one, if you have not overridden it.

To replicate that behaviour use:

Container(
  color: Theme.of(context).scaffoldBackgroundColor
)

If you don't have access to current context - simply use Colors.grey[50], which is the default canvas color in the Light theme.

try setting the scaffoldBackgroundColor in the theme of your application

MaterialApp(
              key: key,
              title: 'Strong app,
              theme: ThemeData(
                 scaffoldBackgroundColor: Colors.red
              )
              ...
),

theme.of(context).canvasColor

works for me

Related