Change Footer Color in Flutter. (persistentFooterButtons) - flutter

I have a persistentFooterButtons option for my Scaffold.
persistentFooterButtons: [
FloatingActionButton(
heroTag: "editself",
child: Icon(Icons.edit),
onPressed: () {
print(InterfaceViewRoute);
Navigator.pushNamed(context, InterfaceViewRoute, arguments: "-1");
}),
FloatingActionButton(
heroTag: "scanneredit",
child: Icon(Icons.qr_code_scanner_rounded),
onPressed: () => _scan(),
),
],
);
But now the whole background is filled there. See image:
Is there a way to make this background transparent so that you can see the list all the way down

Transparent Footer with Floating Action buttons
This is a Code Snippet.
floatingActionButton: Container(
width: MediaQuery.of(context).size.width,
padding: const EdgeInsets.only(
left: 40.0,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
FloatingActionButton(
tooltip: 'Home',
child: Icon(
Icons.home,
color: Colors.black,
),
onPressed: () {},
backgroundColor: Colors.white.withOpacity(.4),
),
Spacer(),
FloatingActionButton(
tooltip: 'Details',
child: Icon(
Icons.details,
color: Colors.black,
),
onPressed: () {},
backgroundColor: Colors.white.withOpacity(.4),
),
Spacer(),
FloatingActionButton(
tooltip: 'Bar Chart',
child: Icon(
Icons.bar_chart_outlined,
color: Colors.black,
),
onPressed: () {},
backgroundColor: Colors.white.withOpacity(.4),
),
Spacer(),
FloatingActionButton(
tooltip: 'Settings',
child: Icon(
Icons.settings,
color: Colors.black,
),
onPressed: () {},
backgroundColor: Colors.white.withOpacity(.4),
),
],
),
),

Have you tried put Row in floatingActionButton?
floatingActionButton: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
FloatingActionButton(
),
SizedBox(width: 10,),
FloatingActionButton(
),
],
)),

Another way is to use bottomNavigationBar of Scaffold
...
extendBody: true, // if you want body to be extended below buttons
bottomNavigationBar: SafeArea(
child: Container(
child: TextButton(child: Text('button'), onPressed: () {}), //or row of buttons
width: MediaQuery.of(context).size.width,
color: Colors.transparent, //background color
padding: EdgeInsets.only(top: 5, bottom: 3),
),
),
...

Related

I want a docked bottom navigation bar in flutter

I want a docked bottom navigation bar in flutter where the item in the center is uplifted and fixed,
any idea how can I do that
this is the output that I want and I don't have any idea I can I do that
try adding floating action button in scaffold
Scaffold(
bottomNavigationBar: BottomAppBar(
child: Row(
children: [
IconButton(icon: Icon(Icons.menu), onPressed: () {}),
Spacer(),
IconButton(icon: Icon(Icons.search), onPressed: () {}),
IconButton(icon: Icon(Icons.more_vert), onPressed: () {}),
],
),
),
floatingActionButton:
FloatingActionButton(child: Icon(Icons.add), onPressed: () {}),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
),
See I have two options for you here (potentially three):
1. Create a mix of bottom-navigation-bar and floating-action-button
floatingActionButton: FloatingActionButton(
onPressed: () {},
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
child: Icon(Icons.video_call),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: BottomAppBar(
color: Colors.redAccent,
notchMargin: 5,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(
icon: Icon(
Icons.menu,
color: Colors.white,
),
onPressed: () {},
),
IconButton(
icon: Icon(
Icons.search,
color: Colors.white,
),
onPressed: () {},
),
IconButton(
icon: Icon(
Icons.print,
color: Colors.white,
),
onPressed: () {},
),
IconButton(
icon: Icon(
Icons.people,
color: Colors.white,
),
onPressed: () {},
),
],
),
),
pseudo second:
Create a notch in the bottom-navigation-bar :
bottomNavigationBar: BottomAppBar(
shape: shape: AutomaticNotchedShape(
RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(15),
),
),
RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
),
), // by adding this line in the above code
color: Colors.redAccent,
notchMargin: 5,
child: Row(
2. Use Stack BottomNavBar Combo :
Stack(
children: [
Align(
alignment: Alignment.bottomCenter,
child: BottomNavigationBar(
backgroundColor: Colors.transparent,
items: const [
BottomNavigationBarItem(
icon: Icon(
Icons.home,
color: Colors.white,
),
label: 'a',
backgroundColor: Colors.transparent),
BottomNavigationBarItem(
icon: Icon(Icons.search),
label: 'a',
backgroundColor: Colors.yellow),
BottomNavigationBarItem(
icon: Icon(Icons.person),
label: 'a',
backgroundColor: Colors.blue,
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
label: 'a',
backgroundColor: Colors.blue,
),
],
type: BottomNavigationBarType.shifting,
selectedItemColor: Colors.black,
iconSize: 20,
elevation: 5),
),
Positioned(
top: height * 0.25,
left: width * 0.40,
child: FloatingActionButton(
onPressed: () {},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15)),
child: Icon(Icons.video_call),
),
),
],
),
),
),
],
),
Try below code:
Scaffold(
body: Container(),
floatingActionButton: FloatingActionButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
onPressed: () {},
tooltip: 'Increment',
child: Icon(Icons.video_camera_back),
elevation: 4.0,
backgroundColor: Colors.pink,
),
bottomNavigationBar: BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: IconButton(icon: Icon(Icons.home), onPressed: () {}),
),
Expanded(
child: IconButton(icon: Icon(Icons.show_chart), onPressed: () {}),
),
Expanded(child: new Text('')),
Expanded(
child: IconButton(icon: Icon(Icons.tab), onPressed: () {}),
),
Expanded(
child: IconButton(icon: Icon(Icons.settings), onPressed: () {}),
),
],
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
)
Result->
Refer persistent_bottom_nav_bar also and refer bottom_nav_bar also for more design of

