使用flutter开发一个渐变色按钮

因为项目需要,需要使用flutter开发一个渐变色的按钮,flutter自带的按钮样式不太好调整,所以需要自定义实现,实现的思路就是使用GestureDetector嵌套Container,Container里面嵌套text实现。

实现的效果:

实现的代码:

            GestureDetector(
              child: Container(
                width: 190,
                height: 80,
                decoration: BoxDecoration(
                    gradient: const LinearGradient(colors: [
                      Color.fromRGBO(73, 42, 229, 1),
                      Color.fromRGBO(111, 30, 155, 1),
                      Color.fromRGBO(225, 33, 67, 1)
                    ], begin: Alignment.topLeft, end: Alignment.bottomRight),
                    borderRadius: BorderRadius.circular(15)),
                child: const Center(
                  child: Text(
                    "点击连接",
                    style: TextStyle(color: Colors.white, fontSize: 26),
                  ),
                ),
              ),
              onTap: () {
                print("点击按钮");
                LoadingDialog.show();
                Future.delayed(Duration(seconds: 2), () {
                  print("隐藏loading");
                  Get.back();
                  Get.toNamed("/");
                });
              },
            )

 

 

相关推荐

  1. el-progress变色

    2024-01-19 05:12:01       43 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-19 05:12:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-19 05:12:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-19 05:12:01       82 阅读
  4. Python语言-面向对象

    2024-01-19 05:12:01       91 阅读

热门阅读

  1. 大白话解析LevelDB: VersionEdit

    2024-01-19 05:12:01       49 阅读
  2. HBASE学习一:原理架构详解

    2024-01-19 05:12:01       52 阅读
  3. C语言:被5整除问题

    2024-01-19 05:12:01       59 阅读
  4. RV1106移植心得

    2024-01-19 05:12:01       60 阅读
  5. linux修改文件名的三种方法有哪些

    2024-01-19 05:12:01       48 阅读
  6. Android 13 - Media框架(26)- MPEG4Extractor

    2024-01-19 05:12:01       49 阅读
  7. Python Web开发:构建高效、可扩展的Web应用

    2024-01-19 05:12:01       54 阅读
  8. qss的使用

    2024-01-19 05:12:01       57 阅读
  9. Python列表append()函数使用详解

    2024-01-19 05:12:01       51 阅读
  10. ORACLE RAC11.2.0.3集群重启无法启动

    2024-01-19 05:12:01       56 阅读
  11. 使用注解@GrpcService在Spring Boot 中开始使用gRPC

    2024-01-19 05:12:01       49 阅读
  12. Scrum敏捷开发企业级实训

    2024-01-19 05:12:01       62 阅读