flutter_dsl 0.1.0
flutter_dsl: ^0.1.0 copied to clipboard
A declarative UI helper extension package for Flutter, making your widget tree more expressive and readable.
flutter_dsl #
A declarative UI helper extension package for Flutter, making your widget tree more expressive and readable.
✨ Features #
- ✅ Widget extension methods for spacing, alignment, padding, gestures, etc.
- ✅ String extension for quick
Text()
widget creation with styles - ✅ Conditional rendering using
.visible()
and.ifTrue()
- ✅ Declarative spacing helper:
Spacing(h: 12)
,Spacing.square(24)
- ✅ Designed to be expressive, chainable, and Flutter-conventional
📦 Installation #
Add this to your pubspec.yaml
:
dependencies:
flutter_dsl: ^0.1.0
Then import:
import 'package:flutter_dsl/flutter_dsl.dart';
🚀 Quick Start
🔹 Widget Extensions
Text('Login')
.paddingAll(16)
.rounded(12)
.backgroundColor(Colors.blue)
.center()
.onTap(() => print('Tapped'));
🔹 String → Text DSL
'Welcome'
.text(fontSize: 18, fontWeight: FontWeight.bold);
'Title'.titleMedium(context);
'Body'.bodyMedium(context);
'Caption'.labelSmall(context);
🔹 Conditional Rendering
'Error occurred'.text().visible(hasError);
'Edit'.text().ifTrue(isEditable, orElse: () => Icon(Icons.lock));
🔹 Spacing DSL
Spacing(w: 12) // Horizontal spacing
Spacing(h: 16) // Vertical spacing
Spacing.square(24) // Square spacer
Spacing.none() // Empty SizedBox
🧪 Example
See example/lib/main.dart for a full working demo.