How to prevent _persistentFooterButtons_ to get covered from activated keyboard?

When the keyboard is activated, persistentFooterButtons are covered.
...
persistentFooterButtons: <Widget>[
ButtonBar(
children: [
IconButton(
iconSize: 15,
onPressed: () {},
icon: Icon(Icons.east, color: Colors.green),
),
IconButton(
iconSize: 15,
onPressed: () {},
icon: Icon(Icons.api, color: Colors.blue),
),],),],
); //Scaffold
When the keyboard is activated, the icons should be displayed above the keyboard.
write in floatingActionButton
for example :
floatingActionButton: Column(
children: [
Row(
children: [
Expanded(child: Container()),
FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
],
),
Container(
height: 1, color: Colors.grey , margin: EdgeInsets.only(top: 10 , left: 30),
),
Container(
child: ButtonBar(
children: [
IconButton(
iconSize: 15,
onPressed: () {},
icon: Icon(Icons.extension, color: Colors.green),
),
IconButton(
iconSize: 15,
onPressed: () {},
icon: Icon(Icons.ac_unit, color: Colors.blue),
),
],
),
)
],
mainAxisAlignment: MainAxisAlignment.end,
), //

How to use Stack and Positioned in Column

Need to adjust the position of the Flatbutton and IconButton in Raw. How to use Stack and Positioned in the below code. is it possible to apply stack and positioned in this code?
return MaterialApp(
home: Scaffold(
body: Column(children: [
FlatButton( // `need to position in bottom right side`
color: Colors.green,
textColor: Colors.black,
padding: EdgeInsets.all(8.0),
onPressed: () {},
child: Text(
'Save',
style: TextStyle(fontSize: 20.0),
)),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: GestureDetector(
child: IconButton( // `need to position in center`
icon: Icon(Icons.mic),
color: Colors.black,
iconSize: 50,
onPressed: () async {
startRecord();
}),
),
),
Expanded(
child: GestureDetector(
child: IconButton( // `need to position in bottom center'
icon: Icon(Icons.pause),
color: Colors.black,
iconSize: 50,
onPressed: () {
pauseRecord();
},
),
),
),
RecordMp3.instance.status == RecordStatus.PAUSE
? Expanded(
child: GestureDetector(
child: IconButton(
icon: Icon(Icons.play_arrow),
color: Colors.black,
iconSize: 50,
onPressed: () {
resumeRecord();
},
),
),
)
: SizedBox(),
Expanded(
child: GestureDetector(
child: IconButton(
icon: Icon(Icons.stop),
color: Colors.black,
iconSize: 50,
onPressed: () {
stopRecord();
},
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Text(
statusText,
style: TextStyle(color: Colors.red, fontSize: 20),
),
),
isComplete && recordFilePath != null
? Expanded(
child: GestureDetector(
child: IconButton( // `need to position in between bottom and middle`
icon: Icon(Icons.play_circle_filled),
color: Colors.black,
iconSize: 50,
onPressed: () {
play();
}),
),
)
: SizedBox(),
]),
),
);
need to position the Flatbutton in the right bottom. need to position the Iconbuttons in middle and space between the middle and bottom.

Flutter double Fab use on docker

I am using double FAB. But I don't know how can set fab position to docker.
If I use one FAB, I can do it like that:
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked
but I used two fab so How can I do it that? Thats my FAB codes:
floatingActionButton: Stack(
children: <Widget>[
Padding(padding: EdgeInsets.only(left:31),
child: Align(
alignment: Alignment.bottomLeft,
child: FloatingActionButton(
backgroundColor: Colors.orange,
child: Icon(Icons.import_contacts),),
),),
Align(
alignment: Alignment.bottomRight,
child: FloatingActionButton(
backgroundColor: Colors.orange,
child: Icon(Icons.play_arrow),),
),
],
),
ScreenShot
Am new to flutter and I want to make it as simple as possible
For vertical use column and for Horizontal use row, Let me show you how.
For Horizontal:
Row(
children: <Widget>[
Padding(padding :const EdgeInsets.only(right: 90.0, bottom: 5.0)),
FloatingActionButton(
child: Icon(Icons.arrow_forward),
onPressed: () {}
), //FloatingActionButton
Padding(padding :const EdgeInsets.only(right: 90.0, bottom: 5.0)),
FloatingActionButton(
child: Icon(Icons.arrow_forward),
onPressed: () {}
), //FloatingActionButton
Padding(padding :const EdgeInsets.only(right: 90.0, bottom: 5.0)),
FloatingActionButton(
child: Icon(Icons.arrow_forward),
onPressed: () {}
), //FloatingActionButton
], //<Widget>[]
) //Row
For Vertical:
Column(
children: <Widget>[
Padding(padding :const EdgeInsets.only(right: 90.0, bottom: 5.0)),
FloatingActionButton(
child: Icon(Icons.arrow_forward),
onPressed: () {}
), //FloatingActionButton
Padding(padding :const EdgeInsets.only(right: 90.0, bottom: 5.0)),
FloatingActionButton(
child: Icon(Icons.arrow_forward),
onPressed: () {}
), //FloatingActionButton
Padding(padding :const EdgeInsets.only(right: 90.0, bottom: 5.0)),
FloatingActionButton(
child: Icon(Icons.arrow_forward),
onPressed: () {}
), //FloatingActionButton
], //<Widget>[]
) //Column
It's just an idea on how to use multiple FloatingActionButtons, It's your wish how and where you'll use this idea...

Flutter: Set button height to fill container

I've been trying to make my button to fill my container.
But as you can see from the picture above, the button (red) on the left clearly did not fill the entire container(green). I can solve this by adding height to MaterialButton, but IMHO this is not the best solution, because device's height might differ. Can you help me to solve this problem? Thanks.
Here is my code:
Row(
children: <Widget>[
Expanded(
child: Container(
color: Colors.green,
child: MaterialButton(
color: Colors.red,
child: Text("Button A"),
onPressed: () {},
),
),
),
Expanded(
child: MaterialButton(
color: Colors.blue,
child: Text("Button B"),
onPressed: () {},
),
),
],
),
Simply Add - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, in MaterialButton
Row(
children: <Widget>[
Expanded(
child: Container(
color: Colors.green,
child: MaterialButton(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, // Add this
color: Colors.red,
child: Text("Button A"),
onPressed: () {},
),
),
),
Expanded(
child: MaterialButton(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, // Add this
color: Colors.blue,
child: Text("Button B"),
onPressed: () {},
),
),
],
),
You may can try
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: Container(
color: Colors.green,
child: SizedBox(
height: 48,
child: MaterialButton(
height: double.infinity,
color: Colors.red,
child: Text("Button A"),
onPressed: () {},
padding: EdgeInsets.all(0),
),
),
),
),
Expanded(
child: SizedBox(
height: 48,
child: MaterialButton(
height: double.infinity,
color: Colors.blue,
child: Text("Button B"),
onPressed: () {},
),
),
),
],
),