How to add border radius for OutlinedButton and ElevatedButton with background color ![enter image description here

推荐答案

请try 下面的示例:

在ElevatedButton示例中:

 ElevatedButton(
            onPressed: () {
              // Add your button click logic here
            },
            style: ElevatedButton.styleFrom(
              shape: RoundedRectangleBorder(
                borderRadius:
                    BorderRadius.circular(10.0), 
                side: BorderSide(
                    width: 2,
                    color: Colors.green),
              ),
              backgroundColor:
                  Colors.red, 
            ),
            child: Text('My Button'),
          ), 

在OutlineButton示例中:

OutlinedButton(
            onPressed: () {
             
            },
            style: OutlinedButton.styleFrom(
              backgroundColor: Colors.white,
              side: BorderSide(
                width: 2,
                color: Colors.blue,
              ),
              shape: RoundedRectangleBorder(
                borderRadius:
                    BorderRadius.circular(10.0), // Adjust the radius as needed
              ),
            ),
            child: Text('My Button'),
          ),

Flutter相关问答推荐

当MyChangeNotifier更改时如何计算函数,而无需在构建方法中进行不必要的调用- Flutter

如何使用Firebase Firestore来获取外部集合中的文档子集合中的文档

Flutter版本3.19.2需要更新版本的Kotlin Gradle插件./android/build.gradle:ext.kotlin_version = latest-version>'

在Flutter 中压缩图片返回空

Android Studio中的Ffltter&;Couchbase:进程C:/Program Files/Git/bin/bash以非零退出值35结束

升级到Ffltter 3.16后,应用程序栏、背景 colored颜色 、按钮大小和间距都会发生变化

将Riverpods NotifierProvider与State类一起使用

SingleChildScrollView在ErrorWidget.builder中不工作

我怎样才能go 掉这个底部导航栏上的白色背景

StateNotifer正在riverpod中提供初始状态值(bool)

运行调试flutter应用程序时出错:B/BL超出范围(最大+/-128MB)到'';

如何在flutter中更改showModalBottomSheet小部件中CheckboxListTile小部件的值?

如何在flutter中将所有单词的第一个字母大写

在 Dart 中按土耳其语字母顺序对字符串进行排序

更新番茄计时器值不会触发 Flutter Riverpod 中的alert 声音

hooks_riverpod 有用途吗

访问 AsyncSnapshot 中的嵌套属性

如何在 cupertino switch flutter 中添加文本

扩展磁贴尾随图标在与一个磁贴交互时更新列表中的所有内容.如何只更改展开图块的图标?

如何在Flutter 中水平滚动堆叠定位的小部件?