prototype 1.0.0

  • Installing
  • Versions
  • 30


version 1.0.0 build status

Prototypal inheritance for Dart.

final ProtoType Animal = new ProtoType(
    name: 'Animal',
    prototype: {#warmblooded: false},
    constructor: (ctx, [args, named]) {
        ..clazz = args[0]
        ..species = args[1];

final ProtoType Mammal = new ProtoType.extend(Animal,
    name: 'Mammal',
    prototype: {#warmblooded: true}, constructor: (ctx, [args, named]) {
  ctx.superConstructor(['Mammalia', args[0]]);

final ProtoType Human = new ProtoType.extend(Mammal, name: 'Human',
    constructor: (ctx, [args, named]) {
  ctx.superConstructor(['Homo sapiens']); = args[0];
}, prototype: {
  #introduce: (ctx, [args, named]) {
    return 'Hi! My name is ${}.';

main() {
  test('human', () {
    var bob = Human.instance(['Bob']);
    expect(bob.isInstanceOf(Human), isTrue);
    expect(bob.isInstanceOf(Mammal), isTrue);
    expect(bob.isInstanceOf(Animal), isTrue);
    expect(bob.warmblooded, isTrue);
    expect(bob.clazz, equals('Mammalia'));
    expect(bob.species, equals('Homo sapiens'));
    expect(, equals('Bob')); = 'Tim';
    expect(bob.introduce(), equals('Hi! My name is Tim.'));

  test('clone', () {
    var kingOfPop = Human.instance(['Michael Jackson']);
    var imposter = kingOfPop.clone();

    // People can mimic...
    expect(imposter.deepEquals(kingOfPop), isTrue);

    // But none can ever copy another's identity.
    expect(imposter == kingOfPop, isFalse);

Use this package as a library

1. Depend on it

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

  prototype: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:prototype/prototype.dart';
Version Uploaded Documentation Archive
1.0.0 Dec 17, 2016 Go to the documentation of prototype 1.0.0 Download prototype 1.0.0 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.1.0
  • pana: 0.12.7


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:prototype/prototype.dart.

Health suggestions

Fix lib/prototype.dart. (-0.50 points)

Analysis of lib/prototype.dart reported 1 hint:

line 88 col 2: 'proxy' is deprecated and shouldn't be used.

Maintenance issues and suggestions

Maintain (-20 points)

Changelog entries help clients to follow the progress in your code.

Package is getting outdated. (-96.71 points)

The package was released 102 weeks ago.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use prototype.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0
matcher ^0.12.0+2 0.12.4
Transitive dependencies
path 1.6.2
stack_trace 1.9.3
Dev dependencies
test ^0.12.17+3