{"id":13826272,"url":"https://github.com/justkawal/utility","last_synced_at":"2026-02-22T03:42:22.163Z","repository":{"id":55093674,"uuid":"318973957","full_name":"justkawal/utility","owner":"justkawal","description":"Utility helps developers to migrate to dart use it more efficiently and easily with wide variety of functionalities.","archived":false,"fork":false,"pushed_at":"2022-09-18T10:55:17.000Z","size":135,"stargazers_count":13,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-23T07:32:04.399Z","etag":null,"topics":["dart","easy","efficient","fast","features","flutter","functions","utility"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/utility","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/justkawal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"patreon":"justkawal","ko_fi":"justkawal"}},"created_at":"2020-12-06T07:12:08.000Z","updated_at":"2025-05-20T18:46:06.000Z","dependencies_parsed_at":"2022-08-14T11:50:13.409Z","dependency_job_id":null,"html_url":"https://github.com/justkawal/utility","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/justkawal/utility","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkawal%2Futility","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkawal%2Futility/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkawal%2Futility/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkawal%2Futility/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justkawal","download_url":"https://codeload.github.com/justkawal/utility/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkawal%2Futility/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29704419,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T03:17:42.375Z","status":"ssl_error","status_checked_at":"2026-02-22T03:17:31.622Z","response_time":110,"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":["dart","easy","efficient","fast","features","flutter","functions","utility"],"created_at":"2024-08-04T09:01:34.905Z","updated_at":"2026-02-22T03:42:22.146Z","avatar_url":"https://github.com/justkawal.png","language":"Dart","funding_links":["https://patreon.com/justkawal","https://ko-fi.com/justkawal","https://www.paypal.me/kawal7415"],"categories":["Dart"],"sub_categories":[],"readme":"# Utility\n  \n  \u003ca href=\"https://flutter.io\"\u003e  \n    \u003cimg src=\"https://img.shields.io/badge/Platform-Flutter-yellow.svg\"  \n      alt=\"Platform\" /\u003e  \n  \u003c/a\u003e \n   \u003ca href=\"https://pub.dartlang.org/packages/utility\"\u003e  \n    \u003cimg src=\"https://img.shields.io/pub/v/utility.svg\"  \n      alt=\"Pub Package\" /\u003e  \n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/justkawal/utility\"\u003e  \n    \u003cimg src=\"https://github.com/justkawal/utility/workflows/Test/badge.svg\"  \n      alt=\"Test\" /\u003e  \n  \u003c/a\u003e \n   \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e  \n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-red.svg\"  \n      alt=\"License: MIT\" /\u003e  \n  \u003c/a\u003e  \n   \u003ca href=\"https://www.paypal.me/kawal7415\"\u003e  \n    \u003cimg src=\"https://img.shields.io/badge/Donate-PayPal-green.svg\"  \n      alt=\"Donate\" /\u003e  \n  \u003c/a\u003e\n   \u003ca href=\"https://github.com/justkawal/utility/issues\"\u003e  \n    \u003cimg src=\"https://img.shields.io/github/issues/justkawal/utility\"  \n      alt=\"Issue\" /\u003e  \n  \u003c/a\u003e \n   \u003ca href=\"https://github.com/justkawal/utility/network\"\u003e  \n    \u003cimg src=\"https://img.shields.io/github/forks/justkawal/utility\"  \n      alt=\"Forks\" /\u003e  \n  \u003c/a\u003e \n   \u003ca href=\"https://github.com/justkawal/utility/stargazers\"\u003e  \n    \u003cimg src=\"https://img.shields.io/github/stars/justkawal/utility\"  \n      alt=\"Stars\" /\u003e  \n  \u003c/a\u003e\n  \u003cbr\u003e\n  \u003cbr\u003e\n  \n### [Utility](https://www.pub.dev/packages/utility) provides functionality to improve dart code and make things faster and more easy.\n\n## Donate (Thanks for being kind)\nIf you find utility useful.\n\n# Table of Contents\n  - [Installing](#lets-get-started)\n  - [Usage](#usage)\n    * [List Operations](#list-operations)\n    * [String Operations](#list-operations)\n    * [Number Operations](#list-operations)\n  - [Upcoming Features](#features-coming-in-next-version)\n\n# Lets Get Started\n\n### 1. Depend on it\nAdd this to your package's `pubspec.yaml` file:\n\n```yaml\ndependencies:\n  utility: 1.0.3\n```\n\n### 2. Install it\n\nYou can install packages from the command line:\n\nwith `pub`:\n\n```css\n$  pub get\n```\n\nwith `Flutter`:\n\n```css\n$  flutter packages get\n```\n\n### 3. Import it\n\nNow in your `Dart` code, you can use: \n\n```dart\nimport 'package:utility/utility.dart';\n```\n\n# Usage\n\n## List Operations\n### slice\nCreates a slice of `list` from `start` up to `end`[exclusive].\n```dart\nvar list = [1, 2, 3, 4];\n\n//It slices the list elements and hence modifies this list\nlist.slice(2); // list = [3, 4]\n\n// Do not want to alter the list object ??\nvar list = [1, 2, 3, 4];\n\n//It creates copy of list slices the list elements and creates new list\nlist.slice(2); // list = [3, 4]\n```\n\n### removeFirst();\nRemoves items at `0` position in the list.\n```dart\nvar list = \u003cint\u003e[1, 5, 2, 4];\nvar firstItem = list.removeFirst();\n// altered list = [5, 2, 4];\n```\n\n### random\nreturns `random value` from list. If list is empty then it returns `null`\n```dart\nvar list = \u003cint\u003e[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\nvar randomValue = list.random(); // 3 // 3 will not be removed from list\n\n// If remove = true is passed as argument then polled random item will be removed from list\n\n// before list is\n// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n\nvar randomValue list.random(remove: true); // 5\n// after calling with remove = true\n// [1, 2, 3, 4, 6, 7, 8, 9, 10]\n\n// If secure = true is passed as argument then Random.secure() is used\nvar randomValue list.random(secure: true); // 5\n```\n\n### isGrowable\nreturns `true` if it is `Growable list` otherwise false.\n```dart\n// On Non-Growable List\nvar list = List\u003cdynamic\u003e(8);\nvar isGrowable = list.isGrowable; // false\n\n// On Growable List\nvar list2 = List\u003cdynamic\u003e();\nvar isGrowable = list2.isGrowable; // true\n```\n\n### drop\nremoves `n` number of elements from the `beginning of list`\n```dart\n//If used as method, it directly alter the list's object\nvar list = \u003cint\u003e[1, 2, 3, 4, 5];\nlist.drop(); // list = [2, 3, 4, 5];\n\nvar list = \u003cint\u003e[1, 2, 3, 4, 5];\nlist.drop(3); // list = [4, 5];\n\nvar list = \u003cint\u003e[1, 2, 3];\nlist.drop(5); // list = []; // does not throw error :D\n\n//If used as function,\n//it creates a new copy of the output and list's object is untouched\nvar list = \u003cint\u003e[1, 2, 3, 4, 5];\nvar newObject = list.dropRight(); // newObject = [1, 2, 3, 4];\n\nvar list = \u003cint\u003e[1, 2, 3, 4, 5];\nvar newObject = list.dropRight(3); // newObject = [1, 2];\n\nvar list = \u003cint\u003e[1, 2, 3];\nvar newObject = list.dropRight(5); // newObject = []; // does not throw error :D\n```\n\n### dropRight\nremoves `n` number of elements from the ending of list\n```dart\n//If used as method, it directly alter the list's object\nvar list = \u003cint\u003e[1, 2, 3, 4, 5];\nlist.dropRight(); // list = [1, 2, 3, 4];\n\nvar list = \u003cint\u003e[1, 2, 3, 4, 5];\nlist.dropRight(3); // list = [1, 2];\n\nvar list = \u003cint\u003e[1, 2, 3];\nlist.dropRight(5); // list = []; // does not throw error :D\n\n//If used as function,\n//it creates a new copy of the output and list's object is untouched\nvar list = \u003cint\u003e[1, 2, 3, 4, 5];\nvar newObject = list.dropRight(); // newObject = [1, 2, 3, 4];\n\nvar list = \u003cint\u003e[1, 2, 3, 4, 5];\nvar newObject = list.dropRight(3); // newObject = [1, 2];\n\nvar list = \u003cint\u003e[1, 2, 3];\nvar newObject = list.dropRight(5); // newObject = []; // does not throw error :D\n```\n\n### dropRightWhile\nstarts `removing elements` from the `ending of list` until condition becomes `false`.\n```dart\nvar list = \u003cint\u003e[2, 1, 3, 4, 5];\nlist.dropRightWhile((element) =\u003e element \u003e= 3); // list = [2, 1];\n```\n\n### dropWhile\nstarts `removing elements` from the `starting of list` until condition becomes `false`\n```dart\nvar list = \u003cint\u003e[2, 1, 3, 4, 5];\nlist.dropWhile((element) =\u003e element \u003c= 3); // list = [4, 5];\n```\n\n### flatten\n`Flattens` list a single level deep.\n\nIt returns `newObject` of flattened list and does not affects the list object called-upon\n```dart\nvar list = [2, [1, 3], [4, [1, [2]] ] ];\nvar newList = list.flatten(); // newList = [2, 1, 3, 4, [1, [2] ] ];\n```\n\n### flattenDepth\n`Recursively flatten list up to depth times.`\n\nIt returns `newObject` of flattened list and does not affects the list object called-upon\n```dart\nvar list = [2, [1, 3], [4, [1, [2]] ] ];\nvar newList = list.flattenDepth(1); // newList = [2, 1, 3, 4, [1, [2] ] ];\n```\n\n### flatterDeep\n`Recursively flattens list.`\n\nIt returns `newObject` of deeply flattened list and does not affects the list object called-upon.\n```dart\nvar list = [2, [1, 3], [4, [1, [2]] ] ];\nvar newList = list.flattenDeep(); // newList = [2, 1, 3, 4, 1, 2];\n```\n\n### chunk\nCreates a new list of elements split into groups the length of `size`.\n\nIf `list` can't be split evenly, the final chunk will be the remaining elements.\n```dart\n\n// It returns new Object of Chunked data;\nvar list = ['a', 'b', 'c', 'd'];\n\nvar newChunkedList = list.chunk(3);// newChunkedList = [['a', 'b', 'c'], ['d']];\n```\n\n### compact\nCreates an list of elements where the values of the list are not `Falsey`.\n\nAvoid calling it on fixed-length list.\n```dart\n//It alters the list object if the list is not fixed-length list.\nvar list = ['a', null, '', false, 'b'];\nvar compactedData = list.compact(); // ['a', 'b'];\n\n//It returns new Object of compacted data;\nvar list = ['a', null, '', false, 'b'];\n//here the list object is not altered\nvar compactedData_new_object = compact(list); // ['a', 'b'];\n```\n\n### heapSort\nSorts the list in `O(nLog(n))` time complexity.\n```dart\n\nvar list = \u003cint\u003e[97, 4, 5, 26, 6];\n// With `inPlace` set to `false` it returns new sorted list.\nvar newSortedList = list.heapSort(inPlace: false);\n// newSortedList = [4, 5, 6, 26, 97];\n\nvar list = \u003cint\u003e[97, 04, 5, 26, 6];\n// With `inPlace` set to `true (default)` it sorts the list in its place.\nlist.heapSort(); // list = [4, 5, 6, 26, 97];\n```\n\n## Number Operations\n### \u003e\u003e\u003e (mimic)\nAs dart don't have `\u003e\u003e\u003e`. So to achieve functionality of `\u003e\u003e\u003e` a mimic can be used.\n\n```dart\n// 20 \u003e\u003e\u003e 3 = 6\nvar value = 20.zeroFillRightShift(3); // value = 6\n```\n\n### zeroFillRightShift(int number, int amount)\nAs operator `\u003e\u003e\u003e` is not available in dart, So `zeroFillRightShift` function helps to mimics the working of `\u003e\u003e\u003e`.\n```dart\n// var t = 20 \u003e\u003e\u003e 3;\nvar t = zeroFillRightShift(20, 3); // 6\n\n// Thus above function helps to provide operation of `\u003e\u003e\u003e`\n\n// 20 \u003e\u003e\u003e 3 = 6\nvar value = 20.zeroFillRightShift(3); // value = 6\n```\n\n### xor\nIt returns `xor` operation.\n```dart\n// 20 ^ 3 = 23\nvar value = 20.xor(3); // value = 23\n```\n\n### divide\nIt returns `quotient` as integer on divison.\n```dart\n// ( In Python ) -\u003e [20 // 10 = 2]\n// ( In Dart )   -\u003e [20 / 10 = 2.0] (oops) :p\n\n// But we need 2 as result.\nvar value = 20.divide(10);       // value = 2\nvar value = 20.divide(10.0);     // value = 2\nvar value = (20.0).divide(10);   // value = 2\nvar value = (20.0).divide(10.0); // value = 2\nvar dividend = 20;\nvar divisor = 10;\nvar value = dividend.divide(divisor); // value = 2\n```\n\n## String Operations\n### slice\nCreates a slice of `string` from `start` up to, but not including, `end`.\n```dart\nvar string = '__justkawal;\n\n// It slices the string and returns modified string\nvar slicedString string.slice(2); // slicedString = 'justkawal';\n```\n\n### enumVal\nReturns the `value` of the `enum`\n```dart\nenum justkawal {\n  just,\n  kawal,\n}\n'${justkawal.just}'.enumVal; // just\n'${justkawal.kawal}'.enumVal; // kawal\n```\n\n### toNumber\nReturns converted number\n```dart\n'2604 '.toNumber; // 2604\n'  26.04 '.toNumber; // 26.04\n```\n\n### count\n`Counts` and `returns` the number of occurrences of value.\n```dart\n'justkawal'.count('a');       // 2\n'justkawal'.count('just');    // 1\n'justkawal'.count('flutter'); // 0\n```\n\n### isNumber\nReturns `true`, if the `string` is `number` other-wise `false`\n```dart\n'123'.isNumber; // true\n'justkawal'.isNumber; // false\n```\n\n### isBinary\nReturns `true` if the `string` is `binary`, other-wise `false`\n```dart\n'1010'.isBinary; // true\n'justkawal'.isBinary; // false\n```\n\n### isDecimal\nReturns `true` if the `string` is `decimal`, other-wise `false`\n```dart\n'123'.isDecimal; // true\n'justkawal'.isDecimal; // false\n```\n\n### isOctal\nReturns `true` if the `string` is `octal`, other-wise `false`\n```dart\n'123'.isOctal; // true\n'justkawal'.isOctal; // false\n```\n\n### isHex\nReturns `true` if the `string` is `good hex`, other-wise `false`\n```dart\n'123'.isHex; // true\n'justkawal'.isHex; // false\n```\n\n### deburr\nConverts string from `Latin-1` to normal `basic latin letters`.\n```dart\n'hey kàwàl'.deburr; // hey kawal\n```\n\n### unicodeWords\nReturns list of `unicode words` from the string.\n```dart\n'hey kàwàl'.unicodeWords; // [kàwàl]\n```\n\n### asciiWords\nReturns list of `ascii words` from the string.\n```dart\n'hey kàwàl'.asciiWords; // [hey]\n```\n\n### hasUnicodeWord\nReturns `true` if string contains any occurence of `unicode word` other-wise `false`.\n```dart\n'hey kàwàl'.hasUnicodeWord; // true\n'hey'.hasUnicodeWord;      // false\n```\n\n### capitalize\nConverts the first character of string to `upper case` and the remaining to `lower case`.\n```dart\n'justkawal'.capitalize; // Justkawal\n'JUSTKAWAL'.capitalize; // Justkawal\n```\n\n### lowerFirst\nConverts the first character of string to `lower case`.\n```dart\n'Justkawal'.lowerFirst; // justkawal\n'JUSTKAWAL'.lowerFirst; // jUSTKAWAL\n```\n\n### upperFirst\nConverts the `first character` of string to `upper case`.\n```dart\n'justkawal'.upperFirst; // Justkawal\n'jUSTKAWAL'.upperFirst; // JUSTKAWAL\n```\n\n### words\nReturns `list of words`\n```dart\n'kàwàl vu'.words; // ['kàwàl', 'vu']\n```\n\n### Case Conversions\n\n### camelCase\nConverts the string to `camelCase` and returns it.\n```dart\n'___just__kawal__'.camelCase; // justKawal\n'  just  Kawal  '.camelCase; // justKawal\n'-----just--Kawal--'.camelCase; // justKawal\n```\n\n### kebabCase\nConverts the string to `kebabCase` and returns it.\n```dart\n'___hello__world__'.kebabCase(); // hello-world\n'  hello  World  '.kebabCase(); // hello-world\n'-----hello--world--'.kebabCase(); // hello-world\n```\n\n### lowerCase\nConverts the string to `lowerCase` and returns it.\n```dart\n'___hello__world__'.lowerCase(); // hello world\n'  hello  World  '.lowerCase(); // hello world\n'-----hello--world--'.lowerCase(); // hello world\n```\n\n### snakeCase\nConverts the string to `snakeCase` and returns it.\n```dart\n'___hello__world__'.snakeCase(); // hello_world\n'  helloWorld  '.snakeCase(); // hello_world\n'-----hello--world--'.snakeCase(); // hello_world\n```\n\n### nameCase\nConverts the string to `nameCase` and returns it.\n```dart\n'___kaWaljeet__sInGH__'.nameCase(); // Kawaljeet Singh\n'  justKawal  '.nameCase(); // Just Kawal\n'-----kawaljeet--singh--'.nameCase(); // Kawaljeet Singh\n```\n\n### repeat\nReturns `repeated string`, `n` number of times\n```dart\n'justkawal'.repeat(1); // justkawal\n'123'.repeat(2); // 123123\n'1'.repeat(5); // 11111\n```\n\n### pad\nPads the string on the left and right sides if it's shorter than `length`.\n\nPadding characters will be truncated if they can't be evenly divided by `length`.\n```dart\nvar pad1 = 'abc'.pad(8); // '  abc   '\n\nvar pad2 = 'abc'.pad(8, '=_'); // '=_abc=_='\n\nvar pad3 = 'abc'.pad(3); // 'abc'\n```\n\n## Features coming in next version\nOn-going implementation for future:\n- Some more Functions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustkawal%2Futility","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustkawal%2Futility","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustkawal%2Futility/lists"}