enum_string_value_lib 1.0.0+2

  • Readme
  • Changelog
  • Example
  • Installing
  • 91

Annotations for enum_string_value.

Usage #

(See whole example project)

Put build.yaml on the root of your project.

targets:
  $default:
    builders:
      enum_string_value_generator|enum_string_value:
        generate_for:
          - lib/**/*.dart

Add packages to your pubspec.yaml.

dependencies:
  enum_string_value_lib: ^1.0.0+1

dev_dependencies:
  build_runner: ^1.7.2
  enum_string_value_generator: ^0.0.2+1

Add @Value annotation to your enum values and part directive for the generated file.

// os.dart
import 'package:enum_string_value_lib/enum_string_value_lib.dart';
part "os.value.g.dart";

enum OsKind {
  @Value("Android")
  android,
  @Value("iOS")
  ios,
}

Run build_runner on your project.

for pure Dart project:

$ pub run build_runner build

for Flutter project

$ flutter packages pub run build_runner build

1.0.0+2 #

  • Update dependencies.

1.0.0+1 #

  • Update documents.

1.0.0 #

  • v0.0.1 has no problem, so bumped major version.

0.0.1 #

  • Initial version

example/lib/example.dart

import 'package:enum_string_value_lib/enum_string_value_lib.dart';

part 'example.value.g.dart';

enum JapanesePrefecture {
// 北海道・東北
  @Value("北海道")
  hokkaido,
  @Value("青森")
  aomori,
  @Value("岩手")
  iwate,
  @Value("宮城")
  miyagi,
  @Value("秋田")
  akita,
  @Value("山形")
  yamagata,
  @Value("福島")
  fukushima,

  /// 関東
  @Value("茨城")
  ibaraki,
  @Value("栃木")
  tochigi,
  @Value("群馬")
  gunma,
  @Value("埼玉")
  saitama,
  @Value("千葉")
  chiba,
  @Value("東京")
  tokyo,
  @Value("神奈川")
  kanagawa,

  /// 北陸
  @Value("新潟")
  nigata,
  @Value("富山")
  toyama,
  @Value("石川")
  ishikawa,
  @Value("福井")
  fukui,

  /// 甲信越
  @Value("山梨")
  yamanashi,
  @Value("長野")
  nagano,

  /// 東海
  @Value("岐阜")
  gifu,
  @Value("静岡")
  shizuoka,
  @Value("愛知")
  aichi,

  /// 近畿
  @Value("三重")
  mie,
  @Value("滋賀")
  shiga,
  @Value("京都")
  kyoto,
  @Value("大阪")
  osaka,
  @Value("兵庫")
  hyogo,
  @Value("奈良")
  nara,
  @Value("和歌山")
  wakayama,

  /// 中国
  @Value("鳥取")
  tottori,
  @Value("島根")
  shimane,
  @Value("岡山")
  okayama,
  @Value("広島")
  hiroshima,
  @Value("山口")
  yamaguchi,

  /// 四国
  @Value("徳島")
  tokushima,
  @Value("香川")
  kagawa,
  @Value("愛媛")
  ehime,
  @Value("高知")
  kochi,

  /// 九州・沖縄
  @Value("福岡")
  fukuoka,
  @Value("佐賀")
  saga,
  @Value("長崎")
  nagasaki,
  @Value("熊本")
  kumamoto,
  @Value("大分")
  oita,
  @Value("宮崎")
  miyazaki,
  @Value("鹿児島")
  kagoshima,
  @Value("沖縄")
  okinawa,
}

Use this package as a library

1. Depend on it

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


dependencies:
  enum_string_value_lib: ^1.0.0+2

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_string_value_lib/enum_string_value_lib.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
83
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]
91
Learn more about scoring.

We analyzed this package on Apr 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
Dev dependencies
pedantic ^1.9.0
test ^1.14.2