Setting custom transparency value to floatingActionButton in flutter - flutter

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?

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

Related

How to greyout FloatingActionButton in Flutter?

I want to greyout a FloatingActionButton in Flutter. How do I do that?
Changing the onPress to null doesn't work:
floatingActionButton: const FloatingActionButton(
onPressed: null,
child: Icon(Icons.add),
)
there are two options....
you can specify the background colour as grey just like this:
floatingActionButton: const FloatingActionButton(
onPressed: null,
child: Icon(Icons.add),
backgroundColor: Colors.grey,
),
You can wrap it with Opacity widget just like this:
floatingActionButton: const Opacity(
opacity: .3,//level of opacity 0~1
child: FloatingActionButton(
onPressed: null,
child: Icon(Icons.add),
backgroundColor: Colors.grey,
),
),

Centering Floating Action Button in navigation bar Flutter

I have created a navigation bar in flutter, now I want to add a button in between the navbar icons as shown in this image.
I want this
But I am getting this. I am getting this
I brought the button in the middle with following code:
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: const Icon(PhosphorIcons.plusLight,color: navBarColor),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
Is there any way to bring it in the middle of the navbar?
If there is a there is a way to give circle background color to a navbar destination, then it would be better.
Try adding an alignment to the fab
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked,
floatingActionButton: Align(
alignment: Alignment.bottomCenter,
child: Container(
padding: const EdgeInsets.only(bottom: 6.0),
child: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
),
),
floatingActionButton: Stack( [ Position( bottom: -20, FloatingActionButton( onPressed: () {}, child: const Icon(PhosphorIcons.plusLight,color: navBarColor), ) ) ]), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
Do not use a FloatingActionButton with a navbar like that. Just add the + action as another button in the middle of the navbar.

How to add two FAB in app one centerDocked in bottom nav and other at normal place

I want to add two floating action buttons in an app but couldn't figure out how to manage this. Example UI is shown in the picture.
Maybe you can achieve this by nesting two Scaffold widgets?
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
title: 'Flutter Demo',
home: Scaffold(
bottomNavigationBar: new BottomAppBar(
shape: CircularNotchedRectangle(),
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(
onPressed: () {},
icon: Icon(Icons.menu),
),
],
),
),
floatingActionButton: new FloatingActionButton(
child: Icon(Icons.shopping_cart),
onPressed: () {},
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked,
body: Scaffold(
floatingActionButton: new FloatingActionButton(
child: Icon(Icons.mail),
onPressed: () {},
),
)),
),
);
}

Flutter Material 'Tap to update' Button

Is there an 'out of the box' implementation of the functionality you get in the google app/etc. where the button at the bottom appears that allows you to 'Tap to update'? A custom snack bar doesn't seem viable as you have to have the title as well as the onTap action.
Try Using Floating Action Button
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Container(
height: 40,
child: RaisedButton(
color: Colors.blue,
onPressed: () => {},
child: Text('Tap to Update'),
),
),
),
try this combination
Scaffold(
bottomNavigationBar: FlatButton(
child: Text('Flat Button'),
onPressed: () {},
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
floatingActionButton: RaisedButton(
child: Text('Floating Button'),
onPressed: () {},
),
);

Flutter having multiple floatingActionButtons

I am trying to have multiple floatingActionButtons on a page in a flutter app, but I haven't been able to solve myself as the instructions on the internet aren't clear. I want the floating action buttons to be on the bottom right of the app. The current code correctly has two floatingactionbuttons, but they appear at the top right. Can someone please let me know how to do this. Thanks! Here is my curret code that puts two floatingactionbuttons in the top right but I want them in the bottomright.
#override
Widget build(BuildContext context) {
return new Scaffold(
floatingActionButton: Column(
children: <Widget>[
FloatingActionButton(
heroTag: "btn1",
child: Icon(Icons.add),
onPressed: () {
setState(() {
list.add(list.length);
});
}),
FloatingActionButton(
heroTag: "btn2",
child: Icon(Icons.add),
onPressed: () {
setState(() {
list.add(list.length);
});
}),
]), //column end
You can use something like this:
floatingActionButton: Stack(
children: <Widget>[
Padding(padding: EdgeInsets.only(bottom:80),
child: Align(
alignment: Alignment.bottomRight,
child: FloatingActionButton(
heroTag: "btn1",
onPressed: (){},
child: Icon(Icons.camera_alt),),
),),
Align(
alignment: Alignment.bottomRight,
child: FloatingActionButton(
heroTag: "btn2",
onPressed: (){},
child: Icon(Icons.add_photo_alternate),),
),
],
)