easy_entry 1.0.1
easy_entry: ^1.0.1 copied to clipboard
A simple, readable and concise way to deal with modifying, inserting and removing Map entries in Dart.
example/easy_entry_example.dart
import 'package:easy_entry/easy_entry.dart';
void main() {
final map = <int, List<String>>{
10: ['Hello'],
};
final helloWorld = map
.entry(10)
.andModify((value) => value.add('World'))
.retainIf((value) => value.length == 2)
.orInsert(['Default']);
print(helloWorld);
final item = map
.entry(20)
.andModify((value) => value.remove('Something from the list'))
.orNull;
print(item);
}
copied to clipboard