[flutter] 容器组件

Center

Center容器用来居中widget

Dart 复制代码
const Center({
    Key key, 
    double widthFactor, // 若该值为空,该组件宽度会尽可能大;若不为空,该组件的宽度就是子节点宽度的多少倍
    double heightFactor, // 同widthFactor
    Widget child // 子组件
}) : super(key: key, widthFactor: widthFactor, heightFactor: heightFactor, child: child);

Padding

Dart 复制代码
Padding({
  EdgeInsetsGeometry padding,
  Widget child,
})

Margin

如果你想为列添加外边距,可以将列用 Container 组件包裹,并使用 margin 属性指定所需的外边距。

复制代码
Container(
  margin: EdgeInsets.all(16.0),
  child: Column(
    children: [
      Text('Hello'),
      Text('World'),
    ],
  ),
)

Reference

5.4 容器组件(Container) | 《Flutter实战·第二版》https://blog.csdn.net/qq_33635385/article/details/100079162

相关推荐
浮江雾7 小时前
Flutter第三节----Dart中的数据类型
android·开发语言·学习·flutter·入门·函数
又菜又爱coding7 小时前
Flutter Android 无线调试No supported devices connected
flutter
心中有国也有家9 小时前
AtomGit Flutter 鸿蒙客户端:初始化流水线
学习·flutter·华为·harmonyos
ZZZMMM.zip1 天前
基于鸿蒙HarmonyOS NEXT开发AI英语口语应用:智能口语练习新体验与鸿蒙Flutter框架跨端实
人工智能·flutter·华为·harmonyos·鸿蒙·鸿蒙系统
心中有国也有家1 天前
AtomGit Flutter 鸿蒙客户端:白噪音场景的视觉设计
学习·flutter·华为·harmonyos
心中有国也有家1 天前
AtomGit Flutter 鸿蒙客户端:呼吸练习的完整生命周期
学习·flutter·华为·harmonyos
心中有国也有家1 天前
AtomGit Flutter 鸿蒙客户端:呼吸球动画
学习·flutter·华为·harmonyos
心中有国也有家1 天前
AtomGit Flutter 鸿蒙客户端:呼吸练习的三种科学模式
学习·flutter·华为·harmonyos
yuanlaile1 天前
前端转 Flutter 自学完整规划,避开跨栈思维转换误区
前端·flutter·flutter跨平台开发
姑苏倾城客1 天前
Flutter中,html 与 dart 桥接沟通
javascript·flutter·html