Flutter Zeplin 代码生成器扩展?

Zeplin 的 Flutter dart 代码生成器。例如:Container、Text、Color、TextStyle 等 - 节省您的时间。⬇ 1.1k

入门

extensions.zeplin.io 将扩展添加到您的项目中。

特点

Text 组件

RichText 组件

Container 组件

BoxDecoration

BoxShadow

Border

TextStyle

StrutStyle

✅ Material 颜色名称

  • [ ] LinearGradient
  • [ ] RadialGradient

关键点

dartfmt (dart_style)

生成的代码格式尽可能设置为 dartfmt(dart_style)
您无需重新格式化生成的代码。

选项

preferences

您可以通过 许多选项 以您想要的格式进行设置。

例如:选项:使用颜色名称 ✅

Color(0xffffffff) /// ❌
Colors.white /// ⭕️

示例输出

Colors (项目)

class ZeplinColors {
   static const Color red = Color(0xffff0000);
   static const Color green = Color(0xff00ff00);
   static const Color yellow = Color(0xffffff00);
   static const Color white = Color(0xffffffff);
}

Container - 带阴影的图层

Container(
   height: 100,
   margin: EdgeInsets.only(
      left: 50,
      right: 50,
   ),
   decoration: BoxDecoration(
      boxShadow: [
         BoxShadow(
            color: ZeplinColors.black50,
            offset: Offset(0, 2),
            blurRadius: 4,
            spreadRadius: 6,
         ),
      ],
   ),
),

Text - 文本图层

Text('Type something',
   style: TextStyle(
      color: ZeplinColors.black,
      fontSize: 20,
      fontFamily: 'SFProText',
   ),
),

RichText - 具有多种样式的文本图层

RichText(
   text: TextSpan(
      children: [
         TextSpan(
            text: 'Type',
            style: TextStyle(
               color: ZeplinColors.black,
               fontSize: 20,
               fontFamily: 'SFProText',
               fontWeight: FontWeight.w500,
            ),
         ),
         TextSpan(
            text: 'something',
            style: TextStyle(
               color: ZeplinColors.black,
               fontSize: 20,
               fontFamily: 'SFProText',
            ),
         ),
         TextSpan(
            text: 'red',
            style: TextStyle(
               color: ZeplinColors.red,
               fontSize: 20,
               fontFamily: 'SFProText',
            ),
         ),
      ],
   ),
),

选项

描述 默认值 示例
颜色类名缀 Zeplin class ZeplinColors
使用颜色名称 Color(0xffffffff) => ZeplinColors.white
文本类名缀 Text => CustomText
TextStyle 类名缀 Zeplin class ZeplinTextStyles
使用文本样式名称 ZeplinTextStyles.title
跳过默认值 FontWeight.w400, FontStyle.normal
跳过 Container 的宽度 Container(width: 120)
跳过 Container 的高度 Container(height: 120)
跳过 Container 的左右边距 Container(margin: EdgeInsets.only(left: 20, right: 20)
跳过 TextStyle 的字体系列 AppleSDGothicNeo,HelveticaNeue (* : 所有字体)
跳过 TextStyle 的字间距 TextStyle(letterSpacing: 1.2)
跳过 TextStyle 的行高 TextStyle(height: 1.2)
跳过 Text 的 StrutStyle Text('',strutStyle: StrutStyle())

GitHub

https://github.com/naver/zeplin-flutter-gen