Buttons - flutter

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class Time extends StatefulWidget {
  @override
  _TimeState createState() => _TimeState();
}

class _TimeState extends State<Time> {
  @override
  Widget build(BuildContext context) {
    return Container(
      child:Column(
        children: [
          Row(
            children: [
              Expanded(
                flex: 4,
                child: Container(
                  //改变 Container的宽高,RaisedButton会跟随改变
                  //在没有Container的情况下, RaisedButton会随着 Expanded 的大小而改变, Expanded 默认填充整个Row
                  //   height: 50,
                  //   height: 50,
                    child:RaisedButton(
                        child: Text("What ?"),
                        color: Colors.pink,
                        textColor: Colors.white,
                        elevation: 10, //很轻的阴影效果
                        onPressed: (){
                          print("what onpress.");
                        }
                    )
                ),
              ),
              Expanded(
                flex: 2,
                //带图标的按钮
                child: RaisedButton.icon(
                  onPressed: (){},
                  icon:Icon(Icons.home),
                  label: Text("点我"),
                  color: Colors.deepOrangeAccent,
                  textColor: Colors.white,
                  elevation: 10, //阴影
                  //圆角
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(50)
                  ),
                ),
              ),
            ],
          ),

          Container(
            height: 100,
            width: 100,
            child: RaisedButton.icon(
              onPressed: (){},
              icon:Icon(Icons.home),
              label: Text("点我"),
              color: Colors.deepOrangeAccent,
              textColor: Colors.white,
              elevation: 10, //阴影
              splashColor: Colors.blue, //被点击时水波纹动画效果
              // shape 翻译为形状, 这是原型的RaiseButton
              shape: CircleBorder(
                  side: BorderSide(
                      color: Colors.orange
                  )
              ),
            ),
          ),
          //扁平按钮, 默认无边框, 用法和RaisedButton 一致
          FlatButton(
              onPressed: (){},
              child: Text("无边框按钮"),
              // color: Colors.orange,
          ),
          //有边框按钮, 用法和RaiseButton 一致
          OutlineButton(
            onPressed: (){},
            child: Text("有边框按钮"),
          ),
          IconButton(icon: Icon(Icons.home), onPressed: (){
            print("1");
          }),
          //一组按钮
          ButtonBar(
            alignment: MainAxisAlignment.center,
            children: [
              RaisedButton(
                  child: Text("What ?"),
                  color: Colors.pink,
                  textColor: Colors.white,
                  elevation: 10, //很轻的阴影效果
                  onPressed: (){
                    print("what onpress.");
                  }
              ),
              RaisedButton(
                  child: Text("What ?"),
                  color: Colors.pink,
                  textColor: Colors.white,
                  elevation: 10, //很轻的阴影效果
                  onPressed: (){
                    print("what onpress.");
                  }
              ),
              RaisedButton(
                  child: Text("What ?"),
                  color: Colors.pink,
                  textColor: Colors.white,
                  elevation: 10, //很轻的阴影效果
                  onPressed: (){
                    print("what onpress.");
                  }
              ),

            ],

          ),
        ],
      ),
    );
  }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值