How to prevent _persistentFooterButtons_ to get covered from activated keyboard? - flutter

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

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

Change Footer Color in Flutter. (persistentFooterButtons)

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

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.

Remove extra space between two IconButton in ROw

I want to remove some extra space between two IconButton in Row widget
I tried much more but still not able to remove space between widgets
Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Home",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15,
color: Colors.black
)
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
IconButton(
icon: Icon(
Icons.edit,
color: Colors.black,
size: 20,
),
onPressed: () {
IntelUtility.navigateToScreen(
context, EditHomeAddressScreen()
);
},
),
IconButton(
icon: Icon(
Icons.delete,
color: Colors.black,
size: 20,
),
onPressed: () {},
),
],
),
],
),
],
),
Please help to solving this issue i am in trouble :(
Instead of using IconButton,
you can use CupertinoButton like this :
CupertinoButton(
minSize: double.minPositive,
padding: EdgeInsets.zero,
child: Icon(
Icons.delete,
color: Color.black,
size: 20
),
onPressed: () {},
)
Add param padding: EdgeInsets.all(0) to IconButton.
IconButton(
padding: EdgeInsets.all(0),
icon: Icon(
Icons.delete,
color: Colors.black,
size: 20,
),
onPressed: () {},
)
Your answer is BoxConstraints
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
IconButton(
constraints: BoxConstraints.tight(Size.fromWidth(30)),
icon: Icon(
Icons.edit,
color: Colors.black,
size: 20,
),
onPressed: () {
IntelUtility.navigateToScreen(
context, EditHomeAddressScreen()
);
},
),
IconButton(
constraints: BoxConstraints.tight(Size.fromWidth(30)),
icon: Icon(
Icons.delete,
color: Colors.black,
size: 20,
),
onPressed: () {},
),
],
),
You can change constraints: BoxConstraints.tight(Size.fromWidth(30)), whatever you want

How to achieve dynamic text under icon in the best way

I'm trying to implement 2 Icons in a Row and under each Icon some text
My current implementation:
ButtonBar(
alignment: MainAxisAlignment.spaceAround,
children: <Widget>[
IconButton(
icon: Icon(
Icons.directions_car,
size: 55.0,
),
onPressed: () {},
),
IconButton(
icon: Icon(
Icons.streetview,
size: 55.0,
),
onPressed: () {},
),
],
),
Padding(
padding: const EdgeInsets.fromLTRB(18.0, 10.0, 0, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text('some text',
style: TextStyle(
fontSize: 16.0
),
),
Text('some text'),
],
),
),
My problem is that my text should be dynamic, So every time the text changed, the location of my text changes and sometimes it look really ugly.
How can in place the text in a better way that is posted here?
try this.. so what I have done is I added both Icon and Text inside a Column so they will behave as a group
ButtonBar(
alignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Column(
children: <Widget>[
IconButton(
padding: EdgeInsets.zero,
icon: Icon(
Icons.directions_car,
size: 55.0,
),
onPressed: () {},
),
SizedBox(
height: 10,
),
Text('some text'),
],
),
Column(
children: <Widget>[
IconButton(
padding: EdgeInsets.zero,
icon: Icon(
Icons.streetview,
size: 55.0,
),
onPressed: () {},
),
SizedBox(
height: 10,
),
Text('some text'),
],
),
],
),