我试着为文字风格制作一个应用程序主题.我从这个例子中得到了flutter docs个.
MaterialApp(
title: appName,
theme: ThemeData(
// Define the default brightness 和 colors.
brightness: Brightness.dark,
primaryColor: Colors.lightBlue[800],
// Define the default font family.
fontFamily: 'Georgia',
// Define the default `TextTheme`. Use this to specify the default
// text styling for headlines, titles, bodies of text, 和 more.
textTheme: const TextTheme(
displayLarge: TextStyle(fontSize: 72.0, fontWeight: FontWeight.bold),
titleLarge: TextStyle(fontSize: 36.0, fontStyle: FontStyle.italic),
bodyMedium: TextStyle(fontSize: 14.0, fontFamily: 'Hind'),
),
),
home: const MyHomePage(
title: appName,
),
);
和
Container(
color: Theme.of(context).colorScheme.secondary,
child: Text(
'Text with a background color',
style: Theme.of(context).textTheme.titleLarge,
),
),
我想要有选项来添加相同文本大小的多种 colored颜色 .例如,titleLarge
可以是红色或白色.
在TextTheme->;TextStyle中添加 colored颜色 只能提供添加一种 colored颜色 的选项.
有什么方法可以让我稍后在文本小部件中更改它吗?也许有一种方法可以覆盖Theme.of(context).textTheme.titleLarge
的 colored颜色 ?