flutter创建不同样式的按钮,背景色,边框,圆角,圆形,大小都可以设置

在ui设计中,可能按钮会有不同的样式需要你来写出来,所以按钮的不同样式,应该是最基础的功能,在这里我们赶紧学起来吧,web端可能展示有问题,需要优化,但是基本样式还是出来了

我是将所有的按钮放在了Column中:

Dart 复制代码
Column(
            children: [
              ElevatedButton(
                onPressed: () {},
                child: Text("红色按钮"),
                style: ButtonStyle(
                  backgroundColor: MaterialStateProperty.all(Colors.red),
                  foregroundColor: MaterialStateProperty.all(Colors.black),
                ),
              ),
              OutlinedButton(onPressed: () {}, child: Text("边框按钮")),
              ElevatedButton(
                onPressed: () {},
                child: Text("圆角"),
                style: ButtonStyle(
                    shape: MaterialStateProperty.all(RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(10)))),
              ),
              ElevatedButton(
                onPressed: () {},
                child: Text("圆形"),
                style: ButtonStyle(
                    shape: MaterialStateProperty.all(CircleBorder())),
              ),
              //   大一点的按钮
              Container(
                width: 90,
                height: 60,
                margin: EdgeInsets.only(bottom: 10),
                child: ElevatedButton(
                  child: Text("大按钮"),
                  onPressed: () {},
                ),
              ),
              //   大圆形按钮
              SizedBox(
                width: 90,
                height: 60,
                child: ElevatedButton(
                  onPressed: () {},
                  child: Text("大圆形"),
                  style: ButtonStyle(
                      shape: MaterialStateProperty.all(CircleBorder())),
                ),
              )
            ],
          )
相关推荐
CamilleZJ6 小时前
react-i18next+i18next使用
前端·i18next·react-i18next
汐泽学园7 小时前
基于Vue的幼儿绘本阅读启蒙网站设计与实现
前端·javascript·vue.js
mikan7 小时前
详解把老旧的vue2+vue-cli+node-sass项目升级为vite
前端·javascript
七宝三叔7 小时前
C# 上位机开发中的动态绑定与虚拟化
前端
安卓程序员_谢伟光7 小时前
如何监听System.exit(0)的调用栈
java·服务器·前端
爱上妖精的尾巴7 小时前
7-2 WPS JS宏 Object对象属性的查、改、增、删
前端·javascript·vue.js
小哀28 小时前
2025年总结: 我还在往前走
前端·后端·全栈
0思必得08 小时前
[Web自动化] Requests模块基本使用
运维·前端·python·自动化·html·web自动化
change_fate8 小时前
vue模板数组不要直接使用reverse方法
前端·javascript·vue.js
一 乐8 小时前
健康管理|基于springboot + vue健康管理系统(源码+数据库+文档)
java·前端·数据库·vue.js·spring boot·后端·学习