[toc]
组件设计规范
为了统一,各视图分别使用如下组件
一、样式设计规范
在第六章进阶Flutter控件的封装一文中,我们已经知道使用继承父类式封装
这种方式,不管在封装时候,还是在使用时候,写的代码都是最简洁的。而且后期如果要直接使用系统样式,也只需要改回类名,其他结构和属性都不用动即可。
所以,即使是你所定义的类只有一个入参,也一定要遵守使用继承父类式封装
的设计规范。
以下以按钮中 textStyle 的传值为例:
1 2 3 4 5 6 7 8 9 10 11 12 13
| import 'package:flutter_baseui_kit/flutter_baseui_kit.dart';
ThemeBGButton( bgColorType: ThemeBGType.pink, title: '红底白字的按钮', titleStyle: ButtonBoldTextStyle(fontSize: 18.0), cornerRadius: 20, onPressed: () {}, ),
|
good:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| import 'package:flutter/material.dart';
class ButtonMediumTextStyle extends TextStyle { final double fontSize;
ButtonMediumTextStyle({ @required this.fontSize, }) : assert(fontSize != null), super( fontFamily: 'PingFang SC', fontSize: fontSize, fontWeight: FontWeight.w500, ); }
|