【问题标题】:Flutter | How can I change my FloatingActionButton background color to transparent?颤振 |如何将我的 FloatingActionButton 背景颜色更改为透明?
【发布时间】:2022-01-24 18:59:24
【问题描述】:

顺便说一句,我在颤振和编程方面是全新的,我有一个问题,如何将我的 floatingActionButton 颜色图标从 lightBlueAccent 更改为渐变?这是我的代码:

floatingActionButton: FloatingActionButton(
        backgroundColor: Colors.lightBlueAccent,
        onPressed: () {
          FirebaseFirestore.instance.collection('categories').add(
            {
              'title': controller.text,
            },
          );
          controller.clear();
        },
        child: const Icon(Icons.add_circle_rounded),
      ),

【问题讨论】:

  • 你喜欢什么,透明的还是渐变的?

标签: flutter


【解决方案1】:

您可以使用具有渐变属性的 LinearGradient 类或 RadialGradient 类。

这里有几个可能有用的链接:

https://medium.com/jlouage/flutter-boxdecoration-cheat-sheet-72cedaa1ba20 https://www.kindacode.com/article/flutter-create-gradient-background-buttons/

.
.
),
gradient: LinearGradient(
  colors: <Color>[Colors.blue, Colors.black],
),
.
.

【讨论】:

  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-06-05
  • 2020-08-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-25
相关资源
最近更新 更多