为了账号安全,请及时绑定邮箱和手机立即绑定

正则十八式-第四式 挫骨扬灰

Flutter大军来到,Container战将率领字符大军来到,师徒二人渐入绝境。

class Container extends StatelessWidget { 

 /// Creates a widget that combines common painting, positioning, and sizing widgets.  ///  

/// The `height` and `width` values include the padding.  ///  

/// The `color` argument is a shorthand for `decoration: new  /// 

BoxDecoration(color: color)`, which means you cannot supply both a `color`  

/// and a `decoration` argument. If you want to have both a `color` and a 

/// `decoration`, you can pass the color as the `color` argument to the

 /// `BoxDecoration`.  Container({    

Key key,    this.alignment,    this.padding,    Color color,    Decoration decoration,    this.foregroundDecoration,    double width,    double height,    BoxConstraints constraints,    

this.margin,    this.transform,    this.child,  }) : assert(margin == null || margin.isNonNegative),       assert(padding == null || padding.isNonNegative),       

assert(decoration == null || decoration.debugAssertIsValid()),       

assert(constraints == null || constraints.debugAssertIsValid()),       

assert(color == null || decoration == null,         

'Cannot provide both a color and a decoration\n'         

'The color argument is just a shorthand for "decoration: new BoxDecoration(color: color)".'       ),       decoration = decoration ?? (color != null ? BoxDecoration(color: color) : null),      

 constraints =        (width != null || height != null)         

 ? constraints?.tighten(width: width, height: height)            

?? BoxConstraints.tightFor(width: width, height: height)          : constraints,       super(key: key);  

/// The [child] contained by the container.  ///  

/// If null, and if the [constraints] are unbounded or also null, the 

  /// container will expand to fill all available space in its parent, unless  

/// the parent provides unbounded constraints, in which case the container  

/// will attempt to be as small as possible.  ///  

/// {@macro flutter.widgets.child}  final Widget child;  

/// Align the [child] within the container.  ///

  /// If non-null, the container will expand to fill its parent and position its  /// 

child within itself according to the given value. If the incoming  

/// constraints are unbounded, then the child will be shrink-wrapped instead.  /// 

  /// Ignored if [child] is null.  ///  

/// See also:  ///  

///  * [Alignment], a class with convenient constants typically used to  

///    specify an [AlignmentGeometry]. 

  ///  * [AlignmentDirectional], like [Alignment] for specifying alignments 

 ///    relative to text direction.  final AlignmentGeometry alignment;  

/// Empty space to inscribe inside the [decoration]. The [child], if any, is  

/// placed inside this padding.  /// 

  /// This padding is in addition to any padding inherent in the [decoration];  

/// see [Decoration.padding].  final EdgeInsetsGeometry padding;  

/// The decoration to paint behind the [child].  ///  

/// A shorthand for specifying just a solid color is available in the  

/// constructor: set the `color` argument instead of the `decoration`  

/// argument.  ///  

/// The [child] is not clipped to the decoration. To clip a child to the shape  

/// of a particular [ShapeDecoration], consider using a [ClipPath] widget.  final Decoration decoration;  /// The decoration to paint in front of the [child].  final Decoration foregroundDecoration;  

/// Additional constraints to apply to the child.  /// 

  /// The constructor `width` and `height` arguments are combined with the  

/// `constraints` argument to set this property.  /// 

  /// The [padding] goes inside the constraints.  final BoxConstraints constraints;  

/// Empty space to surround the [decoration] and [child].  final EdgeInsetsGeometry margin; 

  /// The transformation matrix to apply before painting the container.  final Matrix4 transform;

庙外,Container自报家门:吾乃Widget家族战将,Container,扇仙老儿速来一战。
捷特凌然出战,道一句:呔,吾师名号岂容汝等污秽。出手便是一招龙跃于渊,将对手团团围住,正在升龙之时。
Container一笑:这招不差,可惜火候不足 。仅一挣,就破了这招。

藏扇仙出,bgm起,以心传心:徒儿,为师现在深中灵蛛之毒,气力不济,这第四式也只能使出八成威力,而且只能使用一次。你能学到什么程度,还要看你造化。
只见庙前,藏扇仙身发蓝光,纳天地灵气,运气于掌,一时间飞沙走石,
呵道:正则十八式,第四式-挫骨... 雷电交加,天地共震,container瞬间粉身碎骨,留下了一堆渣渣。

Widget---child 

AlignmentGeometry---alignment 

EdgeInsetsGeometry---padding 

Decoration---decoration 

Decoration---foregroundDecoration 

BoxConstraints---constraints 

EdgeInsetsGeometry---margin Matrix4---transform

藏扇仙:...扬灰。

属性属性类型
foregroundDecorationDecoration
paddingEdgeInsetsGeometry
marginEdgeInsetsGeometry
transformMatrix4
alignmentAlignmentGeometry
decorationDecoration
constraintsBoxConstraints
childWidget

气劲回流,扇仙一口呕红,卧倒在地。捷特:师傅,你感觉如何? 藏扇仙:无碍,这一式,你看得如何? 捷特:这招太厉害了,不过不瞒您说……刚才风大,沙子迷眼了,没看清。
此时远处渐现Text大旗,藏扇仙:唉,天意啊,天意,如今追兵已至,吾命休矣。
捷特:师傅莫灰心,从这残骸中,您的气劲尚存,我似能领略一二。您将Container中的属性与类型分离出来

private static void regexWidget(String target) {   

Map<String,String> fieldMap= new HashMap();    

String regex="final (?<type>\\w*) (?<name>\\w*);";    

Pattern pattern = Pattern.compile(regex);    

Matcher matcher = pattern.matcher(target);    

while (matcher.find()){        

fieldMap.put(matcher.group("name"),matcher.group("type"));    }    

createTable(fieldMap); }

然后将分理处的碎片进行重组,成为markdowon的字符串

private static void createTable(Map<String,String> fieldMap) {    

String title="属性 | 属性类型\n";    

String syb="---|---\n";  StringBuilder sb=  new StringBuilder(title);  

sb.append(syb);    fieldMap.forEach((k,v)->{        

sb.append(k).append("|").append(v).append("\n");    });    

System.out.println(sb.toString()); }

藏扇仙:“说得不差,这挫骨扬灰重在一挫,一扬。将对方粉碎后,提取有用信息,进行重建。”

属性 | 属性类型 ---|--- 

foregroundDecoration|Decoration 

padding|EdgeInsetsGeometry 

margin|EdgeInsetsGeometry 

transform|Matrix4 alignment|AlignmentGeometry 

decoration|Decoration constraints|BoxConstraints child|Widget


Text来到,派出TextStyle大将,捷特应战,便出一招挫骨扬灰

属性属性类型
textBaselineTextBaseline
backgroundColorColor
decorationStyleTextDecorationStyle
colorColor
wordSpacingdouble
decorationThicknessdouble
letterSpacingdouble
foregroundPaint
fontStyleFontStyle
localeLocale
decorationColorColor
fontFamilyString
_packageString
backgroundPaint
inheritbool
fontSizedouble
debugLabelString
decorationTextDecoration
fontWeightFontWeight
heightdouble

Text上阵,捷特应战,一招挫骨扬灰

属性属性类型
softWrapbool
dataString
textAlignTextAlign
semanticsLabelString
textWidthBasisTextWidthBasis
localeLocale
textDirectionTextDirection
textScaleFactordouble
overflowTextOverflow
strutStyleStrutStyle
maxLinesint
textSpanInlineSpan
styleTextStyle

捷特:师傅,我似领悟了要诀,不知是否可以直攻widgets大本营,一举歼灭? 

藏扇仙:你看这,火候欠佳,这渣子不太纯正,你还差得远呢。 

捷特:那第五式呢? 

藏扇仙:学会第五式-七进七出,你倒可以到Flutter的SDK找到widgets大本营, 

通过文件的循环读取,来个火烧连营,一举歼灭。


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
移动开发工程师
手记
粉丝
20
获赞与收藏
56

关注作者,订阅最新文章

阅读免费教程

  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消