Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting custom transparency value to floatingActionButton in flutter

Tags:

flutter

dart

floatingActionButton: FloatingActionButton(
        onPressed: () {},
        child: Icon(Icons.add),
        backgroundColor: Colors.blueGrey[800],
      ),

How can I set custom opacity/transparency value to the floatingActionButton? Is there a property where the % of transparency be defined?

like image 625
codekls Avatar asked Aug 01 '26 13:08

codekls


2 Answers

you can set transparency of a floating button by adding opacity to its color

floatingActionButton: FloatingActionButton(
    onPressed: () {},
    child: Icon(Icons.add),
    backgroundColor: Colors.blueGrey.withOpacity(0.5),
  ),
like image 174
rishabh mistry Avatar answered Aug 03 '26 09:08

rishabh mistry


If you want to keep the original color itself but to change the transparency only, use

Theme.of(context).colorScheme.primaryContainer.withOpacity(0.5)

for the backgroundColor.

like image 26
innomatic Avatar answered Aug 03 '26 08:08

innomatic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!