扑动扩展ThemeData,添加颜色等



我试图扩展我的第一个应用程序使用的配色方案。我创建了一个单独的文件,其中包含以下内容:

import 'package:flutter/cupertino.dart';
class Testy extends CupertinoThemeData {
final Color bgws = Color.fromRGBO(120, 120, 120, 1);
}

然后将导入到Main中。但不知道如何使用我的新颜色。我以为Testy.bgws会这样做,但显然我错过了一些东西。

您可以使用默认的textTheme而不使用Cupertino像

final ThemeData appThemeLight = ThemeData(
/// theme
brightness: Brightness.light,

/// screen
primaryColor: Colors.blue,

/// brightness color
accentColor: Colors.white,

/// opacity color
hintColor: Colors.grey,

/// here you can add cupertino
cupertinoOverrideTheme: CupertinoThemeData(
primaryColor: Colors.black,
),
....

使用Theme.of(context)...

也不要忘记像theme: appThemeLight一样将appThemeLight添加到MaterialApp

最新更新