Add AntIcon in TreeView but showing a ?
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)
-
-
reporter Yes, Kevin, sorry for late reply.
- 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
-
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
-
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.
-
reporter Thanks, Kevin, have try several ways including NodeIcon constructor, same problem, much appreciate
-
- changed status to resolved
Added support for using external font packages
-
reporter Thanks, Kevin
- Log in to comment
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.