{"id":16382301,"url":"https://github.com/pingbird/async_builder","last_synced_at":"2026-01-11T04:49:48.386Z","repository":{"id":50560514,"uuid":"266520863","full_name":"pingbird/async_builder","owner":"pingbird","description":"Improved asyncronous builder for Flutter.","archived":false,"fork":false,"pushed_at":"2023-03-05T14:41:05.000Z","size":123,"stargazers_count":17,"open_issues_count":5,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T17:24:41.325Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/async_builder","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/pingbird.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,"governance":null}},"created_at":"2020-05-24T10:49:47.000Z","updated_at":"2024-07-01T09:54:11.000Z","dependencies_parsed_at":"2023-07-27T19:15:00.995Z","dependency_job_id":"ee796f44-6e88-4b06-bac2-5dfe22f0827d","html_url":"https://github.com/pingbird/async_builder","commit_stats":null,"previous_names":["pingbird/async_builder","pixeltoast/async_builder"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingbird%2Fasync_builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingbird%2Fasync_builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingbird%2Fasync_builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingbird%2Fasync_builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pingbird","download_url":"https://codeload.github.com/pingbird/async_builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245052662,"owners_count":20553162,"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-10-11T04:04:54.686Z","updated_at":"2025-10-06T11:50:51.280Z","avatar_url":"https://github.com/pingbird.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# async_builder - Improved Future and Stream builder for Flutter.\n\nThis package provides `AsyncBuilder`, a widget similar to StreamBuilder / FutureBuilder which is designed to reduce\nboilerplate and improve error handling.\n\nIt also provides `InitBuilder`, which makes it easier to start async tasks safely.\n\n## How to use\n\n**1. Add to dependencies**\n```\ndependencies:\n  async_builder: ^1.2.0\n```\n\n**2. Import**\n```\nimport 'package:async_builder/async_builder.dart';\nimport 'package:async_builder/init_builder.dart';\n```\n\n## AsyncBuilder Examples\n\n### Future\n\n```dart\nAsyncBuilder\u003cString\u003e(\n  future: myFuture,\n  waiting: (context) =\u003e Text('Loading...'),\n  builder: (context, value) =\u003e Text('$value'),\n  error: (context, error, stackTrace) =\u003e Text('Error! $error'),\n)\n```\n\n### Stream\n\n```dart\nAsyncBuilder\u003cString\u003e(\n  stream: myStream,\n  waiting: (context) =\u003e Text('Loading...'),\n  builder: (context, value) =\u003e Text('$value'),\n  error: (context, error, stackTrace) =\u003e Text('Error! $error'),\n  closed: (context, value) =\u003e Text('$value (closed)'),\n)\n```\n\nNote that you cannot provide both a stream and future.\n\n## AsyncBuilder Features\n\n### Separate builders\n\nInstead of a single builder, AsyncBuilder allows you to specify separate builders depending on the state of the\nasynchronous operation:\n\n* `waiting(context)` - Called when no events have fired yet.\n* `builder(context, value)` - Required. Called when a value is available.\n* `error(context, error, stackTrace)` - Called if there was an error.\n* `closed(context, value)` - Called if the stream was closed.\n\nIf any of these are not provided then it defaults to calling `builder` (potentially with a null `value`).\n\n### Error handling\n\nAsyncBuilder does not silently ignore errors by default.\n\nIf an exception occurs and `error` is provided, the widget will rebuild and call that builder.\nOtherwise, if `error` is not provided and `silent` not true then the exception and stack trace will be printed to\nconsole (default behavior).\n\n### Initial value\n\nIf `initial` is provided, it is used in place of the value before one is available.\n\n### RxDart ValueStream\n\nIf `stream` is a ValueStream (BehaviorSubject) holding an existing value, that value will be available immediately on\nfirst build.\n\n### Stream pausing\n\nThe `StreamSubscription` for this widget can be paused with the `pause` parameter, this is useful if you want to notify\nthe upstream `StreamController` that you don't need updates.\n\n## InitBuilder\n\nInitBuilder is a widget that initializes a value only when its configuration changes, this is extremely useful because\nit allows you to safely start async tasks without making a whole new StatefulWidget.\n\nThe basic usage of this widget is to make a separate function outside of build that starts the task and then pass it to\nInitBuilder, for example:\n\n```dart\nstatic Future\u003cint\u003e getNumber() async =\u003e ...;\n\nbuild(context) =\u003e InitBuilder\u003cint\u003e(\n  getter: getNumber,\n  builder: (context, future) =\u003e AsyncBuilder\u003cint\u003e(\n    future: future,\n    builder: (context, value) =\u003e Text('$value'),\n  ),\n);\n```\n\nIn this case, getNumber is only ever called on the first build.\n\nYou may also want to pass arguments to the getter, for example to query shared preferences:\n\n```dart\nfinal String prefsKey;\n\nbuild(context) =\u003e InitBuilder.arg\u003cString, String\u003e(\n  getter: sharedPrefs.getString,\n  arg: prefsKey,\n  builder: (context, future) =\u003e AsyncBuilder\u003cString\u003e(\n    future: future,\n    builder: (context, value) =\u003e Text('$value'),\n  ),\n);\n```\n\nThe alternate constructors `InitBuilder.arg` to `InitBuilder.arg7` can be used to pass arguments to the `getter`, these\nwill re-initialize the value if and only if either `getter` or the arguments change.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingbird%2Fasync_builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpingbird%2Fasync_builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingbird%2Fasync_builder/lists"}