{"id":20556850,"url":"https://github.com/luckybilly/widget_chain","last_synced_at":"2025-04-14T13:12:51.783Z","repository":{"id":50295580,"uuid":"230606618","full_name":"luckybilly/widget_chain","owner":"luckybilly","description":"Chain programming, not widget nesting constructors. Get rid of the nested hell with shiny extensions, now! ","archived":false,"fork":false,"pushed_at":"2019-12-30T04:50:04.000Z","size":14,"stargazers_count":173,"open_issues_count":5,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T02:21:56.400Z","etag":null,"topics":["chain-programming","dart-extension","nested-hell","shiny-extensions","widget-chain","widget-nesting-constructors"],"latest_commit_sha":null,"homepage":"","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/luckybilly.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":"2019-12-28T12:23:54.000Z","updated_at":"2025-02-15T04:07:32.000Z","dependencies_parsed_at":"2022-08-29T07:42:01.352Z","dependency_job_id":null,"html_url":"https://github.com/luckybilly/widget_chain","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckybilly%2Fwidget_chain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckybilly%2Fwidget_chain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckybilly%2Fwidget_chain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckybilly%2Fwidget_chain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luckybilly","download_url":"https://codeload.github.com/luckybilly/widget_chain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248886327,"owners_count":21177644,"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":["chain-programming","dart-extension","nested-hell","shiny-extensions","widget-chain","widget-nesting-constructors"],"created_at":"2024-11-16T03:32:57.968Z","updated_at":"2025-04-14T13:12:51.751Z","avatar_url":"https://github.com/luckybilly.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# widget_chain\n\nGet rid of the nested hell with shiny extensions, now! \n\nChain programming, not widget nesting constructors.\n\n[![Pub](https://img.shields.io/pub/v/widget_chain.svg?style=flat-square)](https://pub.dartlang.org/packages/widget_chain)\n\n```dart\nContainer buildItem(String name) {\n  return Icon(Icons.phone)\n    .addNeighbor(Text(name))\n    .intoRow(crossAxisAlignment: CrossAxisAlignment.center,)\n    .intoContainer(color: Colors.white, padding: EdgeInsets.all(20),);\n}\n```\n\n## Story\n\nIf you've ever written anything like this:\n\n```dart\n/// do you love nested hell?\nclass Test extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      appBar: AppBar(title: Text('Demo'),),\n      body: Container(\n        child: Offstage(\n          offstage: false,\n          child: ListView(\n            children: \u003cWidget\u003e[\n              Container(\n                color: Colors.white,\n                padding: EdgeInsets.all(20),\n                child: Row(\n                  crossAxisAlignment: CrossAxisAlignment.center,\n                  children: \u003cWidget\u003e[\n                    Icon(Icons.phone),\n                    Text(\"amy\"),\n                  ],\n                ),\n              ),\n              Container(\n                color: Colors.white,\n                padding: EdgeInsets.all(20),\n                child: Row(\n                  crossAxisAlignment: CrossAxisAlignment.center,\n                  children: \u003cWidget\u003e[\n                    Icon(Icons.phone),\n                    Text(\"billy\"),\n                  ],\n                ),\n              ),\n            ],\n          ),\n        ),\n      ),\n    );\n  }\n}\n```\n\nto resolve nested hell, maybe you will extract a build method, then it looks like:\n\n```dart\nclass Test extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      appBar: AppBar(title: Text('Demo'),),\n      body: Container(\n        child: Offstage(\n          offstage: false,\n          child: ListView(\n            children: \u003cWidget\u003e[\n              buildItem(\"amy\"),\n              buildItem(\"billy\"),\n            ],\n          ),\n        ),\n      ),\n    );\n  }\n\n  Container buildItem(String name) {\n    return Container(\n      color: Colors.white,\n      padding: EdgeInsets.all(20),\n      child: Row(\n        crossAxisAlignment: CrossAxisAlignment.center,\n        children: \u003cWidget\u003e[\n          Icon(Icons.phone),\n          Text(name),\n        ],\n      ),\n    );\n  }\n}\n```\n\nUse widget_chain can replace constructors by an `intoXxx()` function calling.\n\nThe code looks like:\n\n```dart\nclass Test extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      appBar: AppBar(title: Text('Demo'),),\n      body: Container(\n        child: Offstage(\n          offstage: false,\n          child: ListView(\n            children: \u003cWidget\u003e[\n              buildItem(\"amy\"),\n              buildItem(\"billy\"),\n            ],\n          ),\n        ),\n      ),\n    );\n  }\n\n  Container buildItem(String name) {\n    return Icon(Icons.phone)\n        .addNeighbor(Text(name))  //the widget(Icon) add a neighbor (Text) and returns a List\u003cWidget\u003e\n        .intoRow(crossAxisAlignment: CrossAxisAlignment.center,) // make the List\u003cWidget\u003e as the children of Row, and then returns the Row widget\n        .intoContainer(color: Colors.white, padding: EdgeInsets.all(20),) // make the Row as the child of Container, and then returns the Container widget\n        ;  \n  }\n}\n```\n\u003cdetails\u003e\n\u003csummary\u003eClick to show more...\u003c/summary\u003e\n\nor like this:\n\n```dart\nclass Test extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      appBar: AppBar(title: Text('Demo'),),\n      body: Container(\n        child: Offstage(\n          offstage: false,\n          child: ListView(\n            children: WidgetChain\n              .addNeighbor(buildItem(\"amy\"),)\n              .addNeighbor(buildItem(\"billy\"),),\n          ),\n        ),\n      ),\n    );\n  }\n\n  Container buildItem(String name) {\n    return Icon(Icons.phone)\n        .addNeighbor(Text(name))\n        .intoRow(crossAxisAlignment: CrossAxisAlignment.center,)\n        .intoContainer(color: Colors.white, padding: EdgeInsets.all(20),);\n  }\n}\n```\n\nor like this:\n\n```dart\nclass Test extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      appBar: AppBar(title: Text('Demo'),),\n      body: Container(\n        child: Offstage(\n          offstage: false,\n          child: WidgetChain\n            .addNeighbor(buildItem(\"amy\"),)\n            .addNeighbor(buildItem(\"billy\"),)\n            .intoListView(),\n        ),\n      ),\n    );\n  }\n\n  Container buildItem(String name) {\n    return Icon(Icons.phone)\n        .addNeighbor(Text(name))\n        .intoRow(crossAxisAlignment: CrossAxisAlignment.center,)\n        .intoContainer(color: Colors.white, padding: EdgeInsets.all(20),);\n  }\n}\n```\n\nor like this:\n\n```dart\nclass Test extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      appBar: AppBar(title: Text('Demo'),),\n      body: Container(\n        child: WidgetChain\n           .addNeighbor(buildItem(\"amy\"),)\n           .addNeighbor(buildItem(\"billy\"),)\n           .intoListView()\n           .intoOffstage(offstage: false,),\n      ),\n    );\n  }\n\n  Container buildItem(String name) {\n    return Icon(Icons.phone)\n        .addNeighbor(Text(name))\n        .intoRow(crossAxisAlignment: CrossAxisAlignment.center,)\n        .intoContainer(color: Colors.white, padding: EdgeInsets.all(20),);\n  }\n}\n```\n\n\u003c/details\u003e\n\nor like this:\n\n```dart\nclass Test extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n        appBar: AppBar(title: Text('Demo'),),\n        body: WidgetChain\n              .addNeighbor(buildItem(\"amy\"),)\n              .addNeighbor(buildItem(\"billy\"),)\n              .intoListView()\n              .intoOffstage(offstage: false)\n              .intoContainer()\n    );\n  }\n\n  Container buildItem(String name) {\n    return Icon(Icons.phone)\n        .addNeighbor(Text(name))\n        .intoRow(crossAxisAlignment: CrossAxisAlignment.center,)\n        .intoContainer(color: Colors.white, padding: EdgeInsets.all(20),);\n  }\n}\n```\n\nuse `buildAllAsWidget` extension of `List\u003cT\u003e`, it looks like this:\n\n```dart\nclass Test extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    var list = [\"amy\", \"billy\"]\n            .buildAllAsWidget((name) =\u003e\n              Icon(Icons.phone)\n              .addNeighbor(Text(name))\n              .intoRow(crossAxisAlignment: CrossAxisAlignment.center,)\n              .intoContainer(color: Colors.white, padding: EdgeInsets.all(20),)\n            );\n    return Scaffold(\n        appBar: AppBar(title: Text('Demo'),),\n        body: list.intoListView()\n            .intoOffstage(offstage: false)\n            .intoContainer()\n    );\n  }\n}\n```\n\n```dart\nclass Test extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n        appBar: AppBar(title: Text('Demo'),),\n        body: [\"amy\", \"billy\"]\n            .buildAllAsWidget((name) =\u003e\n              Icon(Icons.phone)\n              .addNeighbor(Text(name))\n              .intoRow(crossAxisAlignment: CrossAxisAlignment.center,)\n              .intoContainer(color: Colors.white, padding: EdgeInsets.all(20),)\n            )\n            .intoListView()\n            .intoOffstage(offstage: false)\n            .intoContainer()\n    );\n  }\n}\n```\n\n\n## Getting Started\n\n```yaml\ndependencies:\n  widget_chain: ^0.1.0\n```\n\n## Usage\n\n```dart\nimport 'package:widget_chain/widget_chain.dart';\n```\nfor `Widget`:\n\n```dart\nreturn widgetA.intoBbb(parmas);\n```\nequivalent as:\n\n```dart\nreturn Bbb(\n  params,\n  child: widgetA,\n);\n```\n\nfor `List\u003cWidget\u003e`:\n\n```dart\nreturn widgetListC.intoDdd(parmas);\n```\nequivalent as:\n\n```dart\nreturn Ddd(\n  params,\n  children: widgetListC,\n);\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckybilly%2Fwidget_chain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluckybilly%2Fwidget_chain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckybilly%2Fwidget_chain/lists"}