persistent_header_adaptive
2.1.3, released a year ago by camillobucciarelli.dev
Provides a SliverPersistentHeader that automatically adapts its height to its child content.
WASM-ready
What it does
The widget measures its child without height constraints and updates the sliver height to match the content. It supports pinned and floating behavior and optional repaint control.
AI-written summary of version 2.1.3, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need a header in a CustomScrollView whose height varies with its content
- You want to avoid hard‑coding header heights
- You need smooth scrolling with adaptive header size
Skip it when
- Header size is static and known beforehand
- Performance is critical on low‑end devices and frequent size changes
Strengths
- Eliminates manual height calculations
- Works with pinned and floating headers
- Simple API with optional initialHeight for performance
Weaknesses
- Adds a measurement step that may impact performance on very dynamic content
- Limited to Flutter’s sliver system
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
class Header extends StatelessWidget{const Header({super.key});@override Widget build(BuildContext context){return Container(padding:const EdgeInsets.all(20),color:Colors.grey,child:Column(mainAxisSize:MainAxisSize.min,children:[const Text('line 1'),const SizedBox(height:20),Row(mainAxisAlignment:MainAxisAlignment.spaceEvenly,children:[const Text('line 2.1'),const Text('line 2.2')]),const SizedBox(height:20),ElevatedButton(onPressed:(){},child:const Text('button'))]));}}Alternatives
Packages that do the same job and could replace persistent_header_adaptive.
- after_layout
Provides a generic way to run code after a widget is laid out, useful for size measurement without a dedicated sliver header
50Compare