Add AntIcon in TreeView but showing a ?

Issue #10 resolved
Ping Woo created an issue

I use flutter material Icon, it works fine, but when I use AntIcon package Icon. It shows ?, any one know what’s the problem?

Comments (7)

  1. Kevin Armstrong

    Hi Ping Woo. I would have to see your code to know what’s going on.
    Have you verified the icons work in other parts of your application? If your can show me how you are loading a TreeNode with an icon, that may be helpful.

  2. Ping Woo reporter

    Yes, Kevin, sorry for late reply.

    1. this is my tree nodes, the icon from a function.
    List<Node> _getSharedChildNode(List<ProjectsWithOwner> projects) {
        List<Node> sharedNodes = new List<Node>();
        projects.forEach((element) => {
              sharedNodes.addAll(element.projects.map((e) => Node(
                  label: e.name,
                  key: e.id.toString(),
                  data: e,
                  icon: NodeIcon.fromIconData(getProjectTypeIcon(e.projectType)),
                  children: _getOwnedChildNode(e.subProjects)))),
            });
        return sharedNodes;
      }
    

    2. the icon function:

    IconData getProjectTypeIcon(ProjectType projectType) {
      switch (projectType) {
        case ProjectType.TODO:
          return AntIcons.carry_out_outline;
        case ProjectType.NOTE:
          return AntIcons.file_text_outline;
        case ProjectType.LEDGER:
          return AntIcons.account_book_outline;
        default:
          return AntIcons.file_unknown_outline;
      }
    }
    

    3. AntIcon

    import 'package:ant_icons/ant_icons.dart';
    
    ant_icons: ^1.0.0
    

  3. Ping Woo reporter

    the flutter material icon just fine, but the when using antIcons, it will just not working properly. in IOS got a ?, in android, got a X

  4. Kevin Armstrong

    Hi Ping Woo, thanks for the code. That should certainly work. The NodeIcon class should get the proper font family from the IconData class. I would suggest explicitly instantiating the NodeIcon class from the constructor to see if it helps. In the meantime, I will debug the issue and figure out a solution.

  5. Ping Woo reporter

    Thanks, Kevin, have try several ways including NodeIcon constructor, same problem, much appreciate

  6. Log in to comment