escape_parent_padding
A lightweight Flutter widget that allows child widgets to visually escape the padding applied by a parent widget. Useful when you want specific widgets (like a horizontally scrolling ListView) to ignore parent padding and span the full screen width.
π₯ Demo
| Before | After |
|
|
β¨ Features
- π§© Escape parent padding without layout hacks.
- πͺ Use
EscapablePadding.litefor simple one-child use cases. - π― Use
EscapablePaddingwith multiple children and custom layouts. - π§± Skip padding for specific children using the
Escapedwidget.
π Getting Started
1. Add the dependency
In your pubspec.yaml:
dependencies:
escape_parent_padding: ^1.0.4
Then run:
flutter pub get
2. Import the package
import 'package:escape_parent_padding/escapable_padding.dart';
π¦ Usage
πΉ Escapable Padding (Multiple Children)
Use this when you want to apply padding to all children except specific ones.
EscapablePadding(
padding: const EdgeInsets.all(16),
children: [
const Text('Padded Item 1'),
Escaped(
child: Container(
color: Colors.red,
padding: const EdgeInsets.all(8),
child: const Text('I am not padded'),
),
),
const Text('Padded Item 2'),
],
builder: (context, children) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: children,
),
)
πΈ Lite Mode (Single Escaped Child)
Use this when you want just one child to escape horizontal padding.
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: EscapablePadding.lite(
height: 100,
child: Container(
color: Colors.blue,
width: 500,
alignment: Alignment.center,
child: const Text('I escape the parent padding!'),
),
),
)
π Example
For a full working sample, see the example/ folder.
π Additional Information
- Built for simplicity and clean layouts.
- Works well inside
Column,ListView, and other layout widgets. - Lightweight with no dependencies.
π€ Contributing
Contributions are welcome! If you find a bug or want a feature, open an issue or PR on GitHub.
π License
MIT License. See the LICENSE file for more info.