How can I control the Stoke ( thikness ) of the icons - flutter

when we put an Icon Like this
Icon(
Icons.notifications_outlined,
)
we can control the size and color... of that icon, but I want to control the Stroke width of the Icon (not the size of the icon, I want to control the width of the icon's line )
is it possible by any widget or any other way in flutter SDK?
please don't recommend packages of other icons
thanks

I didn't find any way from the flutter SDK to control the icons thinkers, I tried using CustomPainter, BoxShadow()...
alternatively, I used a different icons package which is the Ionicons, which belongs to the Ionic framework, I found out that there is a flutter package for those icons, see Ionicons
you can see a list of all icons here, https://ionic.io/ionicons
and they can be used like this:
Icon(Ionicons.add)
Icon(Ionicons.add_outline)
Icon(Ionicons.add_sharp)

Related

How to make an Icon to have two kinds of Colors in flutter

I am building a flutter application. and I wanted to make an icon to have two colors. green and red. but I can only make either green or red.
how can I achieve an icon as the following image.this image refresh icon The following code only changes to the whole red
Icon(
Icons.cached,
color: Colors.red,
)
You can't.
Instead, I recommend you to use Flutter SVG package and make your icons SVG. with desired colors.
flutter_svg package link

How to remove builtin padding from Icon

It seems the Icon widget has a built-in padding, but I would like to remove the padding in order to properly align the icon with other widgets on the left side.
As you can see from the screenshot below, the widget itself is perfectly aligned to the left (I wrapped the Icon in a Container with background color just for testing purposes), but the icon has some padding and it looks missaligned.
Is there a possibility to remove this padding?
I just checked the Icon implementation (you can take a look as well) and could not find anything about added padding. I am not 100% certain but I assume the whitespace is from the icon itself.
I have an alternative solution though:
Get the icon in SVG format (you can download Google Icons from Google Fonts
Remove the padding using a SVG editor (you can use Figma Free version)
Add the icon as an asset in your pubspec.yaml
Good luck!

Flutter Web FontAwesome fonts download size too big

I noticed that a Flutter Web project that I am making with the font_awesome_flutter plugin is being slowed down by the font_size download. I'm only using one icon from the font. Is there any way I can get this smaller?
Here is the data from webpagetest.org:
Remove the Font Awesome plugin from your project
Remove the font_awesome_flutter plugin from pubspec.yaml and wherever you are using it in your project.
Generate a font with only the icons that you need
You can just extract the icons you need from the font and discard the rest. An east way to do this is to use the IcoMoon site. For example I used the site to generate a font with only the Apple logo icon.
Note the code (eabe). You'll use it later.
Add the font in Flutter
You get get instructions for doing that here. I called my font family Apple.
Use the icon in your app
To use your icon just use a Text widget with the code as the text and specify the font family that you registered in step 2.
FlatButton(
child: Text(
'\ueabe',
style: TextStyle(fontFamily: 'Apple', fontSize: 24),
),
onPressed: () {
model.onApplePressed();
},
),
Here is what it looks like in the app:
Check the size
Rebuild your Flutter web app and put it online.
Here is retesting the site at webpagetest.org.
It's not as small as I expected but the font size is definitely better. (The site is also using Material Design icons so that may be contributing to the remaining font size.)

Flutter: Some of the material design icons are not supported

Seems like some of the material design icons are not supported. Like I want to use how_to_vote icon and it's actually listed in this page but it is not suppoted in Icons class. How can I use this and also why isn't it supported?
As of now, to use material design icons you have to add the package outline_material_icon in your pubspec.yaml. This will make available all the icons you want from this page
If you check the Icons class constants. There is no how_to_vote icon available. If you need to use that icon, download that from the material.io and add it to your app.

What is the Pin Icon called in Material Icons?

What is the name of this pin icon?
Now the exact icon is available in Material Icon.
Icon Name: push_pin
Icon Url: https://material.io/resources/icons/?search=push%20pin&icon=push_pin&style=baseline
Image:
Flutter's Icon class uses the icons from Material Design.
The only icons that would come close to the icon from the image you linked are the following:
place
pin_drop
Alternatively, you could use icons from the cupertino_icons package, however, it does not feature your desired icon either.