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 ...
随机推荐
- C++在HotSpot VM中一种巧妙的内存管理方式
在HotSpot VM中定义了一个Relocation类及相关的子类,可以通过这些类操作不同的重定位数据,如在CodeCache中读写这些数据.这些类需要的内存很小,但是不同的类需要的内存大小又不一样 ...
- 手敲,Ascend算子开发入门笔记分享
本文分享自华为云社区<Ascend算子开发入门笔记>,作者: JeffDing . 基础概念 什么是Ascend C Ascend C是CANN针对算子开发场景推出的编程语言,原生支持C和 ...
- 这款 7k Star 的国产监控系统,真不错!
我们都知道天下没有"永不宕机"的系统,但每次线上出问题都要拉出一个程序员"祭天".所以一款靠谱.好用的监控工具就显得十分重要,它可以在生产环境出故障的第一时间发 ...
- 【源码解读(一)】EFCORE源码解读之创建DBContext查询拦截
引言 在网上很少看到有关于系统讲解EFCore源码的,可能大概也许是因为EFCore的源码总体是没有asp.net web的源码流程清晰,正如群友所说,EFCore的源码大致看起来有点凌乱,与其说凌乱 ...
- 可视化-vscode安装pandas
pandas 是基于NumPy 的一种工具,该工具是为解决数据分析任务而创建的.Pandas 纳入了大量库和一些标准的数据模型,提供了高效地操作大型数据集所需的工具.pandas提供了大量能使我们快速 ...
- WPF性能优化:Freezable 对象
Freezable是WPF中一个特殊的基类,用于创建可以冻结(Freeze)的可变对象.冻结一个对象意味着将其状态设置为只读,从而提高性能并允许在多线程环境中共享对象. Freezable的应用 我们 ...
- 14. 从零开始编写一个类nginx工具, HTTP文件服务器的实现过程及参数
wmproxy wmproxy将用Rust实现http/https代理, socks5代理, 反向代理, 静态文件服务器,后续将实现websocket代理, 内外网穿透等, 会将实现过程分享出来, 感 ...
- HTML5的重要内容-1
HTML学习笔记-1 (一):first-child和:first-of-type :first-child第一个元素 :first-of-type第一个某种类型元素 (二):only-child和: ...
- redis 怎么样查看key的大小,多大的key才算大key?
查看key大小的命令 # 格式memory usage [key-name]# 例如:我要查 yino_hash_key 这个key的大小,就在命令行中输入 memory usage yino_has ...
- 谈谈SSO单点登录的设计实现
谈谈SSO单点登录的设计实现 本篇将会讲讲单点登录的具体实现. 实现思路 其实单点登录在我们生活中很常见,比如学校的网站,有很多个系统,迎新系统,教务系统,网课系统.我们往往只需要登录一次就能在各个系 ...