nested
1.0.0, released 6 years ago by dash-overflow.net
Widget that flattens deeply nested widget trees into a list of children.
What it does
Nested provides a `Nested` widget that accepts a list of `SingleChildWidget`s, allowing developers to write long widget trees in a flat, readable form. It also introduces `SingleChildStatelessWidget` and `SingleChildStatefulWidget` to enable widgets to be used both normally and within `Nested`.
AI-written summary of version 1.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You have deeply nested widget trees that hurt readability.
- You want to reuse custom widgets that can be placed inside a flat list without refactoring the entire tree.
- You need a concise syntax for building complex UI hierarchies.
Skip it when
- You prefer the traditional nested syntax for simplicity.
- Your widgets do not support the SingleChildWidget interface and you cannot modify them.
Strengths
- Improves readability of complex widget trees
- Supports null safety and modern Flutter patterns
- Allows custom widgets to be used both normally and inside Nested
Weaknesses
- Requires widgets to implement SingleChildWidget or use mixins
- Limited to single-child widgets
- Adds an extra layer of abstraction that may be unnecessary for simple UIs
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
```dart
Nested(
children: [
MyWidget(),
AnotherWidget(),
Again(),
AndAgain(),
],
child: Leaf(),
),
```Alternatives
Packages that do the same job and could replace nested.
- flutter_parsed_text
A widget to parse text and extract parts using predefined types or Regex.
50Compare - custom_clippers
Provides custom clipper widgets for ClipPath to create various shapes.
54Compare - slide_action
A highly customizable slide-to-perform-action widget for Flutter.
50Compare - footer
A customizable footer widget for Flutter applications.
49Compare
Works with
Packages commonly used together with nested: ones it builds on, ones built on it, and its own family.
- providerBuilt on nestedA lightweight wrapper around InheritedWidget for state management
- widgetbookBuilt on nestedA sandbox for building and testing Flutter widgets and screens in isolation.
- storybook_flutterBuilt on nestedA storybook for Flutter widgets to showcase and preview isolated components.
- bloc_presentationBuilt on nestedDispatch single-time side effects from Bloc or Cubit without polluting state.
- storybook_toolkitBuilt on nestedFlutter widget showcase and isolated preview tool
- mono_kitBuilt on nestedA collection of convenient widgets and utils made by mono.
- go_providerBuilt on nestedScope Provider or Bloc instances to specific go_router routes.