testik_generator 0.0.2

  • Readme
  • Changelog
  • Installing
  • 35

Dart Immutable Data Class Builder #

Example Model

import 'package:testik/testik.dart';

part 'models.g.dart';

@data
abstract class User implements _$User {
  User._();
  factory User(String name, int age, String weight) = _$User$._;
}

@data
abstract class Animal implements _$Animal {
  Animal._();
  factory Animal(String name) = _$Animal$._;
} 

@data
abstract class Home implements _$Home {
  Home._();
  factory Home(User owner, Animal cat) = _$Home$._;
} 

@data
abstract class Shelter implements _$Shelter {
  Shelter._();
  factory Shelter(Animal dog, {Animal cat, Animal mouse}) = _$Shelter$._;
} 

Example Usage

void main() {
  
  // Properties
  var user = User("Joe Doe", 33, "OK");
  assert(user.name == "Joe Doe");
  assert(user.age == 33);
  assert(user.weight == "OK"); 
  print(user);

  // Equals
  var animal = Animal("Dog");
  assert(animal.name == "Dog");
  assert(Animal("Dog") == Animal("Dog"));  
  print(animal);
  print(animal.hashCode);

  // Named parameters
  var shelter = Shelter(Animal("doggo"), cat: Animal("Tom"), mouse: Animal("Jerry"));
  print(shelter);
}

Changelog #

0.0.2 #

  • Add equals, teString and hashCode implementations
  • Support named paramters

0.0.1 #

  • Initial version.

Use this package as a library

1. Depend on it

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


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

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

  • Dart: 2.6.1
  • pana: 0.12.21

Analysis issues and suggestions

Check SDKs in pubspec.yaml.

The following unknown SDKs are in pubspec.yaml: {build, source_gen}.

pana doesn’t recognize them; please remove the sdk entry or report the issue.

Health issues and suggestions

Document public APIs. (-1 points)

2 out of 2 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/src/template/hash_code.dart. (-0.50 points)

Analysis of lib/src/template/hash_code.dart reported 1 hint:

line 35 col 8: Use isEmpty instead of length

Fix lib/src/template/testik.dart. (-0.50 points)

Analysis of lib/src/template/testik.dart reported 1 hint:

line 5 col 8: Unused import: 'comma_list.dart'.

Fix lib/src/template/util.dart. (-0.50 points)

Analysis of lib/src/template/util.dart reported 1 hint:

line 9 col 48: The class 'Stream' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Fix additional 5 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/template/comma_list.dart (Run dartfmt to format lib/src/template/comma_list.dart.)
  • lib/src/template/params.dart (Run dartfmt to format lib/src/template/params.dart.)
  • lib/src/template/to_string.dart (Run dartfmt to format lib/src/template/to_string.dart.)
  • lib/src/testik_generator.dart (Run dartfmt to format lib/src/testik_generator.dart.)
  • lib/testik_generator.dart (Run dartfmt to format lib/testik_generator.dart.)

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Check SDKs in pubspec.yaml.

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (analyzer).

Fix analysis_options.yaml.

The analyzer can't parse analysis_options.yaml.

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.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and testik_generator.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

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
analyzer >=0.34.0 <0.37.0 0.36.4 0.39.2+1
build >=0.12.0 <2.0.0 1.2.2
source_gen ^0.9.0 0.9.4+4 0.9.4+6
testik >=0.0.1 <0.1.0 0.0.2
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.4
csslib 0.16.1
dart_style 1.2.9 1.3.3
front_end 0.1.19 0.1.29
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
kernel 0.3.19 0.3.29
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
path 1.6.4
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+13
yaml 2.2.0
Dev dependencies
build_runner ^1.0.0
build_test ^0.10.3
logging ^0.11.0 0.11.3+2
pedantic ^1.4.0 1.9.0
test ^1.0.0