fields_generator 0.0.2 copy "fields_generator: ^0.0.2" to clipboard
fields_generator: ^0.0.2 copied to clipboard

Fields name generator for Dart

Fields Generator #

This package provides a Dart and Flutter field name code generation for class.

Usage #

import 'package:fields_generator/fields_generator.dart';
import 'package:json_annotation/json_annotation.dart';

part 'main.fields.dart';

@Fields()
class User {
  User({
    required this.name,
    required this.age,
  });

  final String name;
  final int age;
}

Generated code #

// GENERATED CODE - DO NOT MODIFY BY HAND

// **************************************************************************
// FieldsLibraryGenerator
// **************************************************************************

part of 'main.dart';

/// [User] fields
abstract final class UserFields {
  const UserFields._();

  /// [User.name]
  static const String nameFieldName = 'name';

  /// [User.age]
  static const String ageFieldName = 'age';

  static const List<String> fieldsNames = [nameFieldName, ageFieldName];
}

/// [User] fields
@JsonEnum(
  fieldRename: FieldRename.none,
)
enum UserFieldsEnum {
  name,
  age,
}

Features #

  • ✅ Generate fields name for class

Getting started #

In your pubspec.yaml file, add the following dependency:

dependencies:
  fields_generator: 

Then, run flutter pub get in your terminal.

or run this command:

flutter pub add fields_generator

Additional information #

This package is still in development, and the API is subject to change. feel free to contribute to this package.

License #

Read more about the license here

3
likes
0
points
87
downloads

Publisher

unverified uploader

Weekly Downloads

Fields name generator for Dart

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, build, change_case, json_annotation, meta, source_gen, source_helper

More

Packages that depend on fields_generator