【发布时间】:2018-06-18 20:56:54
【问题描述】:
我为我的应用创建了以下主题:
ThemeData _buildDarkTheme() {
final baseTheme = ThemeData(fontFamily: "Sunflower",);
return baseTheme.copyWith(
brightness: Brightness.dark,
primaryColor: Colors.grey[800],
accentColor: Colors.grey[850]);
}
然后我将它应用到我的应用程序中,如下所示:
class MyApp extends StatelessWidget {
MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return new MaterialApp(
theme: _buildDarkTheme(),
home: new Scaffold(
appBar: _buildAppBar(),
body: new Container(
color: Theme.of(context).accentColor,
height: double.infinity,
child: new ListView.builder(...
但是,当我尝试访问容器内(或其他任何地方)的强调色而不是预期的 Colors.grey[850] 时,它默认为蓝色。另外,尝试使用自定义字体 Sunflower 字体系列不起作用,但是当我改为使用时
new Text("Hello World", style: new TextStyle(fontFamily: "Sunflower"))
字体显示正确。
我是 flutter 和 dart 的新手,所以如果能帮助解决这些问题,我们将不胜感激。
【问题讨论】: