{"id":13550535,"url":"https://github.com/felangel/flow_builder","last_synced_at":"2025-04-14T08:56:37.874Z","repository":{"id":39580363,"uuid":"303430155","full_name":"felangel/flow_builder","owner":"felangel","description":"Flutter Flows made easy! A Flutter package which simplifies navigation flows with a flexible, declarative API.","archived":false,"fork":false,"pushed_at":"2024-11-27T20:02:20.000Z","size":583,"stargazers_count":407,"open_issues_count":30,"forks_count":69,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-07T02:07:36.431Z","etag":null,"topics":["dart","flutter","flutter-package","navigation","navigator","router","routing"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/flow_builder","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/felangel.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["felangel"]}},"created_at":"2020-10-12T15:13:42.000Z","updated_at":"2025-03-23T01:55:04.000Z","dependencies_parsed_at":"2024-04-02T05:28:18.703Z","dependency_job_id":"71e2aa44-c0ad-471a-bd42-967ebcf5a0d8","html_url":"https://github.com/felangel/flow_builder","commit_stats":{"total_commits":89,"total_committers":14,"mean_commits":6.357142857142857,"dds":0.1573033707865169,"last_synced_commit":"838f92c3b4a2de9bfa08513f05dfd6ea01608a53"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felangel%2Fflow_builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felangel%2Fflow_builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felangel%2Fflow_builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felangel%2Fflow_builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felangel","download_url":"https://codeload.github.com/felangel/flow_builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852112,"owners_count":21171839,"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":["dart","flutter","flutter-package","navigation","navigator","router","routing"],"created_at":"2024-08-01T12:01:34.456Z","updated_at":"2025-04-14T08:56:37.853Z","avatar_url":"https://github.com/felangel.png","language":"Dart","funding_links":["https://github.com/sponsors/felangel"],"categories":["Dart"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/felangel/flow_builder/master/art/flow_builder_logo.png\" height=\"150\" alt=\"Flow Builder\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eFlutter Flows made easy!\u003c/b\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/felangel/flow_builder/actions\"\u003e\u003cimg src=\"https://github.com/felangel/flow_builder/actions/workflows/main.yaml/badge.svg\" alt=\"build\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/felangel/flow_builder/actions\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/felangel/flow_builder/master/coverage_badge.svg\" alt=\"coverage\"\u003e\u003c/a\u003e\n\u003ca href=\"https://pub.dev/packages/flow_builder\"\u003e\u003cimg src=\"https://img.shields.io/pub/v/flow_builder.svg\" alt=\"pub package\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Usage\n\n### Define a Flow State\n\nThe flow state will be the state which drives the flow. Each time this state changes, a new navigation stack will be generated based on the new flow state.\n\n```dart\nclass Profile {\n  const Profile({this.name, this.age, this.weight});\n\n  final String? name;\n  final int? age;\n  final int? weight;\n\n  Profile copyWith({String? name, int? age, int? weight}) {\n    return Profile(\n      name: name ?? this.name,\n      age: age ?? this.age,\n      weight: weight ?? this.weight,\n    );\n  }\n}\n```\n\n### Create a FlowBuilder\n\n`FlowBuilder` is a widget which builds a navigation stack in response to changes in the flow state. `onGeneratePages` will be invoked for each state change and must return the new navigation stack as a list of pages.\n\n```dart\nFlowBuilder\u003cProfile\u003e(\n  state: const Profile(),\n  onGeneratePages: (profile, pages) {\n    return [\n      MaterialPage(child: NameForm()),\n      if (profile.name != null) MaterialPage(child: AgeForm()),\n    ];\n  },\n);\n```\n\n### Update the Flow State\n\nThe state of the flow can be updated via `context.flow\u003cT\u003e().update`.\n\n```dart\nclass NameForm extends StatefulWidget {\n  @override\n  _NameFormState createState() =\u003e _NameFormState();\n}\n\nclass _NameFormState extends State\u003cNameForm\u003e {\n  var _name = '';\n\n  void _continuePressed() {\n    context.flow\u003cProfile\u003e().update((profile) =\u003e profile.copyWith(name: _name));\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      appBar: AppBar(title: const Text('Name')),\n      body: Center(\n        child: Column(\n          children: \u003cWidget\u003e[\n            TextField(\n              onChanged: (value) =\u003e setState(() =\u003e _name = value),\n              decoration: InputDecoration(\n                labelText: 'Name',\n                hintText: 'John Doe',\n              ),\n            ),\n            RaisedButton(\n              child: const Text('Continue'),\n              onPressed: _name.isNotEmpty ? _continuePressed : null,\n            )\n          ],\n        ),\n      ),\n    );\n  }\n}\n```\n\n### Complete the Flow\n\nThe flow can be completed via `context.flow\u003cT\u003e().complete`.\n\n```dart\nclass AgeForm extends StatefulWidget {\n  @override\n  _AgeFormState createState() =\u003e _AgeFormState();\n}\n\nclass _AgeFormState extends State\u003cAgeForm\u003e {\n  int? _age;\n\n  void _continuePressed() {\n    context\n        .flow\u003cProfile\u003e()\n        .complete((profile) =\u003e profile.copyWith(age: _age));\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      appBar: AppBar(title: const Text('Age')),\n      body: Center(\n        child: Column(\n          children: \u003cWidget\u003e[\n            TextField(\n              onChanged: (value) =\u003e setState(() =\u003e _age = int.parse(value)),\n              decoration: InputDecoration(\n                labelText: 'Age',\n                hintText: '42',\n              ),\n              keyboardType: TextInputType.number,\n            ),\n            RaisedButton(\n              child: const Text('Continue'),\n              onPressed: _age != null ? _continuePressed : null,\n            )\n          ],\n        ),\n      ),\n    );\n  }\n}\n```\n\n### FlowController\n\nA `FlowBuilder` can also be created with a custom `FlowController` in cases where the flow can be manipulated outside of the sub-tree.\n\n```dart\nclass MyFlow extends StatefulWidget {\n  @override\n  State\u003cMyFlow\u003e createState() =\u003e _MyFlowState();\n}\n\nclass _MyFlowState extends State\u003cMyFlow\u003e {\n  late FlowController\u003cProfile\u003e _controller;\n\n  @override\n  void initState() {\n    super.initState();\n    _controller = FlowController(const Profile());\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return FlowBuilder(\n      controller: _controller,\n      onGeneratePages: ...,\n    );\n  }\n\n  @override dispose() {\n    _controller.dispose();\n    super.dispose();\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelangel%2Fflow_builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelangel%2Fflow_builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelangel%2Fflow_builder/lists"}