icon_to_text_extension_codespark 0.0.1 copy "icon_to_text_extension_codespark: ^0.0.1" to clipboard
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.

Banner

๐Ÿ”ค icondata_to_text_extension #

Pub Version GitHub License

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 TextSpan or Text widgets
  • โœ… Preserves original icon font family and package
  • โœ… Accepts optional TextStyle with easy overrides
  • โœ… Prefix and postfix text support โ€” combine icon and surrounding text in one widget, reducing extra TextSpans or Text widgets
  • โœ… 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 #

Example Example

๐Ÿ’ก 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!

3
likes
0
points
48
downloads

Publisher

verified publisherksaikiran.tech

Weekly Downloads

Flutter extension to render any IconData (Material or Cupertino) as Text or TextSpan for inline icons in rich text and custom layouts.

Repository (GitHub)
View/report issues

Topics

#icondata #cupertino-icons #material-icons #inline-icons #flutter-extensions

License

unknown (license)

Dependencies

flutter

More

Packages that depend on icon_to_text_extension_codespark