Skip to content
pubscout

enum_to_string

2.2.1, released 2 years ago by an unverified publisher

Convert enum values to readable strings and back, with camelCase and custom mappings.

WASM-ready
$ flutter pub add enum_to_string
Source repository

What it does

This package provides helper methods to transform enum values into plain strings and vice versa. It supports camelCase formatting, word capitalization, and custom string mappings for enhanced enums.

AI-written summary of version 2.2.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • When you need to display enum values in UI without the default EnumName.ValueName syntax
  • When you need to parse user input or API strings back into enum values
  • When working with Dart 2.17+ enhanced enums that require custom string representations

Skip it when

  • When you need localization or pluralization of enum strings
  • When enum values are dynamic or not known at compile time

Strengths

  • Simple API, no dependencies
  • Supports custom mappings and camelCase conversion
  • Works with Dart 2.17+ enhanced enums
  • Fast and lightweight

Weaknesses

  • No built‑in localization support
  • Limited to enums only
  • No code generation or compile‑time checks

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:enum_to_string/enum_to_string.dart';

enum TestEnum { testValue1, testValue2 }

void main() {
  String s = EnumToString.convertToString(TestEnum.testValue1); // 'testValue1'
  TestEnum e = EnumToString.fromString(TestEnum.values, 'Test Value 1', camelCase: true);
}

Alternatives

Packages that do the same job and could replace enum_to_string.

Works with

Packages commonly used together with enum_to_string: ones it builds on, ones built on it, and its own family.