A configurable spacing system for Flutter applications that provides consistent design tokens and convenient widgets for managing spacing throughout your app.
- 🎯 Configurable base unit: Set your design system's base spacing unit once
- 📏 Consistent spacing scale: Pre-defined spacing values from 0.25x to 10x your base unit
- 🎨 EdgeInsets extensions: Easy-to-use extensions for padding and margins
- 🔧 Gap widgets: Convenient spacing widgets that integrate with your spacing system
- 🧪 Well tested: Comprehensive test coverage
- 🚀 Zero dependencies: Only depends on Flutter SDK and the gap package
Add this to your package's pubspec.yaml file:
dependencies:
pretty_good_spacing: ^0.0.1Then run:
flutter pub getInitialize the spacing system in your app (optional - defaults to 8.0):
import 'package:flutter/material.dart';
import 'package:pretty_good_spacing/pretty_good_spacing.dart';
void main() {
// Optional: Set custom base spacing unit
Space.initialize(spacingUnit: 4.0);
runApp(MyApp());
}import 'package:pretty_good_spacing/pretty_good_spacing.dart';
Container(
// Using spacing values directly
padding: EdgeInsets.all(Space.space200), // 16px with default 8px base
margin: EdgeInsets.symmetric(horizontal: Space.space100), // 8px
child: Text('Hello World'),
)Container(
// Using convenient extensions
padding: Space.space200.all,
margin: Space.space100.horizontal,
child: Column(
children: [
Text('Title'),
Padding(
padding: Space.space050.vertical,
child: Text('Subtitle'),
),
],
),
)Column(
children: [
Text('First item'),
KGap.space100(), // 8px gap
Text('Second item'),
KGap.space200(), // 16px gap
Text('Third item'),
],
)The spacing system provides these values (multipliers of your base unit):
space0: 0 - Reset spacingspace025: 0.25x - Very small spacingspace050: 0.5x - Small spacingspace075: 0.75x - Small spacingspace100: 1x - Base spacing (default)space150: 1.5x - Medium spacingspace200: 2x - Medium spacingspace250: 2.5x - Medium spacingspace300: 3x - Large spacingspace400: 4x - Large spacingspace500: 5x - Very large spacingspace600: 6x - Very large spacingspace800: 8x - Extra large spacingspace1000: 10x - Maximum spacing
All spacing values support these extension methods:
.all- All sides.horizontal- Left and right.vertical- Top and bottom.top,.bottom,.left,.right- Individual sides.topLeft,.topRight,.bottomLeft,.bottomRight- Corner combinations
This package is designed to help Flutter developers maintain consistent spacing throughout their applications by providing a configurable, scalable spacing system.
Contributions are welcome! Please feel free to submit a Pull Request.
Please file issues on the GitHub repository.