# ThemData(colorScheme: xxx) vs ThemeData.from(colorScheme: xxx)?

**URL:** <https://forums.kodeco.com/t/themdata-colorscheme-xxx-vs-themedata-from-colorscheme-xxx/153238>\
**Category:** Flutter Apprentice\
**Created:** [October 15, 2021, 6:27am UTC](https://forums.kodeco.com/t/themdata-colorscheme-xxx-vs-themedata-from-colorscheme-xxx/153238 "2021-10-15T06:27:31Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jomoka](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jomoka/32/109828_2.png) [@jomoka](https://forums.kodeco.com/u/jomoka)\
**Post date:** [October 17, 2021, 6:07am UTC](https://forums.kodeco.com/t/themdata-colorscheme-xxx-vs-themedata-from-colorscheme-xxx/153238/2 "2021-10-17T06:07:00Z")

</div>

@salmankhilji thanks for the interesting question.

By diving into the ThemeData documentation and implementation here is the reason why the background color is blue vs white in some cases.

## Using ThemeData Constructor

When you used the ThemeData constructor:

```auto
ThemeData(
        colorScheme: Theme.of(context).colorScheme.copyWith(
              primary: Colors.grey,
              secondary: Colors.black,
            ),
      ),

```

By default `scaffoldBackgroundColor` takes the canvasColor as shown below:

 ![Screen Shot 2021-10-17 at 1.51.47 PM](https://files.chunter.kodeco.com/original/3X/c/f/cf6f9d155034d29424626f66da63c386bdcce2fc.png)

This is why the background color is set to grey[50] (Almost white looking)

## Using ThemeData.from

In the case when you changed to use the `ThemeData.from`

```auto
ThemeData.from(
        colorScheme: Theme.of(context).colorScheme.copyWith(
              primary: Colors.grey,
              secondary: Colors.black,
            ),
      ),

```

What you did here was:

1. Take the existing colorScheme from the context, and create a new copy but **only** set primary and secondary color.

The reason why the background is light blue in this case is because the default background color uses primarySwatch which is set to blue by default. You will have to update the colorScheme’s background color in this case.

Here is a screenshot of the ThemeData constructor:

 ![Screen Shot 2021-10-17 at 1.50.09 PM](https://files.chunter.kodeco.com/original/3X/4/3/43b9409423947618aa6e38c6e494b3f5ca06996f.png)

You will notice that the default colorScheme’s backgroundColor is also set to blue.

When you look at the ThemeData.from constructor, you will see it uses `colorScheme.background` to set the scaffoldBackgroundCOlor

 ![Screen Shot 2021-10-17 at 2.09.35 PM](https://files.chunter.kodeco.com/original/3X/8/a/8a8920a39d2c882563776f7acea3f69310cd249c.png)

You can check out the entire ThemeData constructor implementation here:

> **[ThemeData.new constructor - ThemeData - material library - Dart API](https://api.flutter.dev/flutter/material/ThemeData/ThemeData.html)**
>
> API docs for the ThemeData.new constructor from Class ThemeData from the material library, for the Dart programming language.

Hope this is helpful!

---

_[View the full topic](https://forums.kodeco.com/t/themdata-colorscheme-xxx-vs-themedata-from-colorscheme-xxx/153238)._
