Skip to content

Commit

Permalink
Create canonicalized-maps-in-dart.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
vandadnp committed Dec 30, 2022
1 parent 26ca006 commit e933936
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 🐦 Twitter https://twitter.com/vandadnp
// πŸ”΅ LinkedIn https://linkedin.com/in/vandadnp
// πŸŽ₯ YouTube https://youtube.com/c/vandadnp
// πŸ’™ Free Flutter Course https://linktr.ee/vandadnp
// πŸ“¦ 11+ Hours Bloc Course https://youtu.be/Mn254cnduOY
// πŸ”Ά 7+ Hours MobX Course https://youtu.be/7Od55PBxYkI
// πŸ¦„ 8+ Hours RxSwift Coursde https://youtu.be/xBFWMYmm9ro
// 🀝 Want to support my work? https://buymeacoffee.com/vandad

import 'package:collection/collection.dart'; // flutter pub add collection
import 'dart:developer' as devtools show log;

const personsAndAges = {
'Andy': 42,
'John': 30,
'jane': 25, // lower-cased intentionally
'Bob': 30,
'Jenny': 25,
};

void testIt() {
final canonicalized = CanonicalizedMap.from(
personsAndAges,
(key) => key.characters.first.toLowerCase(),
);

canonicalized.log(); // prints {Andy: 42, Jenny: 25, Bob: 30}
}

0 comments on commit e933936

Please sign in to comment.