# nested 1.0.0

A Flutter Widget which helps nest multiple widgets without needing to manually nest them.




## Installing
```
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add nested
```
Published: 2021-02-17T20:14:01.118062Z
Expected archive SHA-256: 03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20

Available in cache; verification: upstream_checksum
## Direct dependencies
- flutter: map[sdk:flutter]

## Package README (untrusted upstream documentation)
[![pub package](https://img.shields.io/pub/v/nested.svg)](https://pub.dartlang.org/packages/nested) ![ci](https://github.com/rrousselGit/nested/workflows/ci/badge.svg)

A widget that simplifies the syntax for deeply nested widget trees.

## Motivation

Widgets tend to get pretty nested rapidly.
It's not rare to see:

```dart
MyWidget(
  child: AnotherWidget(
    child: Again(
      child: AndAgain(
        child: Leaf(),
      )
    )
  )
)
```

That's not very ideal.

There's where `nested` propose a solution.
Using `nested`, it is possible to flatten the previous tree into:

```dart
Nested(
  children: [
    MyWidget(),
    AnotherWidget(),
    Again(),
    AndAgain(),
  ],
  child: Leaf(),
),
```

That's a lot more readable!

## Usage

`Nested` relies on a new kind of widget: [SingleChildWidget], which has two
concrete implementation:

- [SingleChildStatelessWidget]
- [SingleChildStatefulWidget]

These are [SingleChildWidget] variants of the original `Stateless`/`StatefulWidget`.

The difference between a widget and its single-child variant is that they have
a custom `build` method that takes an extra parameter.

As such, a `StatelessWidget` would be:

```dart
class MyWidget extends StatelessWidget {
  MyWidget({Key key, this.child}): super(key: key);

  final Widget child;

  @override
  Widget build(BuildContext context) {
    return SomethingWidget(child: child);
  }
}
```

Whereas a [SingleChildStatelessWidget] would be:

```dart
class MyWidget extends SingleChildStatelessWidget {
  MyWidget({Key key, Widget child}): super(key: key, child: child);

  @override
  Widget buildWithChild(BuildContext context, Widget child) {
    return SomethingWidget(child: child);
  }
}
```

This allows our new `MyWidget` to be used both with:

```dart
MyWidget(
  child: AnotherWidget(),
)
```

and to be placed inside `children` of [Nested] like so:

```dart
Nested(
  children: [
    MyWidget(),
    ...
  ],
  child: AnotherWidget(),
)
```

[singlechildwidget]: https://pub.dartlang.org/documentation/nested/latest/nested/SingleChildWidget-class.html
[singlechildstatelesswidget]: https://pub.dartlang.org/documentation/nested/latest/nested/SingleChildStatelessWidget-class.html
[singlechildstatefulwidget]: https://pub.dartlang.org/documentation/nested/latest/nested/SingleChildStatefulWidget-class.html

## Changelog
## 1.0.0

First stable release of Nested (with null safety)

## 0.0.5-nullsafety.0

- Support null-safety (Thanks to [@vishna](https://github.com/vishna)!)

## 0.0.4

- Handle reorder through `GlobalKey`s

## 0.0.3

- Made the element of Stateless/Stateful variants public

## 0.0.2

- Added the ability to implement `SingleChildWidget` using mixins
- Added support for `InheritedWidget` (only using mixins).

## 0.0.1

Initial release







 
