15、Flutter 按钮组件
按钮组件的属性

ButtonStylee里面的常用的参数

ElevatedButton
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return Container(
child: ElevatedButton(
onPressed: (){},
child: Text("普通按钮"),)
);
}
}
TextButton
class MyApp1 extends StatelessWidget {
const MyApp1({super.key});
@override
Widget build(BuildContext context) {
return Container(
child: TextButton(
onPressed: (){},
child: Text("文本按钮"),)
);
}
}
OutlinedButton
class MyApp2 extends StatelessWidget {
const MyApp2({super.key});
@override
Widget build(BuildContext context) {
return Container(
child: OutlinedButton(
onPressed: (){},
child: Text("边框按钮"),)
);
}
}
IconButton
class MyApp3 extends StatelessWidget {
const MyApp3({super.key});
@override
Widget build(BuildContext context) {
return Container(
child: IconButton(
onPressed: (){},
icon: Icon(Icons.abc_rounded))
);
}
}
带图标的按钮
class MyApp4 extends StatelessWidget {
const MyApp4({super.key});
@override
Widget build(BuildContext context) {
return Row(children: [
ElevatedButton.icon(
icon: Icon(Icons.send),
label: Text("发送"),
onPressed: () {},
),
TextButton.icon(
onPressed: () {},
icon: Icon(Icons.access_alarm_outlined),
label: Text("确定")),
OutlinedButton.icon(
onPressed: () {},
icon: Icon(Icons.access_time_filled_sharp),
label: Text("增加"))
]);
}
}
修改按钮的宽度高度
class MyApp5 extends StatelessWidget {
const MyApp5({super.key});
@override
Widget build(BuildContext context) {
return SizedBox(
height: 80,
width: 200,
child: ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(const Color.fromARGB(255, 86, 244, 54)), //按扭背景颜色
foregroundColor: MaterialStateProperty.all(Colors.black)), //字体颜色
onPressed: () {},
child: Text("宽度高度"),
),
);
}
}
自适应按钮
class MyApp7 extends StatelessWidget {
const MyApp7({super.key});
@override
Widget build(BuildContext context) {
return Row(
children: [
Expanded(
child: Container(
color: Colors.green,
height: 80,
margin: EdgeInsets.all(10),
child: ElevatedButton(
child: const Text('自适应按钮'),
onPressed: () {
print("自适应按钮");
})),
)
],
);
}
}
配置圆形圆角按钮
圆角按钮
class MyApp8 extends StatelessWidget {
const MyApp8({super.key});
@override
Widget build(BuildContext context) {
return Container(
child: ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
const Color.fromARGB(255, 33, 243, 61)), //背景颜色
foregroundColor: MaterialStateProperty.all(
const Color.fromARGB(255, 255, 255, 255)), //字体或者图标颜色
elevation: MaterialStateProperty.all(24), //是用来设置Material或Widget的阴影效果的 elevation的值是介于0到24之间的浮点数
shape: MaterialStateProperty.all( //圆角
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10))),
),
onPressed: () {
print("圆角按钮");
},
child: const Text('圆角')));
}
}
圆形按钮
class MyApp8 extends StatelessWidget {
const MyApp8({super.key});
@override
Widget build(BuildContext context) {
return Container(
height: 80,
child: ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
const Color.fromARGB(255, 33, 243, 61)), //按钮背景颜色
foregroundColor: MaterialStateProperty.all(
const Color.fromARGB(255, 255, 255, 255)), //字体或者图标颜色
elevation: MaterialStateProperty.all(
24), //是用来设置Material或Widget的阴影效果的 elevation的值是介于0到24之间的浮点数
shape: MaterialStateProperty.all(
CircleBorder(side: BorderSide(color: Colors.white)),
)),
onPressed: () {
print("圆形按钮");
},
child: const Text('圆形按钮')));
}
}
修改OutlinedButton边框
class MyApp9 extends StatelessWidget {
const MyApp9({super.key});
@override
Widget build(BuildContext context) {
return Row(
children: [
Expanded(
child: Container(
margin: EdgeInsets.all(20),
height: 50,
child: OutlinedButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all(Colors.black),
side: MaterialStateProperty.all( //边框颜色
const BorderSide(width: 1, color: Color.fromARGB(255, 54, 244, 95)))),
onPressed: () {},
child: const Text("注册 配置边框")),
),
)
],
);
}
}
15、Flutter 按钮组件的更多相关文章
- Flutter 中的常见的按钮组件 以及自定义按钮组件
Flutter 里有很多的 Button 组件很多,常见的按钮组件有:RaisedButton.FlatButton. IconButton.OutlineButton.ButtonBar.Float ...
- Flutter中的按钮组件介绍
Flutter 里有很多的 Button 组件很多,常见的按钮组件有:RaisedButton.FlatButton.IconButton.OutlineButton.ButtonBar.Floati ...
- Flutter 中的常见的按钮组件 以及自 定义按钮组件
一.Flutter 中的按钮组件介绍 Flutter 里有很多的 Button 组件很多,常见的按钮组件有:RaisedButton.FlatButton. IconButton.Outlin ...
- 22Flutter中的常见的按钮组件 以及自定义按钮组件
/* Flutter中的常见的按钮组件 以及自定义按钮组件 一.Flutter中的按钮组件介绍 Flutter里有很多的Button组件,常见的按钮组件有:RaisedButton/FlatButto ...
- Flutter学习笔记(11)--文本组件、图标及按钮组件
如需转载,请注明出处:Flutter学习笔记(10)--容器组件.图片组件 文本组件 文本组件(text)负责显示文本和定义显示样式,下表为text常见属性 Text组件属性及描述 属性名 类型 默认 ...
- flutter中的按钮组件
Flutter 里有很多的 Button 组件很多,常见的按钮组件有:RaisedButton.FlatButton.IconButton.OutlineButton.ButtonBar.Floati ...
- 【Flutter学习】基本组件之基本按钮组件
一,概述 由于Flutter是跨平台的,所以有适用于Android和iOS的两种风格的组件.一套是Google极力推崇的Material,一套是iOS的Cupertino风格的组件.无论哪种风格,都是 ...
- Flutter 基础组件:按钮
前言 Material组件库中提供了多种按钮组件如RaisedButton.FlatButton.OutlineButton等,它们都是直接或间接对RawMaterialButton组件的包装定制,所 ...
- JAVA学习Swing章节按钮组件JButton的简单学习
package com.swing; import java.awt.Container; import java.awt.Dimension; import java.awt.GridLayout; ...
- 一个 Vue 的滑动按钮组件
git 地址:https://github.com/SyMind/vue-sliding-button vue-better-slider 一个 Vue 的滑动按钮组件,有关滑动方面的处理借鉴 bet ...
随机推荐
- 重写equals方法的注意事项
重写equals方法的注意事项 一. 在重写equals方法时,要注意满足离散数学上的特性1 自反性:对任意引用值X,x.equals(x)的返回值一定为true.2 对称性:对于任何引用 ...
- Jmeter将响应数据的结果保存到本地的一个文件(xls和csv)
打印excel和csv文件的区别?? 第一种:打印excel 第二种:打印csv文件 创建beanshell后置处理器 import org.json.*;import java.io.*; Str ...
- We Need More Bosses 题解
We Need More Bosses 题目大意 给定一张图,找到两个点,使得这两个点之间的所有路径必须经过的边最多. 思路分析 我们先来思考一下如果已知两个点,怎么求两个点之间必须经过的边的数量. ...
- VS Code C# 开发工具包正式发布
前言 微软于本月正式发布Visual Studio Code C#开发工具包,此前该开发套件已经以预览版的形式在6月份问世.经过4个月的测试和调整,微软修复了350多个问题,其中大部分是用户反馈导致的 ...
- 2022-10-22 CSP赛前隔离时的模拟赛 2:3
T1 简单红题,不懈于写. 锐评:镜子反射出来的竟然没有镜像一下. T2 坑人东西调了 2h. 类似于 round1 的 T4. 线性 \(\Theta(n)\) 过. T3 T4 其实简单,负边权要 ...
- 拿到开发板需要做的事情 -- 配置Python环境
1.查看系统时间 date -R 2.修改系统时间 windows上时间项目时间正常,Ubuntu16.04上时间错误 - 贾斯丁哔哔 - 博客园 (cnblogs.com) 3.安装pip3 sud ...
- MySQL锁:InnoDB行锁需要避免的坑
前言 换了工作之后,接近半年没有发博客了(一直加班),emmmm.....今天好不容易有时间,记录下工作中遇到的一些问题,接下来应该重拾知识点了.因为新公司工作中MySQL库经常出现查询慢,锁等待,节 ...
- 八个SVN提交的好习惯(转)
一.提交之前先更新 1. SVN更新的原则是要随时更新,随时提交.当完成了一个小功能,能够通过编译并且自己测试之后,谨慎地提交. 2. 如果在修改的期间别人也更改了sv ...
- pygame播放视频并实现音视频同步
一.前言 在我接触pygame时最新的pygame已经不支持movie模块,这就导致在pygame播放视频变成一个问题,网上搜了下解决方案有两个: 一是使用opencv播放视频,再结合pygame.m ...
- Git、GitHub、Gitlab的区别以及与SVN的比较
概念解析 Git Git是一个开源的分布式版本控制系统(Version Control System,VCS),可以有效.高速地处理项目版本管理. 版本控制是一种记录一个或若干文件内容变化,以 ...