meta_types_json 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 40

meta_types_json #

json mixin generation for meta_types

0.0.1 #

  • initial annotations for annotating classes with MetaJson()

example/example.dart

import 'package:meta_types/meta_types.dart';
import 'package:meta_types_json/meta_types_json.dart';

part 'example.g.dart';

@MetaJson()
@EnumClass(int)
abstract class $MyEnum {
  static int a;
  static int b;
}

@MetaJson()
@SealedClass()
abstract class $MySealedClass {
  String get string;
  int get integer;
}

@MetaJson()
@DataClass()
abstract class $MyDataClass {
  int get value => 0;
  $NestedObject get nested;
  List<int> get list;
  Set<int> get st;
  Map<String, int> get map;
  List<$NestedObject> get listNested;
  Set<$NestedObject> get setNested;
  Map<String, $NestedObject> get mapNested;
  $MyEnum get enumValue;
  $MySealedClass get sealed;
}

@MetaJson()
@DataClass()
abstract class $NestedObject {
  int get value => 0;
}

void main() {
  final myObj = MyDataClass(
    value: 2,
    nested: NestedObject(value: 99),
    list: [5],
    st: [22222].toSet(),
    map: {'sdf': 4},
    listNested: [NestedObject(value: 34)],
    setNested: [NestedObject(value: 4)].toSet(),
    mapNested: {'sdf': NestedObject(value: 4)},
    sealed: MySealedClass.integerFactory(2),
    enumValue: MyEnum.a,
  );

  print('original');
  print(myObj.value);
  print(myObj.nested.value);
  print(myObj.list);
  print(myObj.st);
  print(myObj.map);
  print(myObj.listNested);
  print(myObj.setNested);
  print(myObj.mapNested);
  print(myObj.sealed);
  print(myObj.enumValue);

  final dynamic json = myObj.toJson();
  print('serialized');
  print(json);

  final deserialized =
      MyDataClassMetaJson.fromJson(json as Map<String, dynamic>);

  print('deserialized');
  print(deserialized.value);
  print(deserialized.nested.value);
  print(deserialized.list);
  print(deserialized.st);
  print(deserialized.map);
  print(deserialized.listNested);
  print(deserialized.setNested);
  print(deserialized.mapNested);
  print(deserialized.sealed);
  print(deserialized.enumValue);
}

Use this package as a library

1. Depend on it

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


dependencies:
  meta_types_json: ^0.0.1

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:meta_types_json/meta_types_json.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
14
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
21
Overall:
Weighted score of the above. [more]
40
Learn more about scoring.

We analyzed this package on Nov 22, 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:meta_types_json/meta_types_json.dart.

Health issues and suggestions

Document public APIs. (-1 points)

8 out of 8 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/meta_types_json.dart. (-1.99 points)

Analysis of lib/meta_types_json.dart reported 4 hints:

line 16 col 5: DO use curly braces for all flow control structures.

line 16 col 12: Unnecessary new keyword.

line 19 col 35: DO use curly braces for all flow control structures.

line 20 col 12: Unnecessary new keyword.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://github.com/davidmarne/dart_meta_types/meta_types_json was unreachable.

Package is getting outdated. (-29.04 points)

The package was last published 67 weeks ago.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2-0-0-dev <3.0.0
meta ^1.0.0 1.1.8
meta_types ^0.1.0 0.1.0
Dev dependencies
build_runner ^0.9.0
meta_types_generator ^0.1.0
meta_types_json_generator