zoukankan      html  css  js  c++  java
  • 【Flutter】容器类组件之填充

    前言

    Padding可以给其子节点添加填充(留白)。

    接口描述

    class EdgeInsets extends EdgeInsetsGeometry {
      // 分别指定四个方向的填充
      const EdgeInsets.fromLTRB(this.left, this.top, this.right, this.bottom);
      // 所有方向均使用相同数值的填充
      const EdgeInsets.all(double value)
        : left = value,
          top = value,
          right = value,
          bottom = value;
      // 可以设置具体某个方向的填充(可以同时指定多个方向)。
      const EdgeInsets.only({
        this.left = 0.0,
        this.top = 0.0,
        this.right = 0.0,
        this.bottom = 0.0,
      });
      // 用于设置对称方向的填充,vertical指top和bottom,horizontal指left和right。
      const EdgeInsets.symmetric({
        double vertical = 0.0,
        double horizontal = 0.0,
      }) : left = horizontal,
           top = vertical,
           right = horizontal,
           bottom = vertical;
    
    

    代码示例

    // 填充(padding)
    
    
    import 'package:flutter/material.dart';
    
    class PaddingTestRoute extends StatelessWidget {
    
      @override
      Widget build(BuildContext context) {
        return Padding(
          // 上下左右各添加16像素补白
          padding: EdgeInsets.all(16.0),
          child: Column(
            // 显式指定对齐方式为左对齐,排除对齐干扰
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Padding(
                // 左边添加8像素补白
                padding: const EdgeInsets.only(left: 8.0),
                child: Text('Hello world',style: TextStyle(color: Colors.blue),),
              ),
              Padding(
                //
                padding: EdgeInsets.symmetric(vertical: 8.0),
                child: Text('I am Hah',style: TextStyle(color: Colors.yellow),),
              ),
              Padding(
                // 分别指定四个方向的补白
                padding: EdgeInsets.fromLTRB(20.0, 20.0, 20.0, 20.0),
                child: Text('Your Dear',style: TextStyle(color: Colors.red),),
              ),
    
            ],
          ),
        );
    
      }
    }
    
    

    总结

    暂无。

  • 相关阅读:
    K8s中Secrets
    记一次kubernetes配置secret拉取私仓镜像错误
    K8S中ConfigMap
    阿里云RDSforMySQL如何定位本地IP
    Python3运算符
    nyoj 67-三角形面积 (海伦公式, 叉积)
    nyoj 66-分数拆分 (Java,暴力)
    nyoj 65-另一种阶乘问题 (Java 高精度)
    nyoj 64-鸡兔同笼 (解二元一次方程)
    nyoj 63-小猴子下落 (模拟)
  • 原文地址:https://www.cnblogs.com/parzulpan/p/12118811.html
Copyright © 2011-2022 走看看