3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Flutter] 背景色によって前景色を良い感じに変えたい

Posted at

動的に背景色を変えていて、たとえば薄い黄色の背景なら黒っぽい前景、赤い背景なら白っぽい前景にしたい、という場合に。

  bool shouldUseWhiteForeGround(Color color) {
    return color.computeLuminance() < 0.4;
  }

Luminance というのは輝度の事です。これを使って判定すると良さげです。計算式はお好みで調整してください。

image.png

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?