copy_with_e_generator 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • new50

###copy_with_e

For more examples look at the github repository

Simple, just put the CopyWithE annotation on the class

var bob = Person(age: 5, name: "bob");
var result = bob.cwPerson(age: 6, name: "bobby");

@CopyWithE()
class Person {
  final int age;
  final String name;

  Person({this.age, this.name});

  String toString() => "${age.toString()}, ${name.toString()}";
}

It works on superclasses automatically

var bob = Person(age: 5, name: "bob");
var rob = Employee(age: 9, name: "rob");
var hasAges = <HasAge>[bob, rob];
var result = hasAges.map((x) => x.cwHasAge(age: 3).age).toList();

@CopyWithE([Person, Employee])
abstract class HasAge {
  int get age;
}

class Person implements HasAge {
  final int age;
  final String name;

  Person({this.age, this.name});
}

One concrete class has two interfaces both of which have copyWith extension methods. It works! and that is why we name our copyWith cw[ClassName]

var ages = hasAges.map((x) => x.cwHasAge(age: 3).age).toList();

@CopyWithE([Person, Employee])
abstract class HasAge {
  int get age;
}

@CopyWithE([Person, Employee])
abstract class HasName {
  String get name;
}

class Person implements HasAge, HasName {
  final int age;
  final String name;

  Person({this.age, this.name});
}

class Employee implements Person {
  final int age;
  final String name;

  Employee({this.age, this.name});
}

Automatically gets subtypes if they exist in the same file also, it gets from the types parameter

    var bob = Person(age: 5, name: "bob");
    var rob = Employee(age: 9, name: "rob");
    var hasAges = <HasAge2>[bob, rob];
    var result = hasAges.map((x) => x.cwHasAge2(age: 3).age).toList();

@CopyWithE([Stuff, Employee]) //[Person, Employee])
abstract class HasAge2 {
  int get age;
}

class Person implements HasAge2 {
  final int age;
  final String name;

  Person({this.age, this.name});
}

class Employee implements Person {
  final int age;
  final String name;

  Employee({this.age, this.name});
}

For more examples look at the Examples project in the github repository

## 1.0.2
- Changed the description because it was too long!

## 1.0.1
- Added examples and changes recommended by pub.

## 1.0.0
- First published version

example/example.dart

import 'package:copy_with_e_annotation/copy_with_e_annotation.dart';

//see example project in github

@CopyWithE()
class Person {
  final int age;
  final String name;

  Person({this.age, this.name});

  String toString() => "${age.toString()}, ${name.toString()}";
}

Use this package as a library

1. Depend on it

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


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

We analyzed this package on Feb 26, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

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.

Format lib/src/CopyWithEGenerator.dart.

Run dartfmt to format lib/src/CopyWithEGenerator.dart.

Format lib/src/adiHelpers.dart.

Run dartfmt to format lib/src/adiHelpers.dart.

Format lib/src/createCopyWith.dart.

Run dartfmt to format lib/src/createCopyWith.dart.

Format lib/src/helpers.dart.

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.1 <3.0.0
analyzer >=0.35.4 <0.40.0 0.39.4
basic_utils ^2.4.8 2.5.2
build ^1.2.2 1.2.2
copy_with_e_annotation ^1.0.1 1.0.1
dartx ^0.3.0 0.3.0
dartz ^0.8.3 0.8.9 0.9.0-dev.6
quiver ^2.0.1 2.1.2+1
source_gen ^0.9.4+7 0.9.5
Transitive dependencies
_fe_analyzer_shared 1.0.3
args 1.5.2
asn1lib 0.6.4
async 2.4.0
characters 0.3.1 0.5.0
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
dart_style 1.3.3
glob 1.2.0
html 0.14.0+3
http 0.12.0+4
http_parser 3.1.3
intl 0.16.1
js 0.6.1+1
json_annotation 3.0.1
logging 0.11.4
matcher 0.12.6
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.9.1
path 1.6.4
pedantic 1.9.0
pointycastle 1.0.2
pub_semver 1.4.3
source_span 1.6.0
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
time 1.2.0
typed_data 1.1.6
watcher 0.9.7+13
yaml 2.2.0
Dev dependencies
build_runner ^1.7.3
test ^1.11.1