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())),
                ),
              )
            ],
          )
相关推荐
变与不变80637 分钟前
jQuery细节以及使用应用场景
前端·javascript·jquery
SailingCoder2 小时前
【封闭结束1】端到端交付:Agent 一次请求如何走完全链路
前端·安全·ai·面试·agent·harness
风骏时光牛马4 小时前
AI多模块协同自动化工作流
前端
zhangminghuan5 小时前
前端面试应对技巧
前端·面试·职场和发展
计算机魔术师5 小时前
潜伏14年的PHP致命洞,AI跑两天就交卷了
前端
IT_陈寒5 小时前
Vue的这个响应式陷阱我居然现在才发现
前端·人工智能·后端
Python自动化直播6 小时前
智能脚本批量管理拆开看:导入、导出、重写、试听
前端·python·ai·秒播
程序员老刘6 小时前
Flutter版本选择指南:3.44稳定了11周正式转正 | 2026年10月
flutter·ai编程·客户端
开开心心就好6 小时前
发票信息录入太麻烦?离线工具一键转表格
运维·服务器·前端·pdf·ocr·maven·intellij-idea