dart_mem_annotation 0.0.1 copy "dart_mem_annotation: ^0.0.1" to clipboard
dart_mem_annotation: ^0.0.1 copied to clipboard

A Code Generator Plugin to Generate Models, Entities and Mappers base on Annotation.

Dart Model Entity Mapper (MEM) Annotation

PubVersion PubPoints build Latest dartdocs

Pub

android ios ios linux windows mac-os

Mem Annotation Generator is a Code Generator Plugin to Generate Models, Entities and Mapper base on Annotation. This package designed to prevent adding extra codes to add Models, Entities and Mappers one by one. You can use it for Models, APIs and JSONs.

Contents: #

Getting Started #

Add dependencies in the pubspec.yaml:

dependencies:
  dart_mem_annotation: ^latest
  
  # If Freezed Code Generations needed:
  freezed: ^2.5.7
  json_annotation: ^4.9.0

dev_dependencies:
  build_runner: ^latest
  dart_mem_annotation_generator: ^latest

  # If Freezed Code Generations needed:
  freezed_annotation: ^2.4.4
  json_serializable: ^6.8.0

Generator Library Link on pub.dev:

Pub

Get the Changes by:

flutter pub get

or

dart pub get

Usage #

import 'package:dart_mem_annotation/annotation.dart';

Add desired @Annotation on top of the desired class and set the desired Options. Also InnerClasses are supported.

Such as:

@Mem.all()
class SomeClass {
  String? someStringField;
  bool? someBooleanField;
  List<String>? someListField;
  SomeInnerClass? someInnerClass;
}

@Mem.all()
class SomeInnerClass {
  bool active;
  String someName;
  String someDescription;
}

Note

InnerClasses if decorated with the annotation they all will have generated Model, Entity and Mappers, but if not, the class itself will use in the main class.

then you should run the build_runner to generate the codes and creating related file and include all the pages, controllers, components and repositories in one place and prepared to use. You can use

dart pub run build_runner build --delete-conflicting-outputs

You can check the /example for a more complete example, more details and further information. #

Options #

You can set some annotations and its Options in the @Annotation Available Annotations:

  • @Mem.all: Will Generate all options, including Mode, Entity, and Mappers.

Available Options:

  • @Mem
    • as: Change the Name of the Page in the dependencies and use it as another name.
    • withFreezed: All Generated Classes will decorate with @freezed Annotation, and all Freezed classes will generate after Mem Code Generation.
    • extendsBaseClass: (Not Recommended) - Generated Classes will extends the Original Annotated Class, and without this option all classes will be independent.

Docs #

build

About Author #

Resam Taghipour #

Pub account Pub Pub

Packages and Dependencies #

Pub Pub Pub Pub

License #

This project is licensed under the 'BSD-3-Clause' License - see the LICENSE for details.

Pub

2
likes
0
points
248
downloads

Publisher

verified publisherresam.site

Weekly Downloads

A Code Generator Plugin to Generate Models, Entities and Mappers base on Annotation.

Homepage
Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

resam.site

License

unknown (license)

Dependencies

build_runner, dartdoc

More

Packages that depend on dart_mem_annotation