skip to Main Content

so i was learning flutter and i was checking the hot reload function of it and there is a problem i encountered the default program gives you an app that counts the number of times the button is clicked and there is a heading on the top written "Flutter Demo Home Page" and the default background color is deepPurple but when i change it to some other colors like black or grey it gives me some random color and when i do red ,green or blue it works perfectly fine . What could be the problem can someone solve this?The picture for Black colorThe picture for Blue color

I tried Black ,grey and white for now and i don’t know which many colors won’t work please tell me how to solve this problem!

2

Answers


  1. It is because you are not specificly changing the backgroundColor of the AppBar, you are changing the value of the seed that generates a color palette for your app, based on the provided color. And the seed doesn’t like colors like black, white or grey; it needs a "true" color (with R, G and B not being aligned as for black-to-white tints) to define where it will put the accent while generating the palette.

    Login or Signup to reply.
  2. The possible reason here is when you are using Material 3 color scheme and utilizing the fromSeed method, it’s essentially akin to informing Flutter that, "Hey, I have this color as my seed," and it will automatically generate a Material 3-based color scheme/palette, which is then utilized according to Material 3 guidelines by all other components in the app.

    So, if you provide grey or black, it doesn’t necessarily mean it will pick that color only for what you expect. It implicitly or automatically picks what suits or looks best. You might need to explicitly specify in that case.

    For more information and insights:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search