{"id":13514333,"url":"https://github.com/simc/superpower","last_synced_at":"2026-01-11T04:52:37.802Z","repository":{"id":56840898,"uuid":"146443567","full_name":"simc/superpower","owner":"simc","description":"Lists, Iterables and Maps on steroids! 🦄 Inspired by Kotlin.","archived":false,"fork":false,"pushed_at":"2019-05-30T08:52:18.000Z","size":62,"stargazers_count":57,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-15T19:02:18.406Z","etag":null,"topics":["dart","flutter","lists","superpowers"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-28T12:22:59.000Z","updated_at":"2024-06-21T08:46:48.000Z","dependencies_parsed_at":"2022-08-29T06:50:33.838Z","dependency_job_id":null,"html_url":"https://github.com/simc/superpower","commit_stats":null,"previous_names":["leisim/superpower"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simc%2Fsuperpower","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simc%2Fsuperpower/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simc%2Fsuperpower/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simc%2Fsuperpower/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simc","download_url":"https://codeload.github.com/simc/superpower/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250167812,"owners_count":21386005,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","flutter","lists","superpowers"],"created_at":"2024-08-01T05:00:53.044Z","updated_at":"2026-01-11T04:52:37.769Z","avatar_url":"https://github.com/simc.png","language":"Dart","funding_links":[],"categories":["Uncategorized","Dart"],"sub_categories":["Uncategorized"],"readme":"![Logo](https://raw.githubusercontent.com/leisim/superpower/master/superpower.png)\n\n\n[![Travis](https://img.shields.io/travis/com/leisim/superpower/master.svg)](https://travis-ci.com/leisim/superpower) [![Coveralls](https://img.shields.io/coveralls/github/leisim/superpower.svg)](https://coveralls.io/github/leisim/superpower) [![Version](https://img.shields.io/pub/v/superpower.svg)](https://pub.dartlang.org/packages/superpower) ![Runtime](https://img.shields.io/badge/dart-%3E%3D2.0-brightgreen.svg) ![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)\n\nIf you come from Kotlin, you will appreciate all the handy extensions for lists.  \nWith superpower, you can use them in your Flutter app.\n\n### Resources:\n- [Documentation](https://pub.dartlang.org/documentation/superpower/latest/superpower/superpower-library.html)\n- [Pub Package](https://pub.dartlang.org/packages/superpower)\n- [GitHub Repository](https://github.com/leisim/superpower)\n\n\n\n# Get started 🎉\nJust wrap your existing `List` with `$(myList)` or create a new empty list with `$()` and you are good to go.\n\n```dart\nvar superList = $([0, 10, 100, 1000]);\nvar sum = superList.sum(); // 1110\nvar last = superList[-1]; // 1000\nvar lastTwo = superList.slice(-2); // [100, 1000]\n```\n\n`Iterable`s can be wrapped with `$it(myIterable)` and `Map`s with `$map(myMap)`.\n\n\n# Introduction to superpowers ❤️\n\n## Negative indices\nThis is one of the coolest features: You can use negative indices which start at\nthe last element of the list: `list[-1]` is the same as `list[list.length - 1]`.\n\n\nHere is a sample with negative indices:\n```dart\n// Negative indices: -4   -3   -2   -1\nvar superlist =  $([ '0', '1', '2', '3']);\n//             Access this ^ item:\nvar positiveItem = positiveIndices[1]; // 1\nvar negativeItem = negativeIndices[-3]; // 1\n```\nYou can use negative indices on all new and existing methods of $List and $Iterable.\n\n## slice\nGet a sublist of the collection:\n```dart\nvar list = $([0, 1, 2, 3, 4, 5]);\nvar last = list.slice(-1); // [5]\nvar lastHalf = list.slice(3); // [3, 4, 5]\nvar allButFirstAndLast = list.slice(1,-2); // [1, 2, 3, 4]\n```\n\n## sortedBy \u0026 thenBy\nSort lists by multiple properties\n```dart\nclass Dog {\n    String name;\n    String age;\n\n    Dog(this.name, this.age);\n}\n\nvar dogs = $();\ndogs.add(Dog(\"Tom\", 3));\ndogs.add(Dog(\"Charlie\", 7));\ndogs.add(Dog(\"Charlie\", 2));\ndogs.add(Dog(\"Cookie\", 4));\ndogs.add(Dog(\"Bark\", 1));\n\nvar sorted = dogs\n    .sortedBy((dog) =\u003e dog.name)\n    .thenByDescending((dog) =\u003e dog.age);\n// Bark, Cookie, Charlie (7), Charlie (2), Tom\n```\n\n## contentEquals\nCompare two lists:\n```dart\nvar list = $(['some', 'items']);\nvar equals1 = list.contentEquals(['some', 'items']); // true\nvar equals2 = list.contentEquals(['SOME', 'items']); // false\n```\n\n## minBy \u0026 maxBy\nGet the smallest or largest element from a list:\n```dart\n//Take dogs list from example above\nvar firstDogByName = dogs.minBy((dog) =\u003e dog.name); // Bark\nvar oldestDog = dogs.maxBy((dog) =\u003e dog.age); // Charlie\n````\n\n## distinctBy\nGet distinct elements from a list:\n```dart\n//Take dogs list from example above\nvar dogNames = dogs\n    .distinctBy((dog) =\u003e dog.name)\n    .map((dog) =\u003e dog.name);\n// ['Tom', 'Charlie', 'Cookie', 'Bark']\n```\n\n## flatten\nFlatten a list of iterables:\n```dart\nvar nestedList = $List([[1, 2, 3], [4, 5, 6]]);\nvar flattened = nestedList.flatten(); // [1, 2, 3, 4, 5, 6]\n```\n\n## firstOrNull \u0026 firstOrNullWhere\nFind the first element of the collection matching a predicate:\n```dart\nvar list = $(['This', 'is', 'a', 'Test']);\nvar first = list.firstOrNull; // 'This'\nvar firstWhere = list.firstOrNullWhere((s) =\u003e s.length \u003c= 2); // 'is'\nvar firtNull = list.firstOrNullWhere((s) =\u003e s.length \u003e 4); // null\n```\n\n## elementAtOrNull \u0026 elementAtOrElse\nGet the element at an index or null if the index does not exist:\n```dart\nvar list = $([0, 1, 2, 3, 4, 5, 6]);\nvar second = list.elementAtOrNull(1); // 1\nvar highIndexNull = list.elementAtOrNull(10); // null\nvar highIndexDefault = list.elementAtOrDefault(10, -1); // -1\n```\n\n## many more superpowers\nThere are many more handy superpowers (like `intersect()`, `groupBy()` and\n`associateWith()`) available. Take a look at the\n**[Documentation](https://pub.dartlang.org/documentation/superpower/latest/superpower/superpower-library.html)**.\n\n\n# \\$List, \\$Iterable and \\$Map 🦄\nThe wrappers for `List`s, `Iterable`s and `Map`s are `$List`, `$Iterable` and `$Map` they\nbehave as you would expect them to. (`$Iterable` is lazy loading while `$List`\nis not).\n\nThere is no need to work with the unwrapped classes. The wrapper classes have\nthe exact same performance as their native counterparts.\n\n**Important:** Always remember that `$List`, `$Iterable` and `$Map` are wrappers.\nThis means if you remove an item from a `$List`, it will also be removed from\nthe source list.\n```dart\nvar source = [0, 1, 2, 3];\n\nvar superList = $(source);\nsuperList.add(4);\n//source: [0, 1, 2, 3, 4]\n\nvar independantList = $(source).toList();\nindependantList.add(5);\n//source: [0, 1, 2, 3, 4]\n```\n\n\n# Features and bugs\n\nPlease file feature requests and bugs at the \n[issue tracker](https://github.com/leisim/superpower/issues).\n\n\n# Todo ✏️\n- ✔️ most important features for collections\n- ✔️ superpowers for Map\n- even more tests\n- superpowers for other classes?\n- more features for collections\n- more samples in the docs\n\n\n## MIT License\n\nCopyright (c) 2018 Simon Leier\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimc%2Fsuperpower","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimc%2Fsuperpower","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimc%2Fsuperpower/lists"}