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())),
                ),
              )
            ],
          )
相关推荐
莪_幻尘2 分钟前
从 0 到 1 搭建你的 AI Agent 平台:当 Agent 有了工厂,人人都能造同事
前端·ai编程
yuzhiboyouye24 分钟前
XML写接口适用场景举例
java·服务器·前端
IMPYLH25 分钟前
HTML 的 <slot> 元素
前端·网络·html
计算机魔术师35 分钟前
AI行业周末炸锅:有人要踩刹车,有人嫌你刹车片太厚
前端
yuzhiboyouye41 分钟前
零sql和xml写接口,的区别是什么,过程是什么,举例一下下,用mybatis-plus+ spring-boot
java·服务器·前端
怕浪猫43 分钟前
构建你自己的 AI Agent 发行版:从 Profile 定制到生产部署全流程
前端·后端·面试
深圳市益普科技有限公司1 小时前
半导体CIM数据底座:四步把多厂数据拉通
前端
乐迪绘防伪油墨技术分享2 小时前
特种功能油墨选型指南:温变 / 遇水 / 荧光 / UV LED 技术对比与供应商参考
前端·html·uv
cll_8692418912 小时前
WordPress Single Post 文章页美化:响应式表格、图片优化与自动悬浮 Table of Contents(CSS + JS)
前端·css
爱勇宝2 小时前
用了一个月 WorkBuddy,聊聊我的真实感受
前端·后端·程序员