identifiable 0.5.1 copy "identifiable: ^0.5.1" to clipboard
identifiable: ^0.5.1 copied to clipboard

Identifiable mixin and id-based collection helpers for Dart.

Identifiable #

Mixin and id-based collection helpers for Dart, generic over the id type.

import 'package:identifiable/identifiable.dart';

class User with Identity {  // Identity = Identifiable<String>
  User(this.id);
  @override
  final String id;
}

final users = [User('a'), User('b')];
users.byId('a');                 // User?
users.withoutId('a');            // Iterable<User>
users.updateById('a', (u) => u); // List<User> — replace by id
users.toMapById();               // Map<String, User>
// also: includes, overlaps, indexWhereById; Map: upsert, upsertAll, removeById, updateById

For other id types use Identifiable<I> — e.g. a record as a compound key: class Chat with Identifiable<(String, String)> (id => (adId, userId)).

1
likes
0
points
642
downloads

Publisher

unverified uploader

Weekly Downloads

Identifiable mixin and id-based collection helpers for Dart.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

canon_codec, meta

More

Packages that depend on identifiable