{"id":15294752,"url":"https://github.com/rickypid/widget_tree_depth_counter","last_synced_at":"2025-10-04T12:23:16.624Z","repository":{"id":61975030,"uuid":"438990747","full_name":"rickypid/widget_tree_depth_counter","owner":"rickypid","description":"Widget to count the amount of nested widget tree, useful in the dynamic construction of the interface when it is important to know the depth of widget.","archived":false,"fork":false,"pushed_at":"2023-04-10T19:30:53.000Z","size":98,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T14:54:25.946Z","etag":null,"topics":["counter","dart","flutter","flutter-package","flutter-packages","nested","nested-widgets","package","pubdev","widget","widget-tree","widgets-counter"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/widget_tree_depth_counter","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/rickypid.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"rickypid","custom":"https://buymeacoffee.com/veweju"}},"created_at":"2021-12-16T13:00:50.000Z","updated_at":"2024-05-08T13:24:27.000Z","dependencies_parsed_at":"2025-04-13T14:54:29.897Z","dependency_job_id":"5cfba895-859b-429b-90d3-32457d1089d1","html_url":"https://github.com/rickypid/widget_tree_depth_counter","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/rickypid/widget_tree_depth_counter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickypid%2Fwidget_tree_depth_counter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickypid%2Fwidget_tree_depth_counter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickypid%2Fwidget_tree_depth_counter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickypid%2Fwidget_tree_depth_counter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rickypid","download_url":"https://codeload.github.com/rickypid/widget_tree_depth_counter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickypid%2Fwidget_tree_depth_counter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272833293,"owners_count":25000870,"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","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["counter","dart","flutter","flutter-package","flutter-packages","nested","nested-widgets","package","pubdev","widget","widget-tree","widgets-counter"],"created_at":"2024-09-30T17:06:36.315Z","updated_at":"2025-10-04T12:23:11.581Z","avatar_url":"https://github.com/rickypid.png","language":"Dart","funding_links":["https://github.com/sponsors/rickypid","https://buymeacoffee.com/veweju"],"categories":[],"sub_categories":[],"readme":"#### widget_tree_depth_counter\n# Widget Tree Depth Counter\n\n[![](https://img.shields.io/static/v1?label=flutter\u0026message=widget_tree_depth_counter\u0026color=red??style=for-the-badge\u0026logo=GitHub)](https://github.com/rickypid/widget_tree_depth_counter)\n[![Pub Package](https://img.shields.io/pub/v/widget_tree_depth_counter.svg?style=flat-square)](https://pub.dartlang.org/packages/widget_tree_depth_counter)\n[![Pub Points](https://img.shields.io/pub/points/widget_tree_depth_counter)](https://pub.dev/packages/widget_tree_depth_counter/score)\n[![Pub Likes](https://img.shields.io/pub/likes/widget_tree_depth_counter)](https://pub.dev/packages/widget_tree_depth_counter/score)\n\n[![Package Issue](https://img.shields.io/github/issues/rickypid/widget_tree_depth_counter)](https://github.com/rickypid/widget_tree_depth_counter/issues)\n![Package License](https://img.shields.io/github/license/rickypid/widget_tree_depth_counter)\n\n`WidgetTreeDepthCounter` is a simple widget to count the amount of nested widget tree, useful in the dynamic construction of the interface when it is important to know the depth of widget.\n\n| ![Image](https://github.com/rickypid/widget_tree_depth_counter/blob/master/doc/.media/example.jpg?raw=true) |\n| :------------: |\n| **WidgetTreeDepthCounter** |\n\n## Features\n\n* count of the depth of the widget with respect to the tree **(all uses of WidgetTreeDepthCounter in the current tree are counted, the other types of widgets are not counted)**\n\nThis widget can be used conveniently in such cases:\n\n- Dynamically manage the colors of widgets based on their position in the tree\n- in an app that manages chapter numbers it is very easy to renumber them in case a chapter is removed.\n- ...\n\n  Many other cases where it is very difficult to manage a widget through fixed parameters to be managed based on the construction of the tree.\n\n\u0026nbsp;\n\n## Usage\n\nMake sure to check out the [examples on GitHub](https://github.com/rickypid/widget_tree_depth_counter/tree/master/example).\n\n| ![Image](https://github.com/rickypid/widget_tree_depth_counter/blob/master/doc/.media/widget_tree_example.jpg?raw=true) |\n| :------------: |\n| **Example of operation in a widget tree** |\n\n### Installation\n\n#### From `pubspec.yaml`\n\nAdd the following line to `pubspec.yaml`:\n\n```yaml\ndependencies:\n  widget_tree_depth_counter: \u003clast-release\u003e\n```\n\nand \n\n```bash\nflutter pub get\n```\n\n#### From cli\n\nrun following command:\n\n```bash\nflutter pub add widget_tree_depth_counter\n```\n\n### Basic setup\n\n*Complete example [available here](https://github.com/rickypid/widget_tree_depth_counter/blob/master/example/lib/main.dart).*\n\n```dart\nParentWidget(\n  child: WidgetTreeDepthCounter(\n    builder: (context, counter) =\u003e //counter=0\n      Container(\n        color: Theme.of(context)\n          .primaryColor\n          .withOpacity(counter * 0.05 + 0.05),\n          child: WidgetTreeDepthCounter(\n            builder: (context, counter) =\u003e//counter=1\n                Container(\n                    color: Theme.of(context)\n                    .primaryColor\n                        .withOpacity(counter * 0.05 + 0.05),\n                ),\n          ),\n      ),\n  ),\n),\n```\n\n### WidgetTreeDepthCounter Properties\n\n* `builder`: Function called at layout time to construct the widget tree, return `Widget`.\n* `count`: With this parameter it's possible define or overwrite the current depth count value.\n\n\u0026nbsp;\n\n### Use current `counter` value during build `WidgetTreeDepthCounter`\n\n`WidgetTreeDepthCounter` uses [Provider](https://pub.dev/packages/provider) library to count the depth, but if it is necessary to access the current value to perform a sum (for example), it is possible to retrieve the count value through the `Provider 'functions:\n\n```dart\n\nWidgetTreeDepthCounter(\n\t\t\tcount: context.read\u003cDepthCounter\u003e().value + 2,\n            builder: (context, counter) =\u003e\n                Text(counter.toString()),\n          )\n\n```\n\n**Obviously to access the value via `context.read\u003cDepthCounter\u003e()` it is necessary that at least one `WidgetTreeDepthCounter` is present in the tree and `provider` package is required.**\n\n\u0026nbsp;\n\n## 📚 My open source projects\n\n### Flutter\n\n| Package | Verison | Score | Likes | Test | Coverage |\n|--|--|--|--|--|--|\n| [![](https://img.shields.io/static/v1?label=flutter\u0026message=flutter_expandable_table\u0026color=red??style=for-the-badge\u0026logo=GitHub)](https://github.com/rickypid/flutter_expandable_table) | [![Pub Package](https://img.shields.io/pub/v/flutter_expandable_table.svg?style=flat-square)](https://pub.dartlang.org/packages/flutter_expandable_table) | [![Pub Points](https://img.shields.io/pub/points/flutter_expandable_table)](https://pub.dev/packages/flutter_expandable_table/score) | [![Pub Likes](https://img.shields.io/pub/likes/flutter_expandable_table)](https://pub.dev/packages/flutter_expandable_table/score) |  |  |\n| [![](https://img.shields.io/static/v1?label=flutter\u0026message=widget_tree_depth_counter\u0026color=red??style=for-the-badge\u0026logo=GitHub)](https://github.com/rickypid/widget_tree_depth_counter) | [![Pub Package](https://img.shields.io/pub/v/widget_tree_depth_counter.svg?style=flat-square)](https://pub.dartlang.org/packages/widget_tree_depth_counter) | [![Pub Points](https://img.shields.io/pub/points/widget_tree_depth_counter)](https://pub.dev/packages/widget_tree_depth_counter/score) | [![Pub Likes](https://img.shields.io/pub/likes/widget_tree_depth_counter)](https://pub.dev/packages/widget_tree_depth_counter/score) |  |  |\n| [![](https://img.shields.io/static/v1?label=flutter\u0026message=flutter_scroll_shadow\u0026color=red??style=for-the-badge\u0026logo=GitHub)](https://github.com/rickypid/flutter_scroll_shadow) | [![Pub Package](https://img.shields.io/pub/v/flutter_scroll_shadow.svg?style=flat-square)](https://pub.dartlang.org/packages/flutter_scroll_shadow) | [![Pub Points](https://img.shields.io/pub/points/flutter_scroll_shadow)](https://pub.dev/packages/flutter_scroll_shadow/score) | [![Pub Likes](https://img.shields.io/pub/likes/flutter_scroll_shadow)](https://pub.dev/packages/flutter_scroll_shadow/score) |  |  |\n| [![](https://img.shields.io/static/v1?label=flutter\u0026message=flutter_bargraph\u0026color=red??style=for-the-badge\u0026logo=GitHub)](https://github.com/rickypid/flutter_bargraph) | [![Pub Package](https://img.shields.io/pub/v/flutter_bargraph.svg?style=flat-square)](https://pub.dartlang.org/packages/flutter_bargraph) | [![Pub Points](https://img.shields.io/pub/points/flutter_bargraph)](https://pub.dev/packages/flutter_bargraph/score) | [![Pub Likes](https://img.shields.io/pub/likes/flutter_bargraph)](https://pub.dev/packages/flutter_bargraph/score) |  |  |\n\n### Dart\n\n| Package | Verison | Score | Likes | Test | Coverage |\n|--|--|--|--|--|--|\n| [![](https://img.shields.io/static/v1?label=dart\u0026message=cowsay\u0026color=red??style=for-the-badge\u0026logo=GitHub)](https://github.com/rickypid/cowsay) | [![Pub Package](https://img.shields.io/pub/v/cowsay.svg?style=flat-square)](https://pub.dartlang.org/packages/cowsay) | [![Pub Points](https://img.shields.io/pub/points/cowsay)](https://pub.dev/packages/cowsay/score) | [![Pub Likes](https://img.shields.io/pub/likes/cowsay)](https://pub.dev/packages/cowsay/score) | [![Test CI](https://github.com/rickypid/cowsay/actions/workflows/test.yml/badge.svg)](https://github.com/rickypid/cowsay/actions/workflows/test.yml) | [![codecov](https://codecov.io/gh/rickypid/cowsay/branch/master/graph/badge.svg?token=Z65KEB9SAX)](https://codecov.io/gh/rickypid/cowsay) |\n| [![](https://img.shields.io/static/v1?label=dart\u0026message=telegram_link\u0026color=red??style=for-the-badge\u0026logo=GitHub)](https://github.com/rickypid/telegram_link) | [![Pub Package](https://img.shields.io/pub/v/telegram_link.svg?style=flat-square)](https://pub.dartlang.org/packages/telegram_link) | [![Pub Points](https://img.shields.io/pub/points/telegram_link)](https://pub.dev/packages/telegram_link/score) | [![Pub Likes](https://img.shields.io/pub/likes/telegram_link)](https://pub.dev/packages/telegram_link/score) | [![Test CI](https://github.com/rickypid/telegram_link/actions/workflows/test.yml/badge.svg)](https://github.com/rickypid/telegram_link/actions/workflows/test.yml) | [![codecov](https://codecov.io/gh/rickypid/telegram_link/branch/main/graph/badge.svg?token=Z65KEB9SAX)](https://codecov.io/gh/rickypid/telegram_link) |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickypid%2Fwidget_tree_depth_counter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frickypid%2Fwidget_tree_depth_counter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickypid%2Fwidget_tree_depth_counter/lists"}