enum_to_string 1.0.8

  • Readme
  • Changelog
  • Example
  • Installing
  • 95

enum_to_string #

Build Status

Better conversion of ENUMs to string - It also can handle converting back again!

What it does #

It takes an enum such as:

enum TestEnum { testValue1 }

and converts it to

testValue1

Also handles camel case

Input enum TestEnum { testValue1 } Output Test Value 1

Usage #

import 'package:enum_to_string:enum_to_string.dart';

enum TestEnum { testValue1 };

convert(){
    String result = EnumToString.parse(TestEnum.testValue1);
    //result = 'testValue1'

    String resultCamelCase = EnumToString.parseCamelCase(TestEnum.testValue1);
    //result = 'Test Value 1'
    
    final result = EnumToString.fromString(TestEnum.values, "testValue1");
    // TestEnum.testValue1
}

Any pull requests / extensions welcome, this was just an annoying thing I needed to fix a couple of times so viola! a package was born.

[1.0.8] - 2019-11-03

  • Better type handling in fromString method (Thanks @Sergey-Schirmer)

[1.0.7+1] - 2019-10-21

  • Improving code robustness (Thanks @ewertonrp)

[1.0.7] - 2019-05-30

  • Improving examples

[1.0.6] - 2019-05-30

  • Added support for getting an enum from a string

[1.0.5] - 2019-05-29

  • Better readme formatting

[1.0.4] - 2019-05-29

  • Better handling of null types

[1.0.3] - 2019-05-26

  • Adding explicit types

[1.0.2] - 2019-05-24

  • Improving my dart score

[1.0.1] - 2019-05-24

  • Initial library release

example/README.md

Example Usage #

The package is pretty self explanatory.

Check out main.dart for usage and expected responses.

import 'package:enum_to_string:enum_to_string.dart';

enum TestEnum { testValue1 };

convert(){
    String result = EnumToString.parse(TestEnum.testValue1);
    //result = 'testValue1'

    String resultCamelCase = EnumToString.parseCamelCase(TestEnum.testValue1);
    //result = 'Test Value 1'
    
    final result = EnumToString.fromString(TestEnum.values, "testValue1");
    // TestEnum.testValue1
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  enum_to_string: ^1.0.8

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:enum_to_string/enum_to_string.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
90
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
95
Learn more about scoring.

We analyzed this package on Nov 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:enum_to_string/enum_to_string.dart.

Health suggestions

Format lib/enum_to_string.dart.

Run dartfmt to format lib/enum_to_string.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
test any