正則十八式-第四式 挫骨揚灰

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一笑:這招不差,惋惜火候不足 。僅一掙,就破了這招。bash

藏扇仙出,bgm起,以心傳心:徒兒,爲師如今深中靈蛛之毒,氣力不濟,這第四式也只能使出八成威力,並且只能使用一次。你能學到什麼程度,還要看你造化。
只見廟前,藏扇仙身發藍光,納天地靈氣,運氣於掌,一時間飛沙走石,
呵道:正則十八式,第四式-挫骨... 雷電交加,天地共震,container瞬間粉身碎骨,留下了一堆渣渣。微信

Widget---child
AlignmentGeometry---alignment
EdgeInsetsGeometry---padding
Decoration---decoration
Decoration---foregroundDecoration
BoxConstraints---constraints
EdgeInsetsGeometry---margin
Matrix4---transform
複製代碼

藏扇仙:...揚灰。app

屬性 屬性類型
foregroundDecoration Decoration
padding EdgeInsetsGeometry
margin EdgeInsetsGeometry
transform Matrix4
alignment AlignmentGeometry
decoration Decoration
constraints BoxConstraints
child Widget

氣勁迴流,扇仙一口嘔紅,臥倒在地。捷特:師傅,你感受如何? 藏扇仙:無礙,這一式,你看得如何? 捷特:這招太厲害了,不過不瞞您說……剛纔風大,沙子迷眼了,沒看清。
此時遠處漸現Text大旗,藏扇仙:唉,天意啊,天意,現在追兵已至,吾命休矣。
捷特:師傅莫灰心,從這殘骸中,您的氣勁尚存,我似能領略一二。您將Container中的屬性與類型分離出來less

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的字符串ide

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());
}
複製代碼

藏扇仙:「說得不差,這挫骨揚灰重在一挫,一揚。將對方粉碎後,提取有用信息,進行重建。」post

屬性 | 屬性類型
---|---
foregroundDecoration|Decoration
padding|EdgeInsetsGeometry
margin|EdgeInsetsGeometry
transform|Matrix4
alignment|AlignmentGeometry
decoration|Decoration
constraints|BoxConstraints
child|Widget
複製代碼

Text來到,派出TextStyle大將,捷特應戰,便出一招挫骨揚灰ui

屬性 屬性類型
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上陣,捷特應戰,一招挫骨揚灰this

屬性 屬性類型
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----看到這裏,我在此感謝你的喜歡與支持,掃碼關注-編程之王spa

icon_wx_200.png
相關文章
相關標籤/搜索