22Flutter中的常见的按钮组件 以及自定义按钮组件
- /*
- Flutter中的常见的按钮组件 以及自定义按钮组件
- 一、Flutter中的按钮组件介绍
- Flutter里有很多的Button组件,常见的按钮组件有:RaisedButton/FlatButton/IconButton/
- OutlineButton/ButtonBar/FloatingActionButton等。
- RaisedButton:凸起的按钮,其实就是Material Design风格的Button
- FlatButton:扁平化的按钮
- OutlineButton:线框按钮
- IconButton:图标按钮
- ButtonBar: 按钮组
- FloatingActionButton:浮动按钮
- 二、Flutter按钮组件中的一些属性:
- onPressed:必填参数,按下按钮时触发的回调,接受一个方法,传null表示按钮禁用,会显示禁用相关样式
- child:文本控件
- textColor:文本颜色
- color:按钮的颜色
- disabledColor:按钮禁用时的颜色
- disabledTextColor:按钮禁用时的文本颜色
- splashColor:点击按钮时水波纹的颜色
- elevation:阴影的范围
- padding:内边距
- shape:设置按钮的形状
- */
Button.dart
- import 'package:flutter/material.dart';
- class ButtonDemoPage extends StatelessWidget {
- const ButtonDemoPage({Key key}) : super(key: key);
- @override
- Widget 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(
- children: <Widget>[
- RaisedButton(
- child: Text('普通'),
- onPressed: () {
- print('普通按钮');
- },
- ),
- SizedBox(width: ),
- RaisedButton.icon(
- icon: Icon(Icons.search),
- label: Text('图标'),
- onPressed: null,
- ),
- SizedBox(width: ),
- RaisedButton(
- child: Text('有颜色'),
- color: Colors.blue,
- textColor: Colors.white,
- onPressed: () {
- print('有颜色按钮');
- },
- ),
- SizedBox(width: ),
- RaisedButton(
- child: Text('有阴影'),
- color: Colors.blue,
- textColor: Colors.white,
- elevation: ,
- onPressed: () {
- print('有阴影按钮');
- }),
- ],
- ),
- SizedBox(height: ),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- height: ,
- width: ,
- child: RaisedButton(
- child: Text('宽度高度'),
- color: Colors.blue,
- textColor: Colors.white,
- elevation: ,
- onPressed: () {},
- ),
- )
- ],
- ),
- SizedBox(height: ),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Expanded(
- child: Container(
- height: ,
- margin: EdgeInsets.all(),
- child: RaisedButton(
- child: Text('自适应按钮'),
- color: Colors.blue,
- textColor: Colors.white,
- elevation: ,
- onPressed: () {
- print('自适应按钮');
- },
- ),
- ))
- ],
- ),
- SizedBox(height: ),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- RaisedButton(
- child: Text('圆角按钮'),
- color: Colors.blue,
- textColor: Colors.white,
- elevation: ,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular()),
- onPressed: () {
- print('圆角按钮');
- },
- ),
- RaisedButton(
- child: Text('圆形按钮'),
- color: Colors.blue,
- textColor: Colors.white,
- elevation: ,
- splashColor: Colors.grey,
- shape: CircleBorder(side: BorderSide(color: Colors.white)),
- onPressed: () {
- print('圆形按钮');
- },
- )
- ],
- ),
- FlatButton(
- //扁平化按钮:
- child: Text('扁平化的按钮'),
- color: Colors.blue,
- textColor: Colors.yellow,
- onPressed: () {},
- ),
- OutlineButton(
- child: Text('线框按钮'),
- onPressed: () {
- print('OutlineButton');
- },
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Expanded(
- child: Container(
- margin: EdgeInsets.all(),
- height: ,
- child: OutlineButton(
- child: Text('注册'),
- onPressed: () {},
- ),
- ),
- )
- ],
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- ButtonBar(
- //按钮组
- children: <Widget>[
- RaisedButton(
- child: Text('登录'),
- color: Colors.blue,
- textColor: Colors.white,
- onPressed: () {},
- ),
- RaisedButton(
- child: Text('注册'),
- color: Colors.blue,
- textColor: Colors.white,
- onPressed: () {},
- ),
- ],
- )
- ],
- ),
- MyButton(
- text: "自定义按钮",
- height: 60.0,
- width: 100.0,
- 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 = , this.height = });
- @override
- Widget build(BuildContext context) {
- return Container(
- height: this.height,
- width: this.width,
- child: RaisedButton(
- child: Text(this.text),
- onPressed: this.pressed,
- ),
- );
- }
- }
22Flutter中的常见的按钮组件 以及自定义按钮组件的更多相关文章
- echarts 显示下载按钮,echarts 自定义按钮,echarts 添加按钮
echarts 显示下载按钮,echarts 自定义按钮,echarts 添加按钮 >>>>>>>>>>>>>>&g ...
- #003 React 组件 继承 自定义的组件
主题:React组件 继承 自定义的 组件 一.需求说明 情况说明: 有A,B,C,D 四个组件,里面都有一些公用的逻辑,比如 设置数据,获取数据,有某些公用的的属性,不想在 每一个 组件里面写这些属 ...
- Flutter 中的常见的按钮组件 以及自定义按钮组件
Flutter 里有很多的 Button 组件很多,常见的按钮组件有:RaisedButton.FlatButton. IconButton.OutlineButton.ButtonBar.Float ...
- MIP组件开发 自定义js组件开发步骤
什么是百度MIP? MIP(Mobile Instant Pages - 移动网页加速器)主要用于移动端页面加速 官网参考:https://www.mipengine.org/doc/00-mip-1 ...
- 常用样式制作思路 自定义按钮~自适应布局~常见bug seajs简记 初学者必知的HTML规范 不容忽略的——CSS规范
常用样式制作思路 学习常用样式总结参考来自这里 带点文字链接列表利用:before实现 1 <!DOCTYPE html> 2 <html lang="en" ...
- 如何让antd的Modal组件的确认和取消不显示(或自定义按钮)(转载)
使用Modal中的footer属性,如下: <Modal title="更改成员" visible={visible} confirmLoading={confirmLoad ...
- PyQt(Python+Qt)学习随笔:Designer中的QDialogButtonBox增加自定义按钮的方法
在Qt Designer中可以预先定义标准按钮,相关支持的标准按钮请见<PyQt(Python+Qt)学习随笔:Designer中的QDialogButtonBox的StandardButton ...
- 基于React.js网页版弹窗|react pc端自定义对话框组件RLayer
基于React.js实现PC桌面端自定义弹窗组件RLayer. 前几天有分享一个Vue网页版弹框组件,今天分享一个最新开发的React PC桌面端自定义对话框组件. RLayer 一款基于react. ...
- iOS开发——UI进阶篇(十八)核心动画小例子,转盘(裁剪图片、自定义按钮、旋转)图片折叠、音量震动条、倒影、粒子效果
一.转盘(裁剪图片.自定义按钮.旋转) 1.裁剪图片 将一张大图片裁剪为多张 // CGImageCreateWithImageInRect:用来裁剪图片 // image:需要裁剪的图片 // re ...
随机推荐
- 脚本shell
vim删除以#,空格开头的行 1,删除以#号开头的行: :g/^#/d :%s/^#.*\n 2,删除以空格开头的行: :g/^\s/d “\s代表空格” :%s/^ ...
- Vue实现一个图片懒加载插件(转载)
Vue是可以自定义指令的,最近学习过程中遇见了一个需要图片懒加载的功能,最后参考了别人的代码和思路自己重新写了一遍.以下将详细介绍如何实现自定义指令v-lazyload. 先看如何使用这个指令: &l ...
- 05-Docker私有仓库
一.介绍私有仓库顾名思义,如果我们不想把docker镜像公开放到公有仓库中,只想在部门或团队内部共享docker镜像,这时私有仓库就来了. 二.私有仓库搭建与配置1.拉取私有仓库镜像,这里说明一下,私 ...
- 源码安装mongoDB
1.安装启动 下载源码包,官方地址: wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.4.22.tgz 解压 ...
- Vue.js-组件化前端开发新思路
Vue.js-组件化前端开发新思路 12017.04.14 18:31:25字数 6228阅读 5632 本文章是我最近在公司的一场内部分享的内容.我有个习惯就是每次分享都会先将要分享的内容写成文章. ...
- dumpe/dumpe2fs/e2fsck
xt2/3/4文件系统备份工具 导出ext2/ext3/ext4文件系统信息 dumpe2fs e2fsck 强制检查文件系统 检查文件系统
- GitHub中PR(Pull request)操作
1. 贡献代码: 贡献代码,通俗的说,就是自己修改了代码,希望合并到别人的Repository(仓库)中.将自己的智慧贡献给开源社区.下面将详细讲解步骤 1.1 第一步:fork 在GitHub社区闲 ...
- visual studio2015窗体中控件的属性中文说明不见了
右击属性窗口,然后选中好说明就ok了.
- C++类*类型和其他类型相互转换
类类型转换时会出现两种之间转换,下面我们说的是类类型 1.其他类型转换为本类类型 通过类带一个参数的构造函数:或者多个参数构造函数,除了第一个参数后面参数都有默认值时!这样在其他类型赋值给该类类型对象 ...
- python 时间等待
#coding=utf- import time t1=time.time() time.sleep() t2=time.time() print(t2-t1) 输出 3.00304102898