Icon class
Displays an icon from Lucide (default) or custom icon fonts.
Quick Start
Icon(Icons.home)
Icon(Icons.search, size: 32)
Icon(Icons.user, color: Colors.blue)
Custom Icon Fonts
For other icon fonts, use Icon.font:
Icon.font('bi-person', prefix: 'bi') // Bootstrap Icons
Icon.font('fa-star', prefix: 'fa') // Font Awesome
Setup
The framework automatically injects the required CSS when these icons are used.
Manual setup (optional):
<link href="https://unpkg.com/lucide-static@latest/font/lucide.css" rel="stylesheet">
Constructors
- Icon(String name, {Object? key, double size = 24, Color? color, String? className, Style? style, IconClassBuilder? classBuilder})
- Creates a Lucide icon (default).
- Icon.font(String name, {required String prefix, Object? key, double size = 24, Color? color, String? className, Style? style, IconClassBuilder? classBuilder})
- Creates an icon from any icon font.
Properties
- classBuilder → IconClassBuilder?
-
Optional class resolver for custom icon font naming schemes.
final
- className → String?
-
Additional CSS class.
final
- color → Color?
-
Icon color.
final
- css → String?
-
Component-level CSS styles.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDirty → bool
-
Whether this component needs rebuild.
no setterinherited
- isMounted → bool
-
Whether this component is mounted.
no setterinherited
- key → Object?
-
Unique identifier for this component within its parent.
finalinherited
- mounted → bool
-
Whether this component is mounted (alias for isMounted).
no setterinherited
- name → String
-
Icon name (e.g., 'home', 'search', 'user').
final
- onNeedRebuild ← RebuildCallback?
-
Sets the rebuild callback.
no getterinherited
- prefix → String
-
CSS class prefix (e.g., 'lucide', 'bi', 'fa').
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scopeId → String
-
Unique identifier for CSS scoping.
no setterinherited
- size → double
-
Icon size in pixels.
final
- style → Style?
-
Custom styles.
final
-
styleSheet
→ Map<
String, Style> -
Component-level scoped styles using typed records.
no setterinherited
Methods
-
build(
) → Component -
Builds the component's content.
override
-
clearDirty(
) → void -
Clears the dirty flag.
inherited
-
layout(
) → Component? -
The layout wrapper for this component.
inherited
-
markDirty(
) → void -
Marks this component as needing rebuild.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onMount(
) → void -
Called when mounted to the tree.
inherited
-
onUnmount(
) → void -
Called before removal from tree.
inherited
-
registerEffect(
CleanupFn? effectFn()) → void -
Registers an effect disposed on unmount.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited