【发布时间】:2022-01-19 15:34:07
【问题描述】:
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
const ColorScheme colorScheme = ColorScheme(
primary: Color.fromRGBO(48, 48, 48, 1),
primaryVariant: Color.fromRGBO(38, 38, 38, 1),
onPrimary: Colors.white,
secondary: Color.fromRGBO(232, 163, 72, 1),
secondaryVariant: Color.fromRGBO(168, 121, 59, 1),
onSecondary: Colors.white,
surface: Colors.white,
onSurface: Color.fromRGBO(48, 48, 48, 1),
background: Colors.white,
onBackground: Color.fromRGBO(48, 48, 48, 1),
error: Color.fromRGBO(214, 84, 84, 1),
onError: Colors.white,
brightness: Brightness.light,
);
const FloatingActionButtonThemeData fabTheme = FloatingActionButtonThemeData(
);
我正在为主题创建一个单独的 theme.dart 文件,并希望将所有主题保留在该文件中。
在这里,我想在FloatingActionButtonThemeData 中使用ColorScheme 中的颜色。我知道我只能在其祖先具有此方案的上下文中使用 ColorScheme。但是有没有办法实现我想要的?
【问题讨论】: