string_to_icon

A Flutter package that converts string icon names to IconData objects from the Material Icons set.

Features

  • Convert string icon names to IconData objects
  • Case-insensitive matching
  • Returns null for non-existent icons
  • Supports a wide range of Material icons

Getting started

Add the package to your pubspec.yaml:

dependencies: string_to_icon: ^0.0.1

Then run: flutter pub get

Usage

import 'package:flutter/material.dart'; import 'package:string_to_icon/string_to_icon.dart';

// Get an IconData from a string IconData? iconData = StringToIcon.fromString('home');

// Use it in an Icon widget Icon( StringToIcon.fromString('favorite'), color: Colors.red, size: 24, )

// Handle null case for non-existent icons IconData? maybeIcon = StringToIcon.fromString('nonexistent_icon'); if (maybeIcon != null) { return Icon(maybeIcon); } else { return Text('Icon not found'); }

Supported Icons

The package currently supports the following icons:

  • home
  • favorite
  • settings
  • person
  • search
  • menu
  • add
  • delete
  • edit
  • share
  • close
  • arrow_back
  • arrow_forward
  • check
  • email
  • phone
  • camera
  • photo
  • alarm
  • location_on
  • shopping_cart
  • local_dining
  • And many more...

Additional information

For more information, please visit the GitHub repository.

Author

Developed by Vivek Mehta (@VivekMehta02)

Contributions are welcome!

Libraries

string_to_icon