Container

介绍

Container 容器控件,包含一个子Widget,具备alignment、padding等属性,方便布局摆放child

类结构

属性

child

子控件

alignment

对齐方式

 /// The top left corner.
  static const Alignment topLeft = Alignment(-1.0, -1.0);
  /// The center point along the top edge.
  static const Alignment topCenter = Alignment(0.0, -1.0);
  /// The top right corner.
  static const Alignment topRight = Alignment(1.0, -1.0);
  /// The center point along the left edge.
  static const Alignment centerLeft = Alignment(-1.0, 0.0);
  /// The center point, both horizontally and vertically.
  static const Alignment center = Alignment(0.0, 0.0);
  /// The center point along the right edge.
  static const Alignment centerRight = Alignment(1.0, 0.0);
  /// The bottom left corner.
  static const Alignment bottomLeft = Alignment(-1.0, 1.0);
  /// The center point along the bottom edge.
  static const Alignment bottomCenter = Alignment(0.0, 1.0);
  /// The bottom right corner.
  static const Alignment bottomRight = Alignment(1.0, 1.0);

color 和 decoration

设置背景色或背景

  • 两者无法共存
    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),

foregroundDecoration

前景设置

margin

边距设置

constraints

布局约束

transform

矩阵变换


 上一篇
Padding&Align&Center Padding&Align&Center
Padding Padding可以给其子节点添加补白(填充) 定义Padding({ ... EdgeInsetsGeometry padding, Widget child, }) EdgeInsetsGeometry是一个
2019-02-26
下一篇 
Stack&Positioned Stack&Positioned
层叠布局层叠布局和Web中的绝对定位、Android中的Frame布局是相似的,子widget可以根据到父容器四个角的位置来确定本身的位置。绝对定位允许子widget堆叠(按照代码中声明的顺序)。Flutter中使用Stack和Positi
2019-02-26
  目录