[Elevated button with icon and arrow1

我可以使用下面的代码创建一个带有图标的按钮

 ElevatedButton.icon(
          icon: Icon(
            Icons.home,
            color: Colors.green,
            size: 30.0,
          ),
          label: Text('Elevated Button'),
          onPressed: () {
            print('Button Pressed');
          },
          style: ElevatedButton.styleFrom(
            shape: new RoundedRectangleBorder(
              borderRadius: new BorderRadius.circular(20.0),
            ),
          ),
        )

但如何将箭头放在按钮的右侧呢?

推荐答案

根据你的共享图像,我已经try 了相同的设计在不同的方式, Select 你的????,你想要try 的方式.

使用ElevatedButton.图标

ElevatedButton.icon(
            icon: const Icon(
              Icons.mail,
              color: Colors.green,
              size: 30.0,
            ),
            label: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: const [
                Text('Change Email Address'),
                Icon(Icons.arrow_forward_ios)
              ],
            ),
            onPressed: () {
              print('Button Pressed');
            },
            style: ElevatedButton.styleFrom(
              backgroundColor: Colors.white,
              foregroundColor: Colors.black,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(10.0),
                side: const BorderSide(color: Colors.black),
              ),
              fixedSize: const Size(double.infinity, 40),
            ),
          ), 

Result Using ElevatedButton.icon -> image

使用OutlinedButton.icon

OutlinedButton.icon(
            icon: const Icon(
              Icons.mail,
              color: Colors.green,
              size: 30.0,
            ),
            label: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: const [
                Text(
                  'Change Email Address',
                  style: TextStyle(
                    color: Colors.black,
                  ),
                ),
                Icon(
                  Icons.arrow_forward_ios,
                  color: Colors.grey,
                )
              ],
            ),
            onPressed: () {
              print('Button Pressed');
            },
            style: ElevatedButton.styleFrom(
             side: const BorderSide(color: Colors.black,),
              fixedSize: const Size(double.infinity, 40),
            ),
          ),

Result Using OutlinedButton.icon -> image

使用ListTile

 ListTile(
            onTap: () {
              print('Button Pressed');
            },
            visualDensity: const VisualDensity(horizontal: -4,vertical: -4),
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(10.0),
              side: const BorderSide(color: Colors.black),
            ),
            leading: const Icon(Icons.mail,color: Colors.green),
            trailing: const Icon(Icons.arrow_forward_ios),
            title: const Text('Change Email Address'),
          ),

Result Using ListTile -> image3

使用GestureDetector

 GestureDetector(
            onTap: () {
              print('Button Pressed');
            },
            child: Container(
              padding:const EdgeInsets.all(10),
              decoration: BoxDecoration(
                border: Border.all(
                  color: Colors.black,
                  width: 1,
                ),
              borderRadius: BorderRadius.circular(10),),
              child: Row(
                children: const [
                  Icon(Icons.mail, color: Colors.green),
                  SizedBox(width: 10,),
                  Text('Change Email Address'),
                  Spacer(),
                  Icon(Icons.arrow_forward_ios),
                ],
              ),
            ),
          ),

Result Using GestureDetector -> image4

使用墨水井

InkWell(
            onTap: () {
              print('Button Pressed');
            },
            child: Container(
              padding:const EdgeInsets.all(10),
              decoration: BoxDecoration(
                border: Border.all(
                  color: Colors.black,
                  width: 1,
                ),
              borderRadius: BorderRadius.circular(10),),
              child: Row(
                children: const [
                  Icon(Icons.mail, color: Colors.green),
                  SizedBox(width: 10,),
                  Text('Change Email Address'),
                  Spacer(),
                  Icon(Icons.arrow_forward_ios),
                ],
              ),
            ),
          ),

Result Using InkWell-> image5

Flutter相关问答推荐

未处理异常:字符串类型不是值类型子类型的子类型'

如何使用新的Riverpod语法将依赖传递给AsyncNotifier?

在Fighter中,我如何在窗口的顶部和底部排列Widget?

如何在Flutter 中共享选定文本

来自FirebaseAuth的错误DisplayName和邮箱在Flutter应用程序中给出错误

如何创建这样的按钮

Wired Firebase错误-[CLOUD_FIRESTORE/UNAvailable]该服务当前不可用

dart /长笛中的返回早期模式和拆分方法

从future 列表到流列表Flutter Firebase

谷歌 map 在 flutter 应用程序中显示错误的当前位置

Flutter:我的应用程序是否需要包含退款购买?

如何从列表中更新provider变量:Flutter列表和Provider优化指南

如何计算 Firestore 集合中的文档数量?

Firebase Auth - 有没有办法为新用户预先生成 UID?

如何从sibling ChildWidgetB 触发 ChildWidgetA 中的操作

如何(部分)更新 riverpod 中的 AsyncValue?

如何为文本主题设置多种 colored颜色 ?

为什么将 bloc 提供程序放在单独的文件/类中会引发错误?

对话框打开时如何使背景模糊?

Flutter Firebase 可以在真实设备上运行,而不是在 Android 模拟器上运行