{"id":19775013,"url":"https://github.com/letsar/value_layout_builder","last_synced_at":"2025-10-19T05:06:14.545Z","repository":{"id":52989994,"uuid":"291035201","full_name":"letsar/value_layout_builder","owner":"letsar","description":"A LayoutBuilder with an extra value","archived":false,"fork":false,"pushed_at":"2024-10-14T13:23:26.000Z","size":98,"stargazers_count":17,"open_issues_count":0,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T04:07:38.601Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/letsar.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-08-28T11:59:12.000Z","updated_at":"2025-02-12T06:42:49.000Z","dependencies_parsed_at":"2022-08-28T12:13:51.507Z","dependency_job_id":null,"html_url":"https://github.com/letsar/value_layout_builder","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsar%2Fvalue_layout_builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsar%2Fvalue_layout_builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsar%2Fvalue_layout_builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsar%2Fvalue_layout_builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/letsar","download_url":"https://codeload.github.com/letsar/value_layout_builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251769141,"owners_count":21640845,"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-12T05:14:34.170Z","updated_at":"2025-10-19T05:06:14.458Z","avatar_url":"https://github.com/letsar.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# value_layout_builder\n\n[![Pub](https://img.shields.io/pub/v/value_layout_builder.svg)][pub]\n\nA `LayoutBuilder` with an extra value. It's useful when you want to build a widget with a value computed during layout.\n\n## Features\n* ValueLayoutBuilder - The RenderBox version.\n* SliverValueLayoutBuilder - The RenderSliver version.\n\n## Getting started\n\nIn the `pubspec.yaml` of your flutter project, add the following dependency:\n\n```yaml\ndependencies:\n  ...\n  value_layout_builder:\n```\n\nIn your library add the following import:\n\n```dart\nimport 'package:value_layout_builder/value_layout_builder.dart';\n```\n\nFor help getting started with Flutter, view the online [documentation](https://flutter.io/).\n\n## Usage\n\n`ValueLayoutBuilder` and `SliverValueLayoutBuilder` will pair with a custom `RenderObject` which accepts a one of them as a child.\n\nFor example it is used in [flutter_sticky_header][flutter_sticky_header] in order to know how much the header is hidden.\n\n\nThe typical usage is to expose a builder in the parameter of your widget's constructor which takes a `BuildContext` and the value you want to get from layout, and to pass it from your custom `RenderObject`.\n\nThe following code is a dumb example to show you how to use it:\n```dart\nclass _Tester\u003cT\u003e extends SingleChildRenderObjectWidget {\n  const _Tester({\n    Key? key,\n    required this.value,\n    required Widget child,\n  }) : super(key: key, child: child);\n\n  final T value;\n\n  @override\n  _RenderTester\u003cT\u003e createRenderObject(BuildContext context) {\n    return _RenderTester\u003cT\u003e(value: value);\n  }\n\n  @override\n  void updateRenderObject(\n    BuildContext context,\n    _RenderTester\u003cT\u003e renderObject,\n  ) {\n    renderObject.value = value;\n  }\n}\n\nclass _RenderTester\u003cT\u003e extends RenderBox\n    with RenderObjectWithChildMixin\u003cRenderBox\u003e {\n  _RenderTester({\n    required T value,\n  }) : _value = value;\n\n  T get value =\u003e _value;\n  T _value;\n  set value(T value) {\n    if (_value != value) {\n      _value = value;\n      markNeedsLayout();\n    }\n  }\n\n  @override\n  void performLayout() {\n    // We create a specific constraints with the value we want to pass to the builder.\n    BoxValueConstraints\u003cT\u003e constraints = BoxValueConstraints\u003cT\u003e(\n      constraints: this.constraints,\n      value: value,\n    );\n    child.layout(constraints);\n    size = constraints.biggest;\n  }\n\n  @override\n  void paint(PaintingContext context, Offset offset) {\n    context.paintChild(child, offset);\n  }\n}\n```\n\nWe can then use `_Tester\u003cT\u003e ` like this:\n```dart\n_Tester\u003cString\u003e(\n  value: 'test',\n  child: ValueLayoutBuilder\u003cString\u003e(\n    builder: (context, constraints) {\n      // The constraints holds the String value.\n      final String value = constraints.value;\n      return Text(value);\n    },\n  ),\n)\n```\n\n## Sponsoring\n\nI'm working on my packages on my free-time, but I don't have as much time as I would. If this package or any other package I created is helping you, please consider to sponsor me. By doing so, I will prioritize your issues or your pull-requests before the others. \n\n## Changelog\n\nPlease see the [Changelog][changelog] page to know what's recently changed.\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][issue].  \nIf you fixed a bug or implemented a feature, please send a [pull request][pr].\n\n\u003c!--Links--\u003e\n[pub]: https://pub.dartlang.org/packages/value_layout_builder\n[changelog]: https://github.com/letsar/value_layout_builder/blob/master/CHANGELOG.md\n[issue]: https://github.com/letsar/value_layout_builder/issues\n[pr]: https://github.com/letsar/value_layout_builder/pulls\n[flutter_sticky_header]: https://github.com/letsar/flutter_sticky_header/\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletsar%2Fvalue_layout_builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fletsar%2Fvalue_layout_builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletsar%2Fvalue_layout_builder/lists"}