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
复制代码
藏扇仙:
...扬灰。
属性 | 属性类型 |
---|---|
foregroundDecoration | Decoration |
padding | EdgeInsetsGeometry |
margin | EdgeInsetsGeometry |
transform | Matrix4 |
alignment | AlignmentGeometry |
decoration | Decoration |
constraints | BoxConstraints |
child | Widget |
气劲回流,扇仙一口呕红,卧倒在地。捷特:
师傅,你感觉如何?
藏扇仙:无碍,这一式,你看得如何?
捷特:这招太厉害了,不过不瞒您说……刚才风大,沙子迷眼了,没看清。
”
此时远处渐现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大将,捷特应战,便出一招挫骨扬灰
属性 | 属性类型 |
---|---|
textBaseline | TextBaseline |
backgroundColor | Color |
decorationStyle | TextDecorationStyle |
color | Color |
wordSpacing | double |
decorationThickness | double |
letterSpacing | double |
foreground | Paint |
fontStyle | FontStyle |
locale | Locale |
decorationColor | Color |
fontFamily | String |
_package | String |
background | Paint |
inherit | bool |
fontSize | double |
debugLabel | String |
decoration | TextDecoration |
fontWeight | FontWeight |
height | double |
Text上阵,捷特应战,一招挫骨扬灰
属性 | 属性类型 |
---|---|
softWrap | bool |
data | String |
textAlign | TextAlign |
semanticsLabel | String |
textWidthBasis | TextWidthBasis |
locale | Locale |
textDirection | TextDirection |
textScaleFactor | double |
overflow | TextOverflow |
strutStyle | StrutStyle |
maxLines | int |
textSpan | InlineSpan |
style | TextStyle |
捷特:师傅,我似领悟了要诀,不知是否可以直攻widgets大本营,一举歼灭?
藏扇仙:你看这,火候欠佳,这渣子不太纯正,你还差得远呢。
捷特:那第五式呢?
藏扇仙:学会第五式-七进七出,你倒可以到Flutter的SDK找到widgets大本营,
通过文件的循环读取,来个火烧连营,一举歼灭。
复制代码
后记
1----本文由张风捷特烈原创,转载请注明
2----如果有什么想要交流的,欢迎留言。也可以加微信:zdl1994328
3----个人能力有限,如有不正之处欢迎大家批评指证,必定虚心改正
4----看到这里,我在此感谢你的喜欢与支持,扫码关注-编程之王