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())),
                ),
              )
            ],
          )
相关推荐
用户30816998764857 小时前
同一个端口能被两个程序监听吗?TCP 11 组绑定实测
前端
程序员老刘·7 小时前
Flutter 3.50更新,开发者应该关注什么?
flutter·ai编程·跨平台开发
deli0078 小时前
红绿灯配时实测:固定 60 秒 vs 自适应,2400 辆车差多少
前端
去伪存真8 小时前
井道无信号、满手黑机油,我们如何用 DeepSeek V4 打造不“犯浑”的电梯维保 Agent?
前端·agent
deli0078 小时前
60fps 为什么还是一顿一顿?帧时间曲线实测给你看
前端
时间的情敌8 小时前
Cesium 流动管线、管道动画、管线流向仿真,管网、油气、水利孪生高频需求
前端·交互·cesium
wangxiaoxuan21710 小时前
SLAM 的基本结构:前端、后端、回环与地图优化
前端·机器人·科沃斯八界
Agent世界13 小时前
用 CDP 做发布自动化:四道机器闸门与产物验收
前端·javascript
FungLeo13 小时前
成为全栈·Vue 管理后台篇·编辑器图片上传:从文件选择到文章附件关联
前端·vue.js·编辑器·markdown·文件上传·formdata·附件管理
某哈压力大13 小时前
SSH 突然 Connection reset?不是密钥坏了,是 OpenSSL 把 sshd 干趴了
前端·node.js·命令行