Text在Flutter中是一个常用的控件,当每次编写一个文本时,我们需要写一大堆的样式,造成代码行数的增加,这里我简单的封装了一下Text。
1 定义一个class文件,里面可以是多个控件的封装,这里我们封装了Text控件。
class MBuilder{
static Text text(String text,{
double size = 16,Color color,FontWeight weight =FontWeight.normal,int line = 1,TextAlign align = TextAlign.start,TextDecoration decoration = TextDecoration.none,double letterSp = 1.0,bool soft = true,TextOverflow flow = TextOverflow.ellipsis,double h=1.5}){
return Text(text,style