跳至主要內容

widget

chanchaw小于 1 分钟flutter

作用介绍

  • 填充满父组件 - Positioned.fill(child: Image.asset('images/login-bg1.jpg',fit: BoxFit.cover)) 表格将其 child 下的 widget 调整宽高使其充满父组件,可用于充满屏幕
  • 添加蒙层 - 下面代码中第二个元素使用 Positioned.fill 为前面一个元素添加蒙层
  _background() {
    return [
      Positioned.fill(child: Image.asset('images/login-bg1.jpg',fit: BoxFit.cover)),
      // 为上面一个元素添加蒙层
      Positioned.fill(child: Container(decoration: const BoxDecoration(color: Colors.black54)))
    ];
  }

布局

单子元素

Container


xxx

Center


xxx

Align


xxx

FractionallySizeBox


xxx

SizedBox


xxx

FittedBox


xxx

ConstrainedBox


xxx

OverflowBox


xxx

AspectRatio


xxx

Offstage


xxx

多子元素

Row


xxx

Column


xxx

Stack


xxx

IndexedStack


xxx

Flow


xxx

Table


xxx

Wrap


xxx

ListBody


xxx

文本

Text


xxx

RichText


xxx

可滚动的

ListView


xxx

GridView


xxx

NestedScrollView


xxx

CustomScrollView


xxx

绘制和效果

Opacity


xxx

Transform


xxx

ClipOval


xxx

DecorateBox


xxx

FractionalTranslation


xxx

RotatedBox


xxx

ClipPath


xxx

ClipRect


xxx

CustomPaint


xxx

BackdropFilter


xxx

图片和资产

Image


xxx

Icon


xxx

RawImage


xxx

AssetBundle


xxx

样式

Padding


xxx

Theme


xxx

MediaQuery


xxx