Remove extra space between two IconButton in ROw - flutter

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

Related

Container widget overflows other widgets- Flutter

This is the expected screen and the container will collapse and expand based on the text displayed and should only occupy the space left out by placing other icons.
But see the flutter implemented screen.
The icons are moved to the right on container expansion and shows overflowed pixel error.
My code
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: const Icon(
Icons.menu,
color: Colors.black,
size: 34,
),
onPressed: () {},
),
//container section
GestureDetector(
child: Container(
margin: const EdgeInsets.only(left: 10, right: 10),
decoration: BoxDecoration(
color: Colors.red.shade100,
borderRadius: BorderRadius.circular(40.0)),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
child: Align(
alignment: Alignment.centerLeft,
child: Row(children: const <Widget>[
Text(
"Content is here",
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.black54,
fontSize: 19.0,
fontWeight: FontWeight.bold),
),
Icon(
Icons.arrow_drop_down,
color: Colors.black,
),
]),
),
),
),
onTap: () {
//todo show bottom sheet dialog here.
},
),
const Spacer(), // I just added one line
IconButton(
icon: Image.asset('assets/images/ic_scan.png'),
iconSize: 20,
onPressed: () {},
),
IconButton(
icon: Image.asset('assets/images/ic_notification.png'),
iconSize: 20,
onPressed: () {},
),
IconButton(
icon: Image.asset('assets/images/ic_search.png'),
iconSize: 20,
onPressed: () {},
),
],
),
);
Remove the spacer and add the dropdown in a flexible widget
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: const Icon(
Icons.menu,
color: Colors.black,
size: 34,
),
onPressed: () {},
),
Flexible(//<-------Flexible
child: GestureDetector(
child: Container(
margin: const EdgeInsets.only(left: 10, right: 10),
decoration: BoxDecoration(
color: Colors.red.shade100,
borderRadius: BorderRadius.circular(40.0)),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
child: Align(
alignment: Alignment.centerLeft,
child: Row(
children: const <Widget>[
Flexible(//<-------Flexible
child: Text(
"Content is here",
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.black54,
fontSize: 19.0,
fontWeight: FontWeight.bold),
),
),
Icon(
Icons.arrow_drop_down,
color: Colors.black,
),
]),
),
),
),
onTap: () {
//todo show bottom sheet dialog here.
},
),
),
//Spacer() //<--------remove this
IconButton(
icon: Image.asset('assets/images/ic_scan.png'),
iconSize: 20,
onPressed: () {},
),
IconButton(
icon: Image.asset('assets/images/ic_notification.png'),
iconSize: 20,
onPressed: () {},
),
IconButton(
icon: Image.asset('assets/images/ic_search.png'),
iconSize: 20,
onPressed: () {},
),
],
),
);

How to use multiply rows with ResponsiveDatatable?

I want to create a second row after the icon "Bearbeiten", but this is not possible, because I need to use "title" for the first row. child: ResponsiveDatatable(title: Row(
I want to have a code like this below. How can I use ResponsiveDatatable, but although use a second row for my buttons?
This image shows, how the code looks at the moment
(without the second row). Because there is not enough space in one row, I want to create a second row.
How can I do this with a ResponsiveDatatable?
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
Container(
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(0),
constraints: BoxConstraints(
maxHeight: 700,
),
child: Card(
elevation: 1,
shadowColor: Colors.black,
clipBehavior: Clip.none,
child: ResponsiveDatatable(
title: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
//add user to the list
TextButton.icon(
onPressed: () => {
Navigator.of(context).pushNamed(RegristrationRoute)
},
icon: Icon(Icons.add,
color: Colors.black,
),
label: Text("Hinzufügen",
style: TextStyle(
color: Colors.black,
)
),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Colors.grey),
padding: MaterialStateProperty.all<EdgeInsets>(
EdgeInsets.all(10)),
),
),
SizedBox(width: 30,),
TextButton.icon(
onPressed: () => {
Navigator.of(context).pushNamed(RegristrationRoute)
//Pop-up Fenster für die Registration machen, wenn Zeit - ansonsten registrationsfenster weiterleiten
},
icon: Icon(
IconData(0xf00d, fontFamily: 'MaterialIcons'),
color: Colors.black,
),
label: Text("Bearbeiten",
style: TextStyle(
color: Colors.black,
)
),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Colors.grey),
padding: MaterialStateProperty.all<EdgeInsets>(
EdgeInsets.all(10)),
),
),]),
child: Row( //error, I am not allowed to use child because of title
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(width: 30,),
TextButton.icon(
onPressed: () => {},
icon: Icon(
IconData(0xe3b1, fontFamily: 'MaterialIcons'),
color: Colors.black,
),
label: Text("Sperren",
style: TextStyle(
color: Colors.black,
)
),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Colors.grey),
padding: MaterialStateProperty.all<EdgeInsets>(
EdgeInsets.all(10)),
),
),
SizedBox(width: 30,),
TextButton.icon(
onPressed: () => {},
icon: Icon(
IconData(0xe3b0, fontFamily: 'MaterialIcons'),
color: Colors.black,
),
label: Text("Freischalten",
style: TextStyle(
color: Colors.black,
)
),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Colors.grey),
padding: MaterialStateProperty.all<EdgeInsets>(
EdgeInsets.all(10)),
),
),
SizedBox(width: 30,),
TextButton.icon(
onPressed: () async => {
await AuthProvider.deleteUser(uid),
print(uid + 'user gelöscht')
},
icon: Icon(
IconData(0xe1bb, fontFamily: 'MaterialIcons'),
color: Colors.black,
),
label: Text("Löschen",
style: TextStyle(
color: Colors.black,
)
),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Colors.grey),
padding: MaterialStateProperty.all<EdgeInsets>(
EdgeInsets.all(10)),
),
),
],
),
What you are expecting is the functionality of the Column.
ResponsiveDatatable(
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: [
TextButton.icon(
onPressed: () => {
Navigator.of(context)
.pushNamed(RegristrationRoute)
},
icon: Icon(
Icons.add,
color: Colors.black,
),
label: Text("Hinzufügen",
style: TextStyle(
color: Colors.black,
)),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(
Colors.grey),
padding: MaterialStateProperty.all<EdgeInsets>(
EdgeInsets.all(10)),
),
),
SizedBox(width: 30,),
TextButton.icon(
onPressed: () => {
Navigator.of(context)
.pushNamed(RegristrationRoute)
//Pop-up Fenster für die Registration machen, wenn Zeit - ansonsten registrationsfenster weiterleiten
},
icon: Icon(
IconData(0xf00d, fontFamily: 'MaterialIcons'),
color: Colors.black,
),
label: Text("Bearbeiten",
style: TextStyle(
color: Colors.black,
)),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(
Colors.grey),
padding: MaterialStateProperty.all<EdgeInsets>(
EdgeInsets.all(10)),
),
),
],
),
SizedBox(height: 10,),
Row(
children: [
TextButton.icon(
onPressed: () => {},
icon: Icon(
IconData(0xe3b1, fontFamily: 'MaterialIcons'),
color: Colors.black,
),
label: Text("Sperren",
style: TextStyle(
color: Colors.black,
)),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(
Colors.grey),
padding: MaterialStateProperty.all<EdgeInsets>(
EdgeInsets.all(10)),
),
),
SizedBox(width: 30,),
TextButton.icon(
onPressed: () => {},
icon: Icon(
IconData(0xe3b0, fontFamily: 'MaterialIcons'),
color: Colors.black,
),
label: Text("Freischalten",
style: TextStyle(
color: Colors.black,
)),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(
Colors.grey),
padding: MaterialStateProperty.all<EdgeInsets>(
EdgeInsets.all(10)),
),
),
SizedBox(width: 30,),
TextButton.icon(
onPressed: () async => {
// await AuthProvider.deleteUser(uid),
// print(uid + 'user gelöscht')
},
icon: Icon(
IconData(0xe1bb, fontFamily: 'MaterialIcons'),
color: Colors.black,
),
label: Text("Löschen",
style: TextStyle(
color: Colors.black,
)),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(
Colors.grey),
padding: MaterialStateProperty.all<EdgeInsets>(
EdgeInsets.all(10)),
),
)
],
),
]),
source: [],
)))
And there is a minor error in the parenthesis closing also.
Note: It will solve your problem but still it will not meet responsiveness.
I had the similar problem.
Instead of TextButton, I made a button-UI in container and wrapped it with InkWell (A rectangular area of a Material that responds to touch).
InkWell(
// on Tap function used and call back function as defined here
onTap: () {
setState(() {
// state will be set when the inkwell area is tapped
inkwell='Inkwell Tapped';
});
},
onLongPress: () {
setState(() {
inkwell='InkWell Long Pressed';
});
},
child: Container(
// container displaying the text
color: Colors.green,
width: 120,
height: 70,
child: Center(
child: Text(
'Button text',
))),
),

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.

Stack multiple icons to flutter IconButton

I have a IconButton and want to stack two icons to look like
I tried with Row layout like
CircleAvatar(
radius: avatarRadius,
child: IconButton(
icon: Row(
children: [
Icon(
Icons.add,
color: Colors.white,
),
Icon(
Icons.message,
color: Colors.white,
),
]
),
onPressed: _onAddMessageButtonClick,
),
),
But it is giving error
A RenderFlex overflowed by 24 pixels on the right.
Remove IconButton widgets
Try this
CircleAvatar(
radius: 40,
child: GestureDetector(
onTap: (){
// perform click here
},
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.add,
color: Colors.white,
),
Icon(
Icons.message,
color: Colors.white,
),
]
),
),
),
OUTPUT