[英]How to change flutter text color for dark and light theme?
如何更改深色主题和浅色主题的颤动文本颜色,有人可以回答我吗?
title: Text('Kitchen Name', )
There are two ways of doing so:有两种方法:
theme
and a darkTheme
variance in your MaterialApp
properties and having it automatically changed whenever the OS theme changes, based on the text properties that you set;MaterialApp
属性中设置theme
和darkTheme
变化,并根据您设置的文本属性在操作系统主题更改时自动更改;Text
style's property (when the brightness is dark, the OS should be using a dark theme, and a light when it's light).Text
样式属性中的当前亮度(当亮度较暗时,操作系统应该使用深色主题,而在浅色时使用浅色)。title: Text(
'Kitchen Name',
style: Theme.of(context).brightness == Brightness.dark ? TextStyle(color: Colors.white) : TextStyle(color: Colors.black),
),
I'd pick the 1 since it's the most correct way of doing it.我会选择 1,因为它是最正确的做法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.