{"id":20979492,"url":"https://github.com/josiahsrc/flutter_functional_widget","last_synced_at":"2025-06-25T02:08:06.928Z","repository":{"id":248425947,"uuid":"828604395","full_name":"josiahsrc/flutter_functional_widget","owner":"josiahsrc","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-14T21:19:31.000Z","size":278,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T09:49:21.989Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","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/josiahsrc.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-14T16:39:12.000Z","updated_at":"2024-07-14T21:19:33.000Z","dependencies_parsed_at":"2024-07-14T20:28:12.561Z","dependency_job_id":"48fd5062-16b9-4660-ab1d-00f18070222c","html_url":"https://github.com/josiahsrc/flutter_functional_widget","commit_stats":null,"previous_names":["josiahsrc/flutter_functional_widget"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/josiahsrc/flutter_functional_widget","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josiahsrc%2Fflutter_functional_widget","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josiahsrc%2Fflutter_functional_widget/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josiahsrc%2Fflutter_functional_widget/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josiahsrc%2Fflutter_functional_widget/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/josiahsrc","download_url":"https://codeload.github.com/josiahsrc/flutter_functional_widget/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josiahsrc%2Fflutter_functional_widget/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261789289,"owners_count":23209776,"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":[],"created_at":"2024-11-19T05:13:39.936Z","updated_at":"2025-06-25T02:08:06.903Z","avatar_url":"https://github.com/josiahsrc.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flutter functional widget\n\n🚧 EXPERIMENTAL! 🚧\n\nAn experiment to see what a functional widget might look like in flutter. Taking inspiration from react to try to reduce boilerplate.\n\nEDIT: There is a much more flushed out implementation here: https://github.com/dart-lang/language/blob/main/working/macros/example/lib/functional_widget.dart\n(I wasn't aware of this at the time of writing this)\n\n## New API\n\nFor example, you might define a function like this\n\n```dart\n// 8 lines of code\n@Functional()\nWidget _fab(BuildContext context, {VoidCallback? onPressed}) {\n  return FloatingActionButton(\n    onPressed: onPressed,\n    tooltip: 'Increment',\n    child: const Icon(Icons.add),\n  );\n}\n```\n\nAnd be able to use the macro version of the widget like you would any other widget.\n\n```dart\nWidget build(BuildContext context) {\n  return Scaffold(\n    floatingActionButton: Fab(\n      onPressed: () {\n        print(\"hello world!\");\n      }\n    ),\n  );\n}\n```\n\n## Standard API\n\nThe equivalent in the current way to do this is the following, requiring more lines of code.\n\n```dart\n// 12 lines of code\nclass Fab extends StatelessWidget {\n  const Fab({super.key, this.onPressed});\n\n  final VoidCallback? onPressed;\n\n  @override\n  Widget build(BuildContext context) {\n    return FloatingActionButton(\n      onPressed: onPressed,\n      tooltip: 'Increment',\n      child: const Icon(Icons.add),\n    );\n  }\n}\n```\n\n## Limitations\n\n1. Macros don't support default parameters or generics yet.\n1. As far as I know, you can't generate a new type from a macro. Until that's resolved, this approach generates a function that uses a Builder widget.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosiahsrc%2Fflutter_functional_widget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosiahsrc%2Fflutter_functional_widget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosiahsrc%2Fflutter_functional_widget/lists"}