prototype 1.0.0

  • Installing
  • Versions
  • 43


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);

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 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


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
98 / 100
Reflects how tidy and up-to-date the package is. [more]
69 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: Flutter, web, other

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


  • Maintain

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

  • The description is too short.

    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.

    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.1+4
Transitive dependencies
path 1.5.1
stack_trace 1.9.1
Dev dependencies
test ^0.12.17+3