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

Time:12-24

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

CodePudding user response:

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

CodePudding user response:

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