Skip to content

How the front text color decided? #42

Closed Answered by rydmike
wyxcoder asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @wyxcode,

If you look in the shared code for the examples that show the theme color boxes and the text on them:

https://github.com/rydmike/flex_color_scheme/blob/master/example/lib/shared/show_theme_colors.dart

You can see that it actually uses 3 different strategies to do this.

Let's start with the lowest level that they ultimately all are based on:

textColor: ThemeData.estimateBrightnessForColor(color) == Brightness.dark ? Colors.white  : Colors.black,

The static function estimateBrightnessForColor(color) in the Flutter SDK's ThemeData class returns the enum value Brightness.dark if the passed in color is one that is considered dark, which means a light text color, typically white, w…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by rydmike
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question This issue is a usage question and will be moved to the Discussions section.
2 participants
Converted from issue

This discussion was converted from issue #10 on April 06, 2022 01:16.