美文网首页
Flutter Widget--Container 学习

Flutter Widget--Container 学习

作者: KtYY | 来源:发表于2019-02-20 15:32 被阅读0次

    ---flutter:万物皆控件

    import 'package:flutter/material.dart';
    
    void main() => runApp(new MyApp());
    
    /*
    * Alignment
    * bottomCenter:下部居中对齐。
    * botomLeft: 下部左对齐。
    * bottomRight:下部右对齐。
    * center:纵横双向居中对齐。
    * centerLeft:纵向居中横向居左对齐。
    * centerRight:纵向居中横向居右对齐。
    * topLeft:顶部左侧对齐。
    * topCenter:顶部居中对齐。
    * topRight: 顶部居左对齐
    * */
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return new MaterialApp(
          title: "Container Widget",
          home: Scaffold(
              appBar: AppBar(title: Text("Container Widget")),
              body: Center(
                child: Container(
                  child: Text("A Child Text",
                      style: TextStyle(fontWeight: FontWeight.bold)),
                  // 容器子内容的对齐方式,并不是容器本身的对齐方式
                  alignment: Alignment.bottomLeft,
                  // 容器宽度 float
                  width: 500.0,
                  // 容器高度 float
                  height: 200.0,
    //              padding: const EdgeInsets.all(30.0), // 内边距
                  padding: EdgeInsets.fromLTRB(20.0, 50.0, 20.0, 50.0),
                  // 外边距
                  margin: const EdgeInsets.all(30.0),
                  // 背景颜色
    //              color: Colors.lightGreen,
                  // container 的修饰器,主要的功能是设置背景和边框
                  decoration: new BoxDecoration(
                    // 纯色
    //                color: Colors.lightGreen,
                    // 渐变色
                    gradient: LinearGradient(colors: [Colors.red, Colors.green, Colors.blue]),
                    // 边框
                    border: Border.all(color: Colors.yellow, width: 4.0)
                  ),
    
                ),
              )),
        );
      }
    }
    
    
    图片.png

    相关文章

      网友评论

          本文标题:Flutter Widget--Container 学习

          本文链接:https://www.haomeiwen.com/subject/vdyhyqtx.html