Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaterialDesignIcons do not work #14

Closed
nstrelow opened this issue Aug 25, 2020 · 3 comments
Closed

MaterialDesignIcons do not work #14

nstrelow opened this issue Aug 25, 2020 · 3 comments
Assignees

Comments

@nstrelow
Copy link

nstrelow commented Aug 25, 2020

I am using https://pub.dev/packages/material_design_icons_flutter to have more icons.

Sadly it breaks. No idea why.

Probably somehow related to the way the font is acquired.

Using a custom indicator now.

indicatorStyle: IndicatorStyle(
                          width: 40,
                          color: Colors.purple,
                          padding: const EdgeInsets.all(8),
                          iconStyle: IconStyle(
                            color: Colors.white,
                            iconData: MdiIcons.delete,
                          ),
                        ),

image

@JHBitencourt
Copy link
Owner

Thanks for the issue @nstrelow.

Well, the cause of this problem is that when using a default iconData I'm painting it directly on Canvas with ui.ParagraphBuilder as you can see here.

final builder = ui.ParagraphBuilder(ui.ParagraphStyle(
  fontFamily: iconData.fontFamily,
));

So the fontFamily is required. When using the default flutter Icons it defines the fontFamily as MaterialIcons that is by default loaded by the SDK.

The material_design_icons_flutter package defines a custom font (as you can see on its implementation) that ui.ParagraphBuilder is not aware of.

So at this point you have 2 options:

  1. Use a custom indicator with these custom icons
  2. Define the custom font in your pubspec.yaml so that ui.ParagraphBuilder will recognise and know how to paint it on canvas.

For this last option you need to take the custom .ttf file and put it into your assets/fonts folder. Now you can declare it into your pubspec.yaml:

flutter:
  uses-material-design: true

  fonts:
    - family: Material Design Icons
      fonts:
        - asset: assets/fonts/materialdesignicons-webfont.ttf

With this you'll be able to use MdiIcons (or any other custom icons package) with the default indicator.

Let me know if this help you.

@JHBitencourt
Copy link
Owner

I'm closing this issue, due to inactivity from the creator.

And the solution can be achieved as explained in my previous comment.

@nstrelow
Copy link
Author

I think in the end I ended up using a custom indicator.

Thanks anyway 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants