easy_entry 1.0.0 copy "easy_entry: ^1.0.0" to clipboard
easy_entry: ^1.0.0 copied to clipboard

A simple, readable and concise way to deal with modifying, inserting and removing Map entries in Dart.

A simple, readable and concise way to deal with modifying, inserting and removing Map entries in Dart.

Inspired on Rust's Entry API.

Usage #

Add easy_entry to our dependencies in pubspec.yaml:

dependencies:
  easy_entry: ^1.0.0
copied to clipboard

Next, import the library:

import 'package:easy_entry/easy_entry.dart';
copied to clipboard

Get a map's entry #

Use the .entry(key) method on a map to get an entry:

final map = <int, List<String>>{};

map.entry(10);
copied to clipboard

Then, you can perform operations on your entry to modify, insert or remove it from the map:

final items = map
      .entry(10)
      .retainIf((value) => value.isNotEmpty)
      .andModify((value) => value.add('Another Item'))
      .orInsert([]);
copied to clipboard
3
likes
160
points
37
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.26 - 2025.04.10

A simple, readable and concise way to deal with modifying, inserting and removing Map entries in Dart.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

More

Packages that depend on easy_entry