serde_generator 1.1.0+2

  • Readme
  • Changelog
  • Example
  • Installing
  • 58

Serde Generator #

Is a builder, to generate code to serialize and deserialize

Getting Started #

Installing #

Add the following to your pubspec

dev_dependencies:
    build_runner: ^1.0.0
    serde_generator: ^1.0.0

run pub get

Using #

Well, the ideia is you dont use it alone :P, this is part of the serde package, please refear to https://pub.dev/packages/serde

1.0.0 First release #

The minimum necessary to the package work and support the annotations

1.0.1 #

  • Add treatment to Nom primitive types

1.0.2 #

  • Treat bug, when nested map inside list duplicate the type

1.0.3 #

  • Generate the generic function fromJson with dynamic type\

1.0.4 #

  • Correcting bug, of GIT

1.0.5 #

  • Add possibility of deserialize function and serialize function, also correct some minor bugs

1.0.6 #

  • Deleting the dart_serde, and turning serde into the main repo, and adding examples

1.0.7 #

  • Correcting error of types, and to be right by the linter parameters

1.0.8 #

  • Change treatment for list

1.0.9 #

  • Implementation of cases transformation
  • Fix of a bug related to the use of nullable aside with nested;

1.0.9+1 #

  • Fix for a bug on deserialzie, he tried to build the path to check deserializable path, when null

1.0.9+2 #

  • Fix bug when nullable and with no @Prop

1.0.9+3 #

  • The last bug was not corrected in the right way, the verification dont parse to snake case

1.1.0 #

  • Dont working deserialize(?)

1.1.0+1 #

  • Serde DateTime

1.1.0+2 #

  • Correcting the deserialization of Map type

example/example.dart

// Remember, all this, will only work if you are using the complete dart_serde package,this package only contains the annotations

import 'dart:convert';

import 'package:serde/src/serde.dart';

@Serde()
class ExampleClass {
  bool attr1;
}

// Just from the annotations the code that will be generated is something like

ExampleClass _fromJson(Map<String, dynamic> data) {
  ExampleClass exampleClass = ExampleClass();
  exampleClass.attr1 = data['attr1'] as bool;
  return exampleClass;
}

String _toJson(ExampleClass instance) {
  Map<String, dynamic> mapper = {
    'attr1': instance.attr1.toString()
  };
  return json.encode(mapper);
}

// Then you have to add to your class
// factory ExampleClass.fromJson(Map<String, dynamic> data) => _fromJson(data);
//  and for serialize toJson(ExampleClass instance) => _toJson(instance);

// You can also add @Prop annotation to an field, if you want to change-it

Use this package as a library

1. Depend on it

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


dependencies:
  serde_generator: ^1.1.0+2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:serde_generator/serde_generator.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
15
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]
58
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: other

Primary library: package:serde_generator/serde_generator.dart with components: io, build, mirrors.

Health suggestions

Format lib/builder.dart.

Run dartfmt to format lib/builder.dart.

Format lib/serde_generator.dart.

Run dartfmt to format lib/serde_generator.dart.

Format lib/src/helpers/deserialize_element.dart.

Run dartfmt to format lib/src/helpers/deserialize_element.dart.

Fix additional 4 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/helpers/generator_serde.dart (Run dartfmt to format lib/src/helpers/generator_serde.dart.)
  • lib/src/helpers/mixins/string_modifiers.dart (Run dartfmt to format lib/src/helpers/mixins/string_modifiers.dart.)
  • lib/src/helpers/serialize_element.dart (Run dartfmt to format lib/src/helpers/serialize_element.dart.)
  • lib/src/serde_generator.dart (Run dartfmt to format lib/src/serde_generator.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
analyzer ^0.38.2 0.38.5
build >=0.12.0 <2.0.0 1.2.0
serde ^1.0.6 1.0.6
source_gen ^0.9.0 0.9.4+5
Transitive dependencies
args 1.5.2
async 2.4.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.3
csslib 0.16.1
dart_style 1.3.1
front_end 0.1.27
glob 1.1.7
html 0.14.0+3
kernel 0.3.27
logging 0.11.3+2
meta 1.1.7
package_config 1.1.0
path 1.6.4
pedantic 1.8.0+1
pub_semver 1.4.2
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+12
yaml 2.2.0
Dev dependencies
build_runner ^1.7.1
build_test ^0.10.0
test ^1.0.0