I see that the splash and highlight colors that the FAB takes are connected to argument color in the MaterialApp widget. is there a way to override those colors? I found only foreground color and background colors and those are not what I want. Thanks
To change background color of Floating Action Button in Kotlin Android, set the backgroundTint attribute (in layout file) or backgroundTintList property (in Kotlin file) of FAB with the required color.
Add the floating action button to your layoutThe size of the FAB, using the app:fabSize attribute or the setSize() method. The ripple color of the FAB, using the app:rippleColor attribute or the setRippleColor() method. The FAB icon, using the android:src attribute or the setImageDrawable() method.
If you check the source code of FloatingActionButton
the splash color is tied to the Theme of the app, so you can change the theme only for the button, like this:
Theme(
data: Theme.of(context).copyWith(highlightColor: Colors.yellow),
child: FloatingActionButton(
backgroundColor: Colors.red,
onPressed: () {},
child: Text("hello world"),
),
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With