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),),
              ),
    
            ],
          ),
        );
    
      }
    }
    
    

    总结

    暂无。

  • 相关阅读:
    Entity Framework 中Decimal字段长度设置方法
    DWZ框架的使用
    .net mvc之web开发体会
    ASP.NET MVC3.0中同一View如何返回多个Model或数据集
    html5中 viewport 的用法
    swagger-REST API
    Git 添加SSH 取消了输入帐号密码
    [转]并发insert情况下会发生重复的数据插入问题
    如何编写适用于Echarts Map的js文件
    [转]OpenLayers 3 自定义坐标系
  • 原文地址:https://www.cnblogs.com/parzulpan/p/12118811.html
Copyright © 2011-2022 走看看