flutter button
flutter button
button类型:
RaisedButton : 凸起的按钮,其实就是Android中的Material Design风格的Button ,继承自MaterialButton
FlatButton : 扁平化的按钮,继承自MaterialButton
OutlineButton :带边框的按钮,继承自MaterialButton
IconButton : 图标按钮,继承自StatelessWidget
shape:属性
BeveledRectangleBorder 带斜角的长方形边框
CircleBorder 圆形边框
RoundedRectangleBorder 圆角矩形
StadiumBorder 两端是半圆的边框
eg:
FlatButton(
child: Text('SimpleDialog'),
color: Colors.green,
// highlightColor: Colors.transparent,
splashColor: Colors.transparent,
shape: StadiumBorder(), //两边圆角
onPressed: () {
},
)
去除水波纹效果
splashColor: Colors.transparent,
自定义带渐变色button
import 'package:flutter/material.dart';
class GradientButton extends StatelessWidget {
GradientButton({
this.colors,
this.width,
this.height,
this.onTap,
@required this.child,
});
// 渐变色数组
final List<Color> colors;
// 按钮宽高
final double width;
final double height;
final Widget child;
//点击回调
final GestureTapCallback onTap;
@override
Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
//确保colors数组不空
List<Color> _colors = colors ??
[theme.primaryColor, theme.primaryColorDark ?? theme.primaryColor];
return DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(colors: _colors),
),
child: Material(
type: MaterialType.transparency,
child: InkWell(
splashColor: colors.last,
highlightColor: Colors.transparent,
onTap: onTap,
child: ConstrainedBox(
constraints: BoxConstraints.tightFor(height: height, width: width),
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: DefaultTextStyle(
style: TextStyle(fontWeight: FontWeight.bold),
child: child),
),
),
),
),
),
);
}
}
flutter button的更多相关文章
- Flutter学习笔记(29)--Flutter如何与native进行通信
如需转载,请注明出处:Flutter学习笔记(29)--Flutter如何与native进行通信 前言:在我们开发Flutter项目的时候,难免会遇到需要调用native api或者是其他的情况,这时 ...
- 关于 Flutter的Button按钮没有高度设置
flutter 里面 RaisedButton.FloatingActionButton.FlatButton.OutlineButton 中四个button都无高度设置,如下用RaisedButto ...
- 【Flutter学习】之button按钮
一,概述 由于Flutter是跨平台的,所以有适用于Android和iOS的两种风格的组件.一套是Google极力推崇的Material,一套是iOS的Cupertino风格的组件.无论哪种风格,都是 ...
- 你知道吗,Flutter内置了10多种Button控件
注意:无特殊说明,Flutter版本及Dart版本如下: Flutter版本: 1.12.13+hotfix.5 Dart版本: 2.7.0 Flutter内置了10多种Button(按钮)类控件供我 ...
- Flutter 1.22版本新增的Button
Flutter 1.22版本新增了3个按钮,TextButton.OutlinedButton.ElevatedButton,虽然以前的Button没有被废弃,但还是建议使用新的Button. 为什么 ...
- Flutter 即学即用系列博客——03 在旧有项目引入 Flutter
前言 其实如果打算在实际项目中引入 Flutter,完全将旧有项目改造成纯 Flutter 项目的可能性比较小,更多的是在旧有项目引入 Flutter. 因此本篇我们就说一说如何在旧有项目引入 Flu ...
- flutter 主题切换
### 主题 ``` // 1.main主文件 import 'package:flutter_smart_park/config/theme.dart' show AppTheme; Provide ...
- Android程序员的Flutter学习笔记
作为忠实与较资深的Android汪, 最近抽出了一些时间研究了一下Google的亲儿子Flutter, 尚属皮毛, 只能算是个简单的记录吧. Google自2017年第一次提出Flutter, 到20 ...
- iOS开发者学习Flutter
Flutter for iOS 开发者 本文档适用那些希望将现有 iOS 经验应用于 Flutter 的开发者.如果你拥有 iOS 开发基础,那么你可以使用这篇文档开始学习 Flutter 的开发. ...
随机推荐
- centos 7 搭建 LNMP ( Linux+Nginx+MySQL+PHP )
操作系统 | CentOS Linux release 7.6.1810 (Core) [root@localhost ~# cat /etc/redhat-release CentOS Linux ...
- Ansible安装部署和常用命令,及其主机清单inventory(二)
1.ansible的安装方式 1.1使用yum源安装 yum install ansible -y 1.2使用rpm包安装 https://dl.fedoraproject.org/pub/epel/ ...
- IO模型(epoll)--详解-02
写在前面 从事服务端开发,少不了要接触网络编程.epoll作为linux下高性能网络服务器的必备技术至关重要,大部分游戏服务器都使用到这一多路复用技术.文章核心思想是:要让读者清晰明白EPOLL为什么 ...
- BZOJ1257 [CQOI2007]余数之和[规律]
被zcr和yy轮流嘲讽了一番,感觉自己智商日渐下降...\TヘTツ 先拆mod变成整数除法,然后就是$nk- \Sigma_{i=1}^{n} i * \lfloor \frac{k}{i} \rfl ...
- UML(Rational Rose)安装教程【载百度经验】
---恢复内容开始--- Win7安装rational rose2007教程 在UML建模的众多工具中,IBM公司的rational rose建模工具可以说是最好用的建模工具了.哪我们又该如何在win ...
- 轮子:读取config.ini文件
python: 把config.ini文件成map返回 def get_conf(conf_file): conf = {} ll=list(map(lambda x: x.replace('&quo ...
- jQuery attr() prop() data()用法及区别
.attr(),此方法从jq1.0开始一直存在,官方文档写的作用是读/写DOM的attribute值,其实1.6之前有时候是attribute,有时候又是property..prop(),此方法jq1 ...
- matplotlib 模块
目录 matplotlib 模块 1.条形图 2.直方图 3.折线图 4.散点图+直线图 5.饼图 6. plot 函数参数 7.图像标注参数 matplotlib 模块 1.条形图 import m ...
- MaxCompute - ODPS重装上阵 第六弹 - User Defined Type
MaxCompute(原ODPS)是阿里云自主研发的具有业界领先水平的分布式大数据处理平台, 尤其在集团内部得到广泛应用,支撑了多个BU的核心业务. MaxCompute除了持续优化性能外,也致力于提 ...
- C# 之抽象类
抽象类 抽象类中 .只包含抽象方法, .包含非抽象方法和抽象方法 .可使用get和set访问器 Example : public abstract class GeeksForGeeks { publ ...