awesome_padding_margin 2.0.0
awesome_padding_margin: ^2.0.0 copied to clipboard
A collection of Flutter widget extensions for adding padding, margin, and slivers in a cleaner and more expressive way.
import 'package:awesome_padding_margin/awesome_extensions.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Awesome Extensions Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: const DemoPage(),
);
}
}
class DemoPage extends StatelessWidget {
const DemoPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Awesome Extensions Demo'),
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Padding and Margin Examples
const Text(
'Padding and Margin',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
).paddingOnly(bottom: 8),
const Text('This text has padding all around')
.paddingAll(16)
.marginOnly(bottom: 16)
.roundedRectangle(color: Colors.grey[200]),
// Alignment Examples
const Text(
'Alignment',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
).paddingOnly(bottom: 8),
Container(
height: 100,
width: double.infinity,
color: Colors.grey[300],
child: const Text('Centered Text').center,
).marginOnly(bottom: 16),
// Sizing Examples
const Text(
'Sizing',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
).paddingOnly(bottom: 8),
Row(
children: [
const Text('Fixed Width').width(100).backgroundColor(Colors.blue),
const SizedBox(width: 8),
const Text('Expanded').expand.backgroundColor(Colors.green),
],
).marginOnly(bottom: 16),
// Decoration Examples
const Text(
'Decoration',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
).paddingOnly(bottom: 8),
const Text('Rounded Rectangle with Shadow')
.paddingAll(16)
.roundedRectangle(
color: Colors.amber,
radius: 12,
boxShadow: [
BoxShadow(
color: Colors.black.withValues(),
blurRadius: 8,
offset: const Offset(0, 4),
),
],
)
.marginOnly(bottom: 16),
// Gesture Examples
const Text(
'Gestures',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
).paddingOnly(bottom: 8),
const Text('Tap Me!')
.paddingAll(16)
.roundedRectangle(color: Colors.purple)
.onTap(() {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Button tapped!')),
);
})
.marginOnly(bottom: 16),
// Animation Examples
const Text(
'Animations',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
).paddingOnly(bottom: 8),
const Text('Fade In Animation')
.paddingAll(16)
.roundedRectangle(color: Colors.teal)
.fadeIn()
.marginOnly(bottom: 16),
const Text('Slide In Animation')
.paddingAll(16)
.roundedRectangle(color: Colors.indigo)
.slideInFromLeft()
.marginOnly(bottom: 16),
// Responsive Example
const Text(
'Responsive',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
).paddingOnly(bottom: 8),
Container(
height: 100,
width: double.infinity,
color: Colors.grey[300],
child: const Text('Responsive Content').center,
)
.responsive(
mobile: const Text('Mobile View').center,
tablet: const Text('Tablet View').center,
desktop: const Text('Desktop View').center,
)
.marginOnly(bottom: 16),
],
),
),
);
}
}