FigmaComponent.icon
The FigmaComponent.icon
component renders vector graphics from your Figma design as icons in your Flutter app. It preserves all visual details including paths, colors, gradients, and effects.
Parameters
Parameter | Type | Description |
---|---|---|
componentName | String | The name of the icon component in your Figma file |
How It Works
- The component looks for a vector node with the specified name in your Figma file
- It extracts all vector paths and styling information
- It renders the vector graphic as a Flutter custom paint
- The result is a pixel-perfect representation of your Figma icon
Icon in a Button
IconButton(
icon: FigmaComponent.icon("settings_icon"),
onPressed: () => openSettings(),
)
Icon with Text
Row(
children: [
FigmaComponent.icon("location_pin"),
SizedBox(width: 8),
Text("New York, NY"),
],
)
Figma Design Tips
- Keep icons simple: Complex icons with many paths can impact performance
- Organize icons in frames: Group related icons in named frames
- Use consistent sizing: Design icons with consistent dimensions
- Flatten vectors: Flatten vector paths when possible to optimize rendering
- Consider color overrides: If you need to change icon colors dynamically, design monochrome icons
Best Practices
- Naming convention: Use a clear naming convention for icons in your Figma file
- Optimize vectors: Too many control points can impact performance
- Consider size: Design icons at their intended size to avoid scaling issues
- Group related icons: Organize icons logically in your Figma file
Limitations
Currently, the FigmaComponent.icon
has a few limitations:
- It doesn't support dynamic color changes (the color comes from Figma)
- Complex effects may not render identically in all cases
- Very complex vectors might impact performance
This component is perfect for rendering custom icons, simple illustrations, and vector graphics from your Figma design.