{"id":24833513,"url":"https://github.com/alexcmgit/dartf","last_synced_at":"2026-01-11T04:14:24.457Z","repository":{"id":178098357,"uuid":"658105368","full_name":"alexcmgit/dartf","owner":"alexcmgit","description":"Superpowers for Dart. Collection of useful static extension methods. Hard fork of dartx and many others.","archived":false,"fork":false,"pushed_at":"2023-10-22T05:22:09.000Z","size":108,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-04T23:01:27.752Z","etag":null,"topics":["collection","dart","dartf","dartx","future","io","method","numbers","stream","strings","utils"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/dartf","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexcmgit.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,"governance":null}},"created_at":"2023-06-24T19:32:03.000Z","updated_at":"2023-11-27T03:05:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"24f08561-956a-4076-9c02-09671908dcbe","html_url":"https://github.com/alexcmgit/dartf","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"8fb27b927c6ca73d986c11a9632c9192e3ca053b"},"previous_names":["alexrintt/dartf","alexcmgit/dartf"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/alexcmgit/dartf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcmgit%2Fdartf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcmgit%2Fdartf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcmgit%2Fdartf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcmgit%2Fdartf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexcmgit","download_url":"https://codeload.github.com/alexcmgit/dartf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcmgit%2Fdartf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28281368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T03:48:11.750Z","status":"ssl_error","status_checked_at":"2026-01-11T03:48:02.765Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["collection","dart","dartf","dartx","future","io","method","numbers","stream","strings","utils"],"created_at":"2025-01-31T02:02:15.028Z","updated_at":"2026-01-11T04:14:24.412Z","avatar_url":"https://github.com/alexcmgit.png","language":"Dart","readme":"[![Pub Dev Dartf](https://img.shields.io/pub/v/dartf?label=pub.dev/dartf)](https://pub.dev/packages/dartf) [![Dart CI](https://github.com/alexrintt/dartf/actions/workflows/dartf.yml/badge.svg)](https://github.com/alexrintt/dartf/actions/workflows/dartf.yml)\n\n_If you miss an extension, please open an issue or pull request_\n\n### Resources:\n\n- [Documentation](https://pub.dev/documentation/dartf/latest/dartf/dartf-library.html)\n- [Pub Package](https://pub.dev/packages/dartf)\n- [GitHub Repository](https://github.com/alexrintt/dartf)\n\nOn this page you can find some of the extensions. Take a look at the docs to see all of them.\n\n## Getting started\n\nAdd the following to your `pubspec.yaml`:\n\n```dart\ndependencies:\n  dartf: any\n```\n\nAfter you import the library, you can use the extensions.\n\n```dart\nimport 'package:dartf/dartf.dart';\n\nfinal slice = [1, 2, 3, 4, 5].slice(1, -2); // [2, 3, 4]\n```\n\n## Iterable\n\n### .slice()\n\nReturns elements at indices between `start` (inclusive) and `end` (inclusive).\n\n```dart\nfinal list = [0, 1, 2, 3, 4, 5];\nfinal last = list.slice(-1); // [5]\nfinal lastHalf = list.slice(3); // [3, 4, 5]\nfinal allButFirstAndLast = list.slice(1, -2); // [1, 2, 3, 4]\n```\n\n### .sortedBy() \u0026 .thenBy()\n\nSort lists by multiple properties.\n\n```dart\nfinal dogs = [\n  Dog(name: \"Tom\", age: 3),\n  Dog(name: \"Charlie\", age: 7),\n  Dog(name: \"Bark\", age: 1),\n  Dog(name: \"Cookie\", age: 4),\n  Dog(name: \"Charlie\", age: 2),\n];\n\nfinal 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### .distinctBy()\n\nGet distinct elements from a list.\n\n```dart\nfinal list = ['this', 'is', 'a', 'test'];\nfinal distinctByLength = list.distinctBy((it) =\u003e it.length); // ['this', 'is', 'a']\n```\n\n### .flatten()\n\nGet a new lazy `Iterable` of all elements from all collections in a collection.\n\n```dart\nfinal nestedList = [[1, 2, 3], [4, 5, 6]];\nfinal flattened = nestedList.flatten(); // [1, 2, 3, 4, 5, 6]\n```\n\n### .chunkWhile() \u0026 .splitWhen()\n\nChunk entries as long as two elements match a predicate:\n\n```dart\nfinal list = [1, 2, 4, 9, 10, 11, 12, 15, 16, 19, 20, 21];\nfinal increasingSubSequences = list.chunkWhile((a, b) =\u003e a + 1 == b);\n\n// increasingSubSequences = [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]]\n```\n\n`splitWhen` is the opposite of `chunkWhile` that starts a new chunk every time\nthe predicate _didn't_ match.\n\n## int\n\n### buildString()\n\nBuilds new string by populating newly created `StringBuffer` using provided `builderAction`\nand then converting it to `String`.\n\n```dart\nfinal word = buildString((sb) {\n  for (var i = 0; i \u003c 10; i++) {\n    sb.write(i);\n  }\n});\n// 0123456789\n``` \n\n### .ordinal\n\nReturns an ordinal number of `String` type for any integer\n\n```dart\nfinal a = 1.ordinal();  // 1st\nfinal b = 108.ordinal();  // 108th\n```\n\n## String\n\n### .capitalize\n\nReturns a copy of the string having its first letter uppercased, or the original string, if it's empty or already starts with an upper case letter.\n\n```dart\nfinal word = 'abcd'.capitalize(); // Abcd\nfinal anotherWord = 'Abcd'.capitalize(); // Abcd\n```\n\n### .decapitalize\n\nReturns a copy of the string having its first letter lowercased, or the original string, if it's empty or already starts with a lower case letter.\n\n```dart\nfinal word = 'abcd'.decapitalize(); // abcd\nfinal anotherWord = 'Abcd'.decapitalize(); // abcd\n```\n  \n### .isAscii\n\nReturns `true` if the string is ASCII encoded.\n\n```dart\nfinal isAscii = 'abc123 !,.~'.isAscii; // true\nfinal isNotAscii = '§3'.isAscii; // false\n```\n\n### .isBlank\n\nReturns `true` if this string is empty or consists solely of whitespace characters.\n\n```dart\nfinal notBlank = '   .'.isBlank; // false\nfinal blank = '  '.isBlank; // true\n```\n\n### .isDouble\n\nReturns `true` if the string can be parsed as a double.\n\n```dart\nfinal a = ''.isDouble; // false\nfinal b = 'a'.isDouble; // false\nfinal c = '1'.isDouble; // true\nfinal d = '1.0'.isDouble; // true\nfinal e = '123456789.987654321'.isDouble; // true\nfinal f = '1,000'.isDouble; // false\n```\n\n### .isInt\n\nReturns `true` if the string can be parsed as an integer.\n\n```dart\nfinal a = ''.isInt; // false\nfinal b = 'a'.isInt; // false\nfinal c = '1'.isInt; // true\nfinal d = '1.0'.isInt; // false\nfinal e = '1,000'.isInt; // false\n```\n\n### .isLatin1\n\nReturns `true` if the string is Latin 1 encoded.\n\n```dart\nfinal isLatin1 = '§Êü'.isLatin1; // true\nfinal isNotLatin1 = 'ő'.isLatin1; // false\n```\n\n### .isLowerCase\n\nReturns `true` if the entire string is lower case.\n\n```dart\nfinal a = 'abc'.isLowerCase; // true\nfinal b = 'abC'.isLowerCase; // false\nfinal c = '   '.isLowerCase; // true\nfinal d = ''.isLowerCase; // false\n```\n\n### .isNotBlank\n\nReturns `true` if this string is not empty and contains characters except whitespace characters.\n\n```dart\nfinal blank = '  '.isNotBlank; // false\nfinal notBlank = '   .'.isNotBlank; // true\n```\n\n### .isNullOrEmpty\n\nReturns `true` if the String is either `null` or empty.\n\n```dart\nfinal isNull = null.isNullOrEmpty; // true\nfinal isEmpty = ''.isNullOrEmpty; // true\nfinal isBlank = ' '.isNullOrEmpty; // false\nfinal isLineBreak = '\\n'.isNullOrEmpty; // false\n```\n\n### .isNotNullOrEmpty\n\nReturns `true` if the String is neither `null` nor empty.\n\n```dart\nfinal isNull = null.isNullOrEmpty; // true\nfinal isEmpty = ''.isNullOrEmpty; // true\nfinal isBlank = ' '.isNullOrEmpty; // false\nfinal isLineBreak = '\\n'.isNullOrEmpty; // false\n```\n\n### .isNullOrBlank\n\nReturns `true` if the String is either `null` or blank.\n\n```dart\nfinal isNull = null.isNullOrBlank; // true\nfinal isEmpty = ''.isNullOrBlank; // true\nfinal isBlank = ' '.isNullOrBlank; // true\nfinal isLineBreak = '\\n'.isNullOrBlank; // true\nfinal isFoo = ' foo '.isNullOrBlank; // false\n```\n\n### .isNotNullOrBlank\n\nReturns `true` if the String is neither `null` nor blank.\n\n```dart\nfinal isNull = null.isNullOrBlank; // true\nfinal isEmpty = ''.isNullOrBlank; // true\nfinal isBlank = ' '.isNullOrBlank; // true\nfinal isLineBreak = '\\n'.isNullOrBlank; // true\nfinal isFoo = ' foo '.isNullOrBlank; // true\n```\n\n### .isUpperCase\n\nReturns `true` if the entire string is upper case.\n\n```dart\nfinal a = 'ABC'.isUpperCase; // true\nfinal b = 'ABc'.isUpperCase; // false\nfinal c = '   '.isUpperCase; // true\nfinal d = ''.isUpperCase; // false\n```\n\n### .md5\n\nCalculates the MD5 digest and returns the value as a string of hexadecimal digits.\n\n```dart\nfinal a = 'abc'.md5; // 900150983cd24fb0d6963f7d28e17f72\nfinal b = 'ഐ⌛酪Б👨‍👨‍👧‍👦'.md5; // c7834eff7c967101cfb65b8f6d15ad46\n```\n\n### .urlEncode\n\nTranslates a string into application/x-www-form-urlencoded format using a specific encoding scheme.\n\n```dart\nconst originalUrl = 'Hello Ladies + Gentlemen, a signed OAuth request!';\nfinal encodedUrl = originalUrl.urlEncode;\n// 'Hello%20Ladies%20+%20Gentlemen,%20a%20signed%20OAuth%20request!'\n```\n\n### .urlDecode\n\nDecodes an application/x-www-form-urlencoded string using a specific encoding scheme.\n\n```dart\nconst encodedUrl = 'Hello%20Ladies%20+%20Gentlemen,%20a%20signed%20OAuth%20request!';\nfinal decodedUrl = encodingUrl.urlDecode;\n// 'Hello Ladies + Gentlemen, a signed OAuth request!'\n```\n\n### .removePrefix(), .removeSuffix() and .removeSurrounding()\n\nRemove a prefix, a suffix, or both from a given string:\n\n```dart\nfinal name = 'James Bond'.removePrefix('James '); // Bond\nfinal milliseconds = '100ms'.removeSuffix('ms'); // 100\nfinal text = '\u003cp\u003eSome HTML\u003c/p\u003e'\n  .removeSurrounding(prefix: '\u003cp\u003e', suffix: '\u003c/p\u003e'); // Some HTML\n```\n\n### .reversed\n\nReturns a new string with characters in reversed order.\n\n```dart\nfinal emptyString = ''.reversed; // ''\nfinal reversed = 'abc🤔'.reversed; // '🤔cba'\n```\n\n### .slice()\n\nReturns a new substring containing all characters including indices [start] and [end].\nIf [end] is omitted, it is being set to `lastIndex`.\n\n```dart\nfinal sliceOne = 'awesomeString'.slice(0,6)); // awesome\nfinal sliceTwo = 'awesomeString'.slice(7)); // String\n```\n\n### .toDoubleOrNull()\n\nParses the string as a `double` and returns the result or `null` if the String is not a valid representation of a number.\n\n```dart\nfinal numOne = '1'.toDoubleOrNull(); // 1.0\nfinal numTwo = '1.2'.toDoubleOrNull(); // 1.2\nfinal blank = ''.toDoubleOrNull(); // null\n```\n\n### .toInt()\n\nParses the string as an integer and returns the result. The radix (base) thereby defaults to 10. Throws a `FormatException` if parsing fails.\n\n```dart\nfinal a = '1'.toInt(); // 1\nfinal b = '100'.toInt(radix: 2); // 4\nfinal c = '100'.toInt(radix: 16); // 256\nfinal d = '1.0'.toInt(); // throws FormatException\n```\n\n### .toIntOrNull()\n\nParses the string as an integer or returns `null` if it is not a number.\n\n```dart\nfinal number = '12345'.toIntOrNull(); // 12345\nfinal notANumber = '123-45'.toIntOrNull(); // null\n```\n\n### .toUtf8()\n\nConverts String to UTF-8 encoding.\n\n```dart\nfinal emptyString = ''.toUtf8(); // []\nfinal hi = 'hi'.toUtf8(); // [104, 105]\nfinal emoji = '😄'.toUtf8(); // [240, 159, 152, 132]\n\n```\n\n### .toUtf16()\n\nConverts String to UTF-16 encoding.\n\n```dart\nfinal emptyString = ''.toUtf16(); // []\nfinal hi = 'hi'.toUtf16(); // [104, 105]\nfinal emoji = '😄'.toUtf16(); // [55357, 56836]\n```\n\n### .orEmpty()\n\nReturns the string if it is not `null`, or the empty string otherwise.\n\n```dart\nString? nullableStr;\nfinal str = nullableStr.orEmpty(); // ''\n```\n\n### .matches()\n\nReturns `true` if this char sequence matches the given regular expression.\n\n```dart\nprint('as'.matches(RegExp('^.s\\$'))) // true\nprint('mst'.matches(RegExp('^.s\\$'))) // false\n```\n\n### Time utils\n\ndartf exports [@jogboms](https://github.com/jogboms) great [⏰ time.dart](https://github.com/jogboms/time.dart) package so you can do the following:\n\n```dart\nint secondsInADay = 1.days.inSeconds;\n\nDuration totalTime = [12.5.seconds, 101.milliseconds, 2.5.minutes].sum();\n\nDateTime oneWeekLater = DateTime.now() + 1.week;\n```\n\nCheck out [⏰ time.dart](https://github.com/jogboms/time.dart) for more information and examples.\n\n## num\n\n### .coerceIn()\n\nEnsures that this value lies in the specified range.\n\n```dart\nfinal numberInRange = 123.coerceIn(0, 1000); // 123\nfinal numberOutOfRange = -123.coerceIn(0, 1000); // 0\n```\n\n### .toBytes()\n\nConverts this value to binary form.\n\n### .toChar()\n\nConverts this value to character\n\n```dart\nfinal character = 97.toChar(); // a\n```\n\n## range\n\n### rangeTo\n\nCreates a range between two ints (upwards, downwards and with custom steps)\n\n```dart\n// upwards with default step size 1\nfor (final i in 1.rangeTo(5)) {\n  print(i); // 1, 2, 3, 4, 5\n}\n// downwards with custom step\nfor (final i in 10.rangeTo(2).step(2)) {\n  print(i); // 10, 8, 6, 4, 2\n}\n```\n\n## Function\n\n### .partial(), .partial2() ...\n\nApplies some of the required arguments to a function and returns a function which takes the remaining arguments.\n\n```dart\nvoid greet(String firstName, String lastName) {\n  print('Hi $firstName $lastName!');\n}\n\nfinal greetStark = greet.partial('Stark');\ngreetStark('Sansa'); // Hi Sansa Stark!\ngreetStark('Tony'); // Hi Tony Stark!\n```\n\n## File\n\n### .name\n\nGet the name and extension of a file.\n\n```dart\nfinal file = File('some/path/testFile.dart');\nprint(file.name); // testFile.dart\nprint(file.nameWithoutExtension); // testFile\n```\n\n### .appendText()\n\nAppend text to a file.\n\n```dart\nawait File('someFile.json').appendText('{test: true}');\n```\n\n### .isWithin()\n\nChecks if a file is inside a directory.\n\n```dart\nfinal dir = Directory('some/path');\nFile('some/path/file.dart').isWithin(dir); // true\n```\n\n## Directory\n\n### .file(String)\n\nReferences a file within a `Directory`\n\n```dart\nDirectory androidDir = Directory('flutter-app/android');\nFile manifestFile = androidDir.file(\"app/src/main/AndroidManifest.xml\");\n```\n\nReferences a directory within a `Directory`\n\n### .directory(String)\n\n```dart\nDirectory androidDir = Directory('flutter-app/android');\nDirectory mainSrc = androidDir.directory(\"app/src/main\");\n```\n\n### .contains(FileSystemEntity entity, {bool recursive = false})\n\nChecks if a `Directory` contains a `FileSystemEntity`. This can be a `File` or a `Directory`.\n\nUse the `recursive` argument to include the subdirectories.\n\n```dart\nfinal File someFile = File('someFile.txt');\nfinal Directory someDir = Directory('some/dir');\n\nfinal Directory parentDir = Directory('parent/dir');\n\nparentDir.contains(someFile);\nparentDir.contains(someDir);\nparentDir.contains(someFile, recursive: true);\nparentDir.contains(someDir, recursive: true);\n```\n\nThis is the `async` method, which returns a `Future\u003cbool\u003e`.\n\n### .containsSync(FileSystemEntity entity, {bool recursive = false})\n\nSame as `.contains(FileSystemEntity entity, {bool recursive = false})` but synchronous. Returns a `bool`.\n","funding_links":[],"categories":["Dart"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexcmgit%2Fdartf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexcmgit%2Fdartf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexcmgit%2Fdartf/lists"}