From 99b1bcc68b4230a9e3bd68011b7bbc0e17c1a20d Mon Sep 17 00:00:00 2001 From: Riccardo Cucia Date: Tue, 21 Dec 2021 09:52:32 +0100 Subject: [PATCH] Bugfix README.md, first stable release --- CHANGELOG.md | 4 ++ README.md | 2 +- example/README.md | 113 +++++++++++++++++++++++++++++++++++++++++++ example/pubspec.lock | 2 +- example/pubspec.yaml | 2 +- pubspec.yaml | 2 +- 6 files changed, 121 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d88e46a..d831915 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Widget Tree Depth Counter +## [1.0.0] +#### [@rickypid](https://github.com/rickypid) +- Stable release. + ## [0.0.1-alpha] #### [@rickypid](https://github.com/rickypid) - Initial release. diff --git a/README.md b/README.md index ff8a1f2..e0513ea 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ flutter pub get run following command: ```bash -flutter pub add provider +flutter pub add widget_tree_depth_counter ``` ### Basic setup diff --git a/example/README.md b/example/README.md index e69de29..1331113 100644 --- a/example/README.md +++ b/example/README.md @@ -0,0 +1,113 @@ +#### widget_tree_depth_counter +# 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) +[![likes](https://badges.bar/widget_tree_depth_counter/likes)](https://pub.dev/packages/widget_tree_depth_counter/score) +[![popularity](https://badges.bar/widget_tree_depth_counter/popularity)](https://pub.dev/packages/widget_tree_depth_counter/score) +[![pub points](https://badges.bar/widget_tree_depth_counter/pub%20points)](https://pub.dev/packages/widget_tree_depth_counter/score) + +[![Package Issue](https://img.shields.io/github/issues/rickypid/widget_tree_depth_counter)](https://github.com/rickypid/widget_tree_depth_counter/issues) +![Package License](https://img.shields.io/github/license/rickypid/widget_tree_depth_counter) + +`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. + +| ![Image](https://github.com/rickypid/widget_tree_depth_counter/blob/master/doc/.media/example.jpg?raw=true) | +| :------------: | +| **WidgetTreeDepthCounter** | + +## Features + +* 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)** + +This widget can be used conveniently in such cases: + +- Dynamically manage the colors of widgets based on their position in the tree +- in an app that manages chapter numbers it is very easy to renumber them in case a chapter is removed. +- ... + + 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. + +  + +## Usage + +Make sure to check out the [examples on GitHub](https://github.com/rickypid/widget_tree_depth_counter/tree/master/example). + +| ![Image](https://github.com/rickypid/widget_tree_depth_counter/blob/master/doc/.media/widget_tree_example.jpg?raw=true) | +| :------------: | +| **Example of operation in a widget tree** | + +### Installation + +#### From `pubspec.yaml` + +Add the following line to `pubspec.yaml`: + +```yaml +dependencies: + widget_tree_depth_counter: +``` + +and + +```bash +flutter pub get +``` + +#### From cli + +run following command: + +```bash +flutter pub add widget_tree_depth_counter +``` + +### Basic setup + +*Complete example [available here](https://github.com/rickypid/widget_tree_depth_counter/blob/master/example/lib/main.dart).* + +```dart +ParentWidget( + child: WidgetTreeDepthCounter( + builder: (context, counter) => //counter=0 + Container( + color: Theme.of(context) + .primaryColor + .withOpacity(counter * 0.05 + 0.05), + child: WidgetTreeDepthCounter( + builder: (context, counter) =>//counter=1 + Container( + color: Theme.of(context) + .primaryColor + .withOpacity(counter * 0.05 + 0.05), + ), + ), + ), + ), +), +``` + +### WidgetTreeDepthCounter Properties + +* `builder`: Function called at layout time to construct the widget tree, return `Widget`. +* `count`: With this parameter it's possible define or overwrite the current depth count value. + +  + +### Use current `counter` value during build `WidgetTreeDepthCounter` + +`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: + +```dart + +WidgetTreeDepthCounter( + count: context.read().value + 2, + builder: (context, counter) => + Text(counter.toString()), + ) + +``` + +**Obviously to access the value via `context.read()` it is necessary that at least one `WidgetTreeDepthCounter` is present in the tree and `provider` package is required.** + +  + diff --git a/example/pubspec.lock b/example/pubspec.lock index 0e45cf0..f05c333 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -162,7 +162,7 @@ packages: path: ".." relative: true source: path - version: "0.0.1-alpha" + version: "1.0.0" sdks: dart: ">=2.12.0 <3.0.0" flutter: ">=1.17.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 706346d..79a779e 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: widget_tree_depth_counter_example 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. -version: 0.0.1-alpha +version: 1.0.0 environment: sdk: ">=2.12.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 66d2e8c..bc5886f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: widget_tree_depth_counter 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. -version: 0.0.1-alpha +version: 1.0.0 repository: https://github.com/rickypid/widget_tree_depth_counter issue_tracker: https://github.com/rickypid/widget_tree_depth_counter/issues