papaya 0.0.1+1 copy "papaya: ^0.0.1+1" to clipboard
papaya: ^0.0.1+1 copied to clipboard

outdatedDart 1 only

Commons library inspired by Guava

#Papaya

Papaya

Papaya is a commons librairies for Dart inspired a lot by Guava. It provides help to write :

  • hashCode / == / toString methods

Build Status

Papaya is distributed under the Apache 2.0 License.

Getting Started #

Create a Dart project and add a pubspec.yaml file to it

dependencies:
  papaya: any

and run

pub install

Samples #

hashCode / == / toString methods #

import 'package:papaya/papaya.dart';

main() {
  var john = new Person("John", 25);
  var unknown = new Person(null, 37);
  
  // hashCode
  print(john.hashCode);
  print(unknown.hashCode);
 
  // toString
  print(john.toString());
  print(unknown.toString());
  print(unknown.alternativeToString());
  
  // equals
  print(john == unknown);
}

class Person {
  
  String name;
  int age;
  
  Person(this.name, this.age);
  
  int get hashCode => hashcode([name, age]);
  
  bool operator==(other) => equal(name, other.name) && equal(age, other.age);
  
  String toString() => toStringHelper(this.runtimeType).add("name", name).add("age", age).toString();
  
  String alternativeToString() => 
    toStringHelper(this.runtimeType).omitNullValues().add("name", name).add("age", age).toString();
  
}

it print :

1495571744
998
Person{name=John, age=25}
Person{name=null, age=37}
Person{age=37}
false
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Commons library inspired by Guava

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on papaya