Skip to content

It's hard to use custom icons #3199

Closed

Description

@vlidholt

Many, if not most, apps are likely to require custom icons. While it's simple enough to draw an image, some components (e.g. the IconButton) asks for an IconData and not a Widget.

I propose adding an extra, optional field to the IconData that specifies the font to use when drawing the icon. This would make it easy for developers to create a custom icon font and use custom icons.

Activity

  1. modified the milestone: on May 20, 2016
  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Sep 12, 2016
  3. added a commit that references this issue on Mar 18, 2017
    0e58913
  4. added a commit that references this issue on Mar 18, 2017
    c95e734
  5. fablue commented on May 10, 2017

    @fablue

    But how can i get the codePoint from https://materialdesignicons.com ?

  6. Hixie commented on May 11, 2017

    @Hixie
    Contributor

    That's a question you'll have to ask them. Presumably it's documented somewhere, otherwise it's not clear how anyone could use their font (assuming they have a font).

  7. Hixie commented on May 11, 2017

    @Hixie
    Contributor

    Looks like the answer is on: https://cdn.materialdesignicons.com/1.9.32/

  8. fablue commented on May 11, 2017

    @fablue

    Thank you very much 👍

  9. BenSower commented on Sep 13, 2017

    @BenSower

    For anyone coming here from google: I created a tutorial on how to add custom icons to your app: https://medium.com/@emv_tech/add-custom-font-icons-to-a-flutter-project-12bddb841d7

  10. KaranChimple commented on May 23, 2018

    @KaranChimple

    @BenSower I tried to work through your process but the problem I'm facing is that I already have a png file in assets folder and I want to include it. Iconmoon doesn't allow to upload png files. It says "Please choose SVG images, SVG fonts or JSONs exported by IcoMoon." Do you guys have any other solutions?

  11. BenSower commented on May 23, 2018

    @BenSower

    @KaranChimple I am not quite, but pretty sure you won't be able to use a png file like you would use a font-type file. You can however convert your png file to svg and then just convert it into a font: https://stackoverflow.com/questions/1861382/how-to-convert-a-png-image-to-a-svg

  12. KaranChimple commented on May 23, 2018

    @KaranChimple

    @BenSower Thanks. I found out a much better way to include png files. I used the following code:
    IconButton(
    icon: new Image.asset("assets/forward_button.png"),
    iconSize: ht > wd ? ht * 0.08 : wd * 0.08,
    onPressed: () {
    Navigator.pop(context);
    Navigator.pop(context);
    Navigator.pop(context);
    })

  13. BenSower commented on May 23, 2018

    @BenSower

    That is of course a way to use a png as an icon, but depending on the image, you might run into problems when scaling the image on larger/smaller devices, since png does not contain any vector information. If that is acceptable then you should be fine :-).

  14. zoechi commented on May 25, 2018

    @zoechi
    Contributor
  15. raveesh-me commented on Oct 4, 2018

    @raveesh-me

    Now there is a package that does it for material design icons at least:
    https://pub.dartlang.org/packages/material_design_icons_flutter

  16. github-actions commented on Aug 16, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  17. locked as resolved and limited conversation to collaborators on Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    frameworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions