{"id":32277166,"url":"https://github.com/agungnursatria/ifonly","last_synced_at":"2026-05-14T21:05:16.341Z","repository":{"id":56832840,"uuid":"261056064","full_name":"agungnursatria/ifonly","owner":"agungnursatria","description":"Flutter conditional (if-else / switch-case) helpers to make a more readable and simplifier conditional code.","archived":false,"fork":false,"pushed_at":"2020-05-05T06:34:43.000Z","size":77,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-23T00:02:44.973Z","etag":null,"topics":["conditional-statements","flutter","flutter-plugin"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/ifonly","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agungnursatria.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":"2020-05-04T01:33:27.000Z","updated_at":"2021-09-10T09:12:06.000Z","dependencies_parsed_at":"2022-09-08T01:41:23.448Z","dependency_job_id":null,"html_url":"https://github.com/agungnursatria/ifonly","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/agungnursatria/ifonly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agungnursatria%2Fifonly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agungnursatria%2Fifonly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agungnursatria%2Fifonly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agungnursatria%2Fifonly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agungnursatria","download_url":"https://codeload.github.com/agungnursatria/ifonly/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agungnursatria%2Fifonly/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33043264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["conditional-statements","flutter","flutter-plugin"],"created_at":"2025-10-23T00:03:13.848Z","updated_at":"2026-05-14T21:05:16.330Z","avatar_url":"https://github.com/agungnursatria.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IfOnly\n\nFlutter conditional (`if`-`else` / `switch`-`case`) helpers to make a more readable and simpler conditional statement code.\n\n## 🏃‍♂️ Getting Started\n\nIn your flutter project add the dependency:\n\n```yml\ndependencies:\n  ...\n  ifonly: ^0.1.3\n```\n\n## 🧞‍♂️ Usage\n#### Importing package\n```dart\nimport 'package:ifonly/ifonly.dart';\n```\n\n## 🐋 Why using this?\n\nHave you ever seen a repetitive code like this?\n\n```dart\nbool isValid = (username != null \u0026\u0026 username.isNotEmpty \u0026\u0026 password != null \u0026\u0026 password.isNotEmpty \u0026\u0026 email != null \u0026\u0026 email.isNotEmpty \u0026\u0026 phoneNumber != null \u0026\u0026 phoneNumber.isNotEmpty);\n```\n\nor returning widget like this\n\n```dart\nreturn (isValid) ? RaisedButton(child: Text('Click Me!'), onPressed: () =\u003e print('Hi!');) : RaisedButton(child: Text('Please fill the empty field first!'), onPressed: null;\n```\n\n## 🧙‍♂️ What IfOnly do\n\nWith this package, we are trying to make a commonly used code easier to read.\n\nLike making the isValid to this:\n\n```dart\nbool isValid = [username, password, email, phoneNumber].isNotNullOrEmpties();\n```\n\nAnd returning widget to this:\n\n```dart\nreturn IfOnly(\n    condition: isValid,\n    validBuilder: (context) =\u003e RaisedButton(child: Text('Click Me!'), onPressed: () =\u003e print('Hi!');),\n    invalidBuilder: (context) =\u003e RaisedButton(child: Text('Please fill the empty field first!'),\n),\n```\n\nOr like this:\n\n```dart\nreturn IfCaseOnly\u003cbool\u003e(\n    value: isValid,\n    caseBuilder: {\n        true: (BuildContext context) =\u003e RaisedButton(child: Text('Click Me!'), onPressed: () =\u003e print('Hi!');),\n        false: (BuildContext context) =\u003e RaisedButton(child: Text('Please fill the empty field first!'),\n    },\n    defaultBuilder: (context) =\u003e Text(\"Expression's builder is undefined. please input it to caseBuilder.\"),\n),\n```\nOr even like this:\n\n```dart\nreturn IfCaseOnly\u003cIfCases\u003e(\n    value: IfCases(\n        cases: [\n            IfCaseItem(isValid.isTrue(), (context) =\u003e YourValidButton()),\n            IfCaseItem(isValid.isFalse(), (context) =\u003e YourInvalidButton()),\n        ],\n    ),\n    defaultBuilder: (context) =\u003e Text(\"Expression's builder is undefined. please input it to caseBuilder.\"),\n),\n```\n\n### 👨‍🎨 Custom conditional function\n\nIf you need a self defined function like when define isValid, \nUse method `isCondition` or `ifCondition` for single data, `isConditions` or `ifConditions` for list:\n\n```dart\nbool isValid = [username, password, email, phoneNumber].isConditions((item) =\u003e item.isNotNullOrEmpty());\n```\n\n### Execute code after conditions are meet\n\nChange the `is` on function to `if`\n\n```dart\nWidget nextButton;\n[username, password, email, phoneNumber].ifConditions(\n    (item) =\u003e item.isNotNullOrEmpty(),\n    onTrue: (context) =\u003e nextButton = RaisedButton(child: Text('Click Me!'), onPressed: () =\u003e print('Hi!');),\n    onFalse: (context) =\u003e nextButton = RaisedButton(child: Text('Please fill the empty field first!'),\n);\n```\n\n### More detailed explanation\n\nWe have inputting comment to all function code, Go check [Repository](https://github.com/agungnursatria/ifonly/tree/master/lib) for more.\n\n## 🙏🏻  Contributions\n\nFeel free to contribute to this project.\n\nIf you find a bug or want a feature, but don't know how to fix/implement it, please fill an [issue](https://github.com/agungnursatria/ifonly/issues).\nIf you fixed a bug or implemented a feature, please send a [pull request](https://github.com/agungnursatria/ifonly/pulls).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagungnursatria%2Fifonly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagungnursatria%2Fifonly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagungnursatria%2Fifonly/lists"}