flutter_dsl 0.1.2+2 copy "flutter_dsl: ^0.1.2+2" to clipboard
flutter_dsl: ^0.1.2+2 copied to clipboard

A declarative UI helper extension package for Flutter, making your widget tree more expressive and readable.

pub package

flutter_dsl #

A declarative UI extension toolkit for Flutter, making your widget tree more expressive, readable, and concise.


โœจ Features #

  • ๐Ÿ”น Fluent widget extension methods: .paddingAll(), .rounded(), .onTap(), etc.
  • ๐Ÿ”น String-based Text() creation: 'Hello'.text(...)
  • ๐Ÿ”น Theme-aware text styles: 'Title'.titleMedium(context)
  • ๐Ÿ”น Conditional rendering: .visible(), .ifTrue(), .ifFalse()
  • ๐Ÿ”น Declarative spacing: Spacing.square(16), .gapBottom(12)
  • ๐Ÿ”น Designed to be chainable, intuitive, and Flutter-conventional

๐Ÿ“ฆ Installation #

Add to your pubspec.yaml:

dependencies:
  flutter_dsl: ^0.1.2+2

Then import it in your Dart files:

import 'package:flutter_dsl/flutter_dsl.dart';

๐Ÿš€ Quick Usage #

๐Ÿ”น Widget DSL

Text('Login')
  .paddingAll(16)
  .rounded(12)
  .backgroundColor(Colors.blue)
  .center()
  .onTap(() => print('Tapped'));

๐Ÿ”น Iterable Widget DSL

[
  Icon(Icons.star),
  'Favorite'.text(),
].row(spacing: 8);

[
  'Welcome'.headlineMedium(context),
  'Please log in'.text(),
].column(crossAxisAlignment: CrossAxisAlignment.start, spacing: 16);

[
  'A'.text().backgroundColor(Colors.red),
  'B'.text().backgroundColor(Colors.green).expanded(),
  'C'.text().backgroundColor(Colors.blue).flex(2),
].row();

๐Ÿ”น 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);         // Equal width & height
Spacing.none();             // Empty SizedBox

๐Ÿงช Example #

Check out the full working demo in: ๐Ÿ“„ example/lib/main.dart

๐Ÿ“Œ Why flutter_dsl? #

Flutter UI can be expressive, but often verbose. This package aims to: Reduce nesting and boilerplate Make UI code more readable Provide reusable and declarative patterns Stay consistent with Flutter's philosophy

๐Ÿค Contributing #

We welcome PRs and issues! Please open an issue or fork and create a PR.

๐Ÿ“„ License #

MIT License ยฉ 2025 HARDY

4
likes
160
points
125
downloads

Publisher

unverified uploader

Weekly Downloads

A declarative UI helper extension package for Flutter, making your widget tree more expressive and readable.

Repository (GitHub)
View/report issues

Topics

#dsl #ui #widget #extension #flutter

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_dsl