icon_to_text_extension_codespark 0.0.1
icon_to_text_extension_codespark: ^0.0.1 copied to clipboard
Flutter extension to render any IconData (Material or Cupertino) as Text or TextSpan for inline icons in rich text and custom layouts.
๐ค icondata_to_text_extension #
Convert any Flutter IconData (Material or Cupertino) into inline Text or TextSpan widgets with correct font rendering.
Ideal for rich text, custom layouts, or displaying icons as text in Flutter apps.
โจ Fully null-safe, simple, and customizable.
๐ Features #
- โ Supports both Material and Cupertino icons
- โ
Converts IconData to
TextSpanorTextwidgets - โ Preserves original icon font family and package
- โ
Accepts optional
TextStylewith easy overrides - โ
Prefix and postfix text support โ combine icon and surrounding text in one widget, reducing extra
TextSpans orTextwidgets - โ Perfect for inline icons in rich text or complex UI
- โ Minimal, zero-dependency extension
๐ง Installation #
Add to your pubspec.yaml:
dependencies:
icondata_to_text_extension: ^0.0.1
Then run:
flutter pub get
๐งช Usage #
Convert IconData to TextSpan #
final span = CupertinoIcons.share.toTextSpan(
style: TextStyle(fontSize: 24, color: Colors.blue),
);
Convert IconData to Text widget #
final widget = Icons.share.toText(
style: TextStyle(fontSize: 30, color: Colors.green),
textAlign: TextAlign.center,
);
Use prefix and postfix to reduce extra spans/widgets #
final spanWithText = CupertinoIcons.share.toTextSpan(
prefix: 'Tap ',
postfix: ' to share',
style: TextStyle(fontSize: 24, color: Colors.black),
);
final textWithIcon = Icons.share.toText(
prefix: 'Click ',
postfix: ' here',
style: TextStyle(fontSize: 28, color: Colors.purple),
);
Use in RichText #
RichText(
text: TextSpan(
children: [
TextSpan(text: 'Click the '),
CupertinoIcons.share.toTextSpan(style: TextStyle(color: Colors.black)),
TextSpan(text: ' button to share.'),
],
),
)
๐ท Preview #
๐ก Roadmap #
- โ IconData to TextSpan conversion
- โ IconData to Text widget conversion
- โ Prefix and postfix support in text conversion
- โ Support for custom font sizes & colors via style
- โ Additional utility methods for widget building
- โ Example app with live preview
- โ Add support for other icon fonts (custom font icons)
๐ Example #
Clone or open the example/ folder and run:
flutter run
๐ Check Out My Other Packages! #
Explore more Flutter packages by Katayath Sai Kiran to add unique UI effects and functionality to your apps.
๐จโ๐ป Maintainer #
Developed with ๐ by Katayath Sai Kiran ๐ฌ Contributions and suggestions are always welcome!