我想使用一些构造函数(例如 Color 和 fontWeight)创建自定义 TextStyle,因此稍后在屏幕视图中字体和大小的样式是固定的,但只能自定义颜色和 fontweight,
class TextStyles {
final Color fontColor;
const TextStyles({
this.fontColor = Colors.black;
});
static const TextStyle buttonText = const TextStyle(
fontFamily: 'Montserrat',
color: fontColor,
fontWeight: FontWeight.w700,
fontSize: 14.0
);
}
class CustomButton extends StatelessWidget {
....
final Function onPressed;
const CustomButton({
Key key,
...
@required this.onPressed,
this.textSize = 14.0,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final CreateBlueButton = FlatButton(
color: background,
child: Text(
text,
style: TextStyleCustom,
)
);
return Container(
constraints: BoxConstraints.expand(height: …Run Code Online (Sandbox Code Playgroud)