[英]Flutter GetX Custom Theme for Button
我已经像这样编写了我的自定义主题并将其存储在 Get storage 中。
class Themes {
static final lightTheme = ThemeData(
brightness: Brightness.light,
colorScheme: const ColorScheme.light(),
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
textStyle: TextStyle(
color: CustomColor.lightLandingScreenTextColor,
),
),
),
);
static final darkTheme = ThemeData(
brightness: Brightness.dark,
colorScheme: const ColorScheme.dark(),
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
backgroundColor: Colors.red,
textStyle: TextStyle(
color: CustomColor.darkLandingScreenTextColor,
),
),
),
);
}
然后我尝试像这样在我的轮廓按钮上应用我的轮廓按钮主题
SizedBox(
height: 48.h,
width: 155.w,
child: OutlinedButton(
onPressed: () {},
child: Text("SKIP"),
style: OutlinedButton.styleFrom(),
),)
我也尝试像这样分配主题,但这给了我一个错误。
现在如何在我的按钮中分配自定义按钮主题? 我正在使用 GetX 进行 state 管理。
尝试像这样使用
style: context.theme.outlinedButtonTheme.style
您正在尝试在参数类型“ButtonStyle”中添加OutlinedButtonThemeData
'ButtonStyle?'
这就是为什么给出错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.