简体   繁体   中英

Flutter | How can I change my FloatingActionButton background color to transparent?

Im completely new in flutter and programming btw and I have a question, how can I change my floatingActionButton color Icon from lightBlueAccent to gradient? Here is my code:

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

It doesnt work or I am doing something wrong... Can u show me how it supposed to be excatly in my code pls? :)

You can utilize the LinearGradient class or RadialGradient class with the gradient property.

Here are a couple of links that may be useful:

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],
),
.
.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM