Where are inbuilt icons in flutter located (default location in flutter folder) - flutter

I want to use flutter inbuilt icons as assets. So I want default location where all of flutter icons are located in flutter folder of flutter installation.

This would seem to imply that there's a fontFamily named 'MaterialIcons'. Not sure you can get it easily from any part of the Flutter distro, but https://material.io/resources/icons/ will show how to download or reference the font for your material designs.
static const IconData ac_unit_outlined = IconData(0xe005, fontFamily: 'MaterialIcons')

I don't think they are. If you look at the IconData class (https://api.flutter.dev/flutter/widgets/IconData-class.html). You will see that the description says 'A description of an icon fulfilled by a font glyph.'
Taking an example of one of the Icon values:
static const IconData list_alt = IconData(0xe81b, fontFamily: 'MaterialIcons');
I believe what that is telling us is that the Icon is being defined by the position 0xe81b in the Unicode font family called MaterialIcons

Not an answer to the original question, but likely tangentially helpful...
To visually identify & search/filter icons, both from the included MaterialIcons from Google and those created by the Community, check out:
https://materialdesignicons.com/
And to use them, the related pub.dev package for material_design_icons_flutter.

Related

Flutter face_2 icon not found

I can see the "face_2" right here in the flutter MaterialIcon listing: https://api.flutter.dev/flutter/material/Icons/face_2-constant.html and https://api.flutter.dev/flutter/material/Icons-class.html, but when I try Icons.face_2, flutter can't find it.
I tried to use this code provided in the docs to get the corresponding IconData directly:
IconData(0xf085f, fontFamily: 'MaterialIcons')
It gave me an emoji.

Can we fetch the flutter IconData with flutter Icon name?

Abstract :
I would like to use dynamic icons with custom widget. Inorder to use dynamic icons I need Icon data number. Is there there any each way to get the icon data ?
Example :
Icon Name - Icon(Icons.abc)
Needed :
IconData(0xf04b6, fontFamily: 'MaterialIcons')
Not using a name but You can extract icon data directly from the icon you mentioned.
Icons.abc.codePoint
Icons.abc.fontFamily

Flutter - Some icons are not found

I'm trying to use Icon(Icons.factory) but it not displayed: in VSCode and even in my app.
Do you know why? (I saw I need to add font_awesome_flutter or material_design_icons_flutter but is it mandatory?)
I'm using cupertino_icons: ^1.0.4 & uses-material-design: true in my pubspec.yaml
I haven't seen any icon with name factory in the cupertino documentation but if you want to add any icon which is not yet present in your ide's options, simply visit flutters cupetino docs and click on the icon you want. For example the paperlane icon which is not yet available in the options
static const IconData paperplane = IconData(0xf733, fontFamily: iconFont, fontPackage: iconFontPackage);
change above code to
static const IconData paperplane = IconData(0xf733, fontFamily: CupertinoIcons.iconFont, fontPackage: CupertinoIcons.iconFontPackage);
then you can use the font in your code as
Icon(paperplane)
Remember to update your cupertino package and import the file for some icons to work

Using a custom icon font in a Flutter package displays Question marks instead of custom icons

I have an application composed of a number of different Dart and Flutter packages.
This has proven useful in that I've been able to move things like fonts, colours and Widgets into an independent style guide package which we can then use across all of our other applications.
Using custom fonts in a package works slightly differently in Flutter as we need to add the assets directory as a child of lib rather than a sibling:
…and then register these assets in pubspec.yaml like so:
assets:
- packages/receipt_widget/assets/fonts/my_font.ttf
// other asset declarations
This, for custom fonts and icons (png, jpg etc) works completely fine. My issue is that the same approach does not work for custom icon fonts.
Steps:
Generate custom icon font using IcoMoon or Flutter Icon
Place the generated font into the assets/fonts directory as demonstrated above
Place the generated dart file into the lib folder
Reference the custom icon in code and place into an Icon widget like so:
Icon(MyFontIcon.ic_heart);
For safety I then run flutter clean and uninstall the app from the device/ emulator before deploying a clean build.
I'm then left with a question mark rather than the referenced icon.
NB. the very same icons work correctly when used in a Flutter application directly rather than in a package.
To use your Flutter Icon font from a custom package, you can follow these steps:
(I repeated some of your steps already, for others who will find this issue)
create a flutter icon font
You can use flutter icon for that https://www.fluttericon.com
Put the file into your package
Make sure to copy the .ttf file into of the /lib folder.
NOT just assets, as you would do in your root project.
Example path:
/packages/my_awesome_fontpackage/lib/assets/MyIconFont.ttf
(see https://zubairehman.medium.com/how-to-use-custom-fonts-images-in-flutter-package-c2d9d4bfd47a )
Add the font to your project
Now open your package's pubspec.yaml file and add the font as an asset with package path:
flutter:
fonts:
- family: MyIconFont
fonts:
- asset: packages/my_awesome_fontpackage/assets/MyIconFont.ttf
(you might have to restart your app and bundling completely for the font to be loaded correctly and maybe run flutter clean just to be sure)
Now add package declaration to font dart file
Go into the my_icon_font.dart file and change the constant _kFontPkg there to your package name.
class MyIconFont {
MyIconFont._();
static const _kFontFam = 'MyIconFont';
static const String? _kFontPkg = 'my_awesome_fontpackage';
static const IconData bell = ...
....
}

How to use SVG in Flutter

I'm currently in the process of integrating a map into my app, which should highlight individual components in color. I use this map (https://simplemaps.com/resources/svg-de), which is already available in a well-designed SVG file. I am now trying to color the individual SVG paths using Flutter Code. I am building on the svg_path_parser package (https://pub.dev/packages/svg_path_parser) and have used the corresponding example. But I am unable to replace the paths from the example with those from my SVG file. This may be due to the fact that my SVG paths are significantly longer than the ones given in the example.
I would be very grateful if you would give me a little help or a suggestion for a better approach.
step 1.add dependency in your pubspec.yaml
dependencies:
flutter_svg: any
step 2.import the flutter svg package in your app
import 'package:flutter_svg/flutter_svg.dart';
step 3. just use like below
SvgPicture.asset(
'assets/images/bm-icon1.svg',
width: 18.0,
height: 18.0,
),