How to make a custom Arrow Back height and width in Flutter - flutter

I want to make a custom back arrow with a specific height and width, how can I achieve that in flutter? I tried wrapping the IconButton with SizedBox and Container but none of those work. This is the current back arrow from the Icon(Icons.arrow_back):
But I wanted to make it more like this:
The straight line of the arrow is a little longer and the head of the arrow is a little shorter than the default one. Any suggestions on how to achieve this? Should I use another icon or can I make customize the already given one by default?
The code:
AppBar(
backgroundColor: Colors.white,
elevation: 0.0,
iconTheme: IconThemeData(
color: Colors.black,
),
title: new Text('Back Arrow')
leading: IconButton(
color: Color(0xFF323232),
icon: Icon(
Icons.arrow_back,
),
onPressed: () => Navigator.of(context).pop(),
),
),
Thanks in advance for the help and suggestions!

You cant customise inbuilt icons in flutter, you need to create your own icons. There is size property in Icon widget which grows both width and height but it will not satisfy your need.
You can download icons from below sites:
Flaticon
Icons8
and check this blog to use custom icons in flutter

Related

How can I adjust flutter icon button (or image button) to get larger?

leading: Padding(
padding: EdgeInsets.only(left: 20),
child: IconButton(
onPressed: () => print('Menu Tapped'),
icon: Image.asset(
'assets/images/vecteezy_triangle_1200693.png',
fit: BoxFit.fitWidth,
),
),
),
I try adding height: and width: to the Image.asset and iconsize: to IconButton but it does't work
Does it have something to do with edgeInsets?
PS* I'm quite new here, I'm follow YouTube to write a financial management app
if your code is about Appbar you need to increase the icon's space in the Appbar by using toolbarHeight: and leadingWidth: in the Appbar widget.
I hope this work for you.
Since you are providing this widget to "leading", I'm guessing this is for an AppBar. The size of the icon cannot exceed the size of your appbar. You need to increase the size of your appbar to be able to increase the size of your icon. If this doesn't work, provide your code containing the AppBar widget so I can test it out for you.

How to make a button in Flutter have the same shape as its icon?

I am trying to create a backspace button (using an ElevatedButton()). I don't want the button to be circular, but instead have the same shape as the icon. Also, when tapping the button, I want the splash effect to be the same size and shape as the button.
I've attached a reference image below of the shape I'm trying to replicate.
Extra challenge: I'm also trying to set the fill color of the button to be black and the color of the button to be grey (like the example).
You can use the IconButton() widget instead of ElevtaedButton() as well as defining the splashRadius to change the size of the splash effect:
IconButton(
splashRadius: 1, // Set the Size of the splash area
color: Colors.grey,
icon: Icon(Icons.backspace),
onPressed: () {},
),
Result:
Or, if you want to use ElevatedButton(), use the .icon constructor:
ElevatedButton.icon(
style: ElevatedButton.styleFrom(primary: Colors.grey.shade300),
label: Text('Hello World'),
icon: Icon(
Icons.backspace,
color: Colors.grey,
),
onPressed: () {},
)
Result:
There are many default icons in class Icons are not good-looking for your app. You can use some design platform, such as Figma, then download it as svg. Then the code could be:
InkWell(
onTap: () {},
child: SvgPicture.asset(path_to_svg_icon)
)
This way, you can edit color, shape, style... for your icon. Good luck!

Different icon for appBar back button in the whole app

When navigating between pages in flutter, if the second page has an AppBar, by default the AppBar comes with an IconButton to go back to the previous page. Is there a way to set a custom icon for that IconButton that is different than the one provided by default by Flutter and will be applied to every other page? Kind of like a custom AppBarTheme?
You can remove the BackButton and handling it by yourself, using:
AppBar(
automaticallyImplyLeading: false,
leading: Navigator.canPop(context)
? IconButton(
icon: Icon(
Icons.arrow_back,
color: Colors.black,
size: 47,
),
onPressed: () => Navigator.of(context).pop(),
)
: null,
);

How to fill color in the icon in flutter

I am new in flutter. I am using multiple theme(i.e. dark mode) in the app. So, When we use icon in different theme, automatically take background color according to the theme. I want background color of theme but not inside the icon.
Example:
I am using youtube's icon in dark theme so look like below,
But i want to like below,
I am using
Icon(
FontAwesomeIcons.youtube,
color: Colors.red
)
So how to fill the color white in this icon ? (Or also you can suggest me to do that in proper as well as better way to implement)
(so, i can use white filled icon in every theme)
You can use a Stack to place a filled Container under your icon like so:
Stack(children: <Widget>[
Positioned.fill(
child: Container(
margin: EdgeInsets.all(5), // Modify this till it fills the color properly
color: Colors.white, // Color
),
),
Icon(
FontAwesomeIcons.youtube, // Icon
color: Colors.red,
),
),
])
Since its a container, you can also modify its shape in case there are random icon shapes that a normal square does not help in :P
I tried filling the icon play_circle_filled with green using this on DartPad and it gave me this:
I also faced the same issue. I think there could be a modification in Sidak's solution. Instead of using a container in the background, we could use the same Icon of the desired color in the background using the stack widget.
Stack(children: <Widget>[
Positioned.fill(
child: Container(
margin: EdgeInsets.all(5), // Modify this till it fills the color properly
color: Colors.white, // Color
),
),
Icon(
FontAwesomeIcons.youtube, // Icon
color: Colors.red,
),
),
])

Flutter FloatingActionButton and IconButton

How can I create a FloatingActionButton like in the image?
I tried using FloatingActionButton, but it looks like a whole button with a circle.
I need something like an IconButton as shown in the image.
IconButton will actually deliver the result you are aiming for!
A FloatingActionButton, by guidelines, will always deliver the design you find on your "View in Your Room" titled button.
IconButton(
icon: Icon(Icons.back),
onPressed...
)
You need to use IconButton as below
// Icon Button
new IconButton(
icon: new Icon(Icons.favorite),
tooltip: 'Facorite icon',
color: Colors.blue, //set color which you want
onPressed: () {
// Do your work
},
),
For this, you can use actions ** property of appbar to put icons on the right side of title and **leading property to put a leading icon.
appbar: new AppBar(
leading: new Icon(Icons.search),
actions: <Widget>[
new Icon(Icons.search),
new Icon(Icons.search),
],
title: new Text("title"),
)
I suggest using an Icon inside a GestureDetector widget. This will give you the result you want, but also getting rid of the unnecessary padding around an IconButton.
GestureDetector(
onTap: () {},
child: Icon(Icons.arrow_back, color: Colors.black)
)