Futter基础第14篇: 中的按钮组件 RaisedButton、FlatButton、OutlineButton、IconButton、ButtonBar以及自定义按钮组件
效果图:
import 'package:flutter/material.dart';class ButtonDemoPage extends StatelessWidget {@overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text('按钮演示页面'),actions: <Widget>[IconButton( //图标按钮icon: Icon(Icons.settings),onPressed: (){},)],),body: Column(mainAxisAlignment: MainAxisAlignment.center, //垂直居中children: <Widget>[Row(mainAxisAlignment: MainAxisAlignment.center, //水平居中children: <Widget>[RaisedButton(child: Text('普通按钮'),onPressed: (){print('普通按钮');},),SizedBox(width: 10,),RaisedButton(child: Text('颜色按钮'),color: Colors.blue, //背景颜色textColor: Colors.white, //字体白色onPressed: (){print('颜色按钮');},),SizedBox(width: 10,),RaisedButton(child: Text('阴影按钮'),color: Colors.blue, //背景颜色textColor: Colors.white, //字体白色elevation: 10, //设置阴影效果,值越大阴影效果越好onPressed: (){print('阴影按钮');},),],),RaisedButton.icon(
// onPressed: null,icon: Icon(Icons.search),label: Text('图标按钮'),color: Colors.blue,textColor: Colors.white,onPressed: (){print('图标按钮');},),SizedBox(height: 5,),Row(mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[Container( //利用容器来设置按钮的宽度和高度height: 50,width: 300,child: RaisedButton(child: Text('宽度高度'),color: Colors.blue,textColor: Colors.white,elevation: 20,onPressed: (){print('宽度高度');},),)],),SizedBox(height: 5,),Row(mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[Expanded( //铺满屏幕宽度child: Container( //利用容器设置高度height: 80,margin: EdgeInsets.all(10), //设置:左右间距10child: RaisedButton(child: Text('自适应按钮'),color: Colors.blue,textColor: Colors.white,elevation: 20,onPressed: (){print('自适应按钮');},),))],),SizedBox(height: 10,),Row(mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[RaisedButton(child: Text('圆角按钮'),color: Colors.blue,textColor: Colors.white,elevation: 20,shape: RoundedRectangleBorder( //圆角按钮borderRadius: BorderRadius.circular(10) //圆角弧度),onPressed: (){print('圆角按钮');}),SizedBox(width: 10,),Container(height: 80, //设置:高度、也可以理解为直径child: RaisedButton(child: Text('圆形按钮'),color: Colors.blue,textColor: Colors.white,elevation: 20,splashColor: Colors.red, //设置长按按钮时,水波纹颜色shape: CircleBorder( //圆角按钮side: BorderSide(color: Colors.white)),onPressed: (){print('圆形按钮');}),),FlatButton( //扁平按钮,默认是没有阴影,而且默认也没有背景颜色child: Text('扁平按钮'),color: Colors.blue,textColor: Colors.yellow,onPressed: (){print('扁平化按钮');},)],),SizedBox(height: 10,),OutlineButton( //带边框按钮child: Text('边框按钮'),
// color: Colors.red, 没有效果,这就是边框按钮的特性,不仅自带边框,还无法设置它的背景颜色,我猜可能是作者怕设置的背景颜色跟边框颜色一致
// textColor: Colors.yellow, //有效果onPressed: (){print('边框按钮');},),SizedBox(height: 5,),Row(mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[Expanded( //自适应水平平铺child: Container(margin: EdgeInsets.all(20), //上下左右分别间距 20height: 50,child: OutlineButton(child: Text('注册'),onPressed: (){},),),)],),Row(mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[ButtonBar(children: <Widget>[RaisedButton(child: Text('登录'),color: Colors.blue,textColor: Colors.white,elevation: 20,onPressed: (){print('登录');},),RaisedButton(child: Text('注册'),color: Colors.blue,textColor: Colors.white,elevation: 20,onPressed: (){print('注册');},),MyButton(text:'自定义按钮',height: 60.0,width: 100,pressed: (){print('自定义按钮');})],)],)],),);}
}//自定义按钮组件class MyButton extends StatelessWidget {final text;final pressed;final double width;final double height;const MyButton({this.text="",this.pressed=null,this.width=80.0,this.height=30.0});@overrideWidget build(BuildContext context) {return Container(height: this.height,width: this.width,child: RaisedButton(child: Text(this.text),onPressed: this.pressed,),);}
}
Futter基础第14篇: 中的按钮组件 RaisedButton、FlatButton、OutlineButton、IconButton、ButtonBar以及自定义按钮组件相关推荐
- Futter基础第3篇: 实现引用远程图片、本地图片、实现圆形图片,实现圆角图片【Image.network、Image.asset、BorderRadius.circular(150)】
文章目录 一丶 效果图 二丶 代码+注释 三丶 知识点 一丶 效果图 [1]引用远程图片 [2]引用本地图片 [3]实现圆形图片(方法一).圆角图片(受弧度影响) [4]实现圆形图片(方法二) 二丶 ...
- 用仿ActionScript的语法来编写html5——第七篇,自定义按钮
第七篇,自定义按钮 这次弄个简单点的,自定义按钮. 其实,有了前面所定义的LSprite,LBitmap等类,定义按钮就很方便了. 下面是添加按钮的代码, function gameInit(even ...
- 按钮配置之自定义按钮使用(一)——JEPLUS软件快速开发平台
为什么80%的码农都做不了架构师?>>> JEPLUS按钮配置之自定义按钮使用(一) 系统开发过程中无论是表单的默认按钮或是列表的默认按钮以及Action的默认按钮有时候并不能 ...
- qt自定义按钮类,每个按钮自带一个右键弹出框,如何使同一时刻只显示一个弹出框
提要 继承于QPushButton的自定义按钮类,其右键弹出一个弹框,创建多个这样的自定义按钮在窗口中,每一时刻只显示一个右键弹出框,避免同一时刻,多个按钮右键弹出弹出框后,未及时关闭弹出框导致的同一 ...
- Android自定义按钮样式
安卓系统自带的按钮样式很不好看,满足不了感官需求,如何自定义一个自己需要的按钮样式呢? 分三步来介绍: 1.自定义按钮背景样式,在res/drawable/目录下新建bg_btn.xml文件. < ...
- Python 与 Office 办公软件专栏目录:14 篇博客从基础到实例,助力你的自动化办公梦
Python 与 Office 办公软件专栏目录 前言: Python 与 Excel 文章一:用 xlwt 将数据写入Excel文件简介 文章二:xlwt 工作表对象常用设置 文章三:xlwt 设置 ...
- 【HTML 教程系列第 14 篇】什么是 HTML 中的有序列表 ol
这是[HTML 教程系列第 14 篇],如果觉得有用的话,欢迎关注专栏. 在 HTML 中,列表共分为三种,分别是 有序列表,无序列表 和 定义列表 . 本篇博客介绍第一种:有序列表 文章目录 一:什 ...
- JavaScript 基础知识 - DOM篇(二)
7. 节点操作 7.1 节点的属性 节点分类: 标签节点 文本节点 属性节点 注释节点 节点常用的属性: nodeType:节点的类型 nodeName:节点名称 nodeValue:节点值 常见的节 ...
- HTML(html5)-----学习(基础笔记总结篇)
-预备内容:-软件安装篇 1.记笔记工具----typroa 文件名:为了区分计算机中的不同文件,而给每个文件设定一个指定的名称.由基本文件名(文件主名)和扩展名组成. eg:SDN.docx 销售统 ...
- 《精通QTP——自动化测试技术领航》—第1章1.5节QTP精华—对象库(上)之基础攻略篇...
本节书摘来自异步社区<精通QTP--自动化测试技术领航>一书中的第1章1.5节QTP精华-对象库(上)之基础攻略篇,作者余杰 , 赵旭斌,更多章节内容可以访问云栖社区"异步社区& ...
最新文章
- SLAM中大场景下室内外区域的地图管理方法
- python使用imbalanced-learn的TomekLinks方法进行下采样处理数据不平衡问题
- wordpress 自定义删除后台管理菜单
- oracle第一次使用语句创建作业失败记
- mysql zrm 配置_利用MySQL-zrm来备份和恢复MySQL数据库方法详解
- Makefile中几种赋值
- 阿帕奇跨域_阿帕奇骆驼遇见Redis
- 工作188:表单校验规则
- 一步步编写操作系统 15 CPU与外设通信——IO接口,下
- (王道408考研操作系统)第二章进程管理-第三节3:实现进程互斥的硬件方法
- VMware中安装deepin虚拟机
- iOS 图形编程总结
- 《精通.Net核心技术》
- 学一门计算机语言大体的过程,学习一门新编程语言的6个步骤
- 吴恩达深度学习——人脸识别与神经风格转换
- Win10系统安装失败?用这种方法一键就解决了
- (附源码)计算机毕业设计SSM基于大数据的高校国有固定资产管理及绩效自动评价系统
- Information:java: Errors occurred while compiling module
- c语言n个自然数得阶乘求和,计算n个自然数阶乘的和
- Microsoft.Office.Interop.Word 创建word