pretty_good_spacing 0.1.0
pretty_good_spacing: ^0.1.0 copied to clipboard
A configurable spacing system for Flutter applications with consistent design tokens and convenient widgets.
Pretty Good Spacing #
A configurable spacing system for Flutter applications that provides consistent design tokens and convenient widgets for managing spacing throughout your app.
Features #
- π― 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
Getting started #
Add this to your package's pubspec.yaml file:
dependencies:
pretty_good_spacing: ^0.1.0
Then run:
flutter pub get
Usage #
Basic Setup #
Initialize 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());
}
Using Spacing Values #
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'),
)
Using EdgeInsets Extensions #
Container(
// Using convenient extensions
padding: Space.space200.all,
margin: Space.space100.horizontal,
child: Column(
children: [
Text('Title'),
Padding(
padding: Space.space50.vertical,
child: Text('Subtitle'),
),
],
),
)
Using Gap Widgets #
Column(
children: [
Text('First item'),
KGap.space100(), // 8px gap
Text('Second item'),
KGap.space125(), // 10px gap
Text('Third item'),
KGap.space200(), // 16px gap
Text('Fourth item'),
],
)
Available Spacing Values #
The spacing system provides these values (multipliers of your base unit):
space0: 0 - Reset spacingspace25: 0.25x - Very small spacingspace50: 0.5x - Small spacingspace75: 0.75x - Small spacingspace100: 1x - Base spacing (default)space125: 1.25x - Small-medium spacingspace150: 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
EdgeInsets Extension Methods #
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
Additional information #
This package is designed to help Flutter developers maintain consistent spacing throughout their applications by providing a configurable, scalable spacing system.
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
Issues #
Please file issues on the GitHub repository.