flutter_widget_skewer 0.0.1 copy "flutter_widget_skewer: ^0.0.1" to clipboard
flutter_widget_skewer: ^0.0.1 copied to clipboard

A Dart code generator that makes Flutter widgets chainable like skewers. With widget_skewer, you can build widget trees with extension methods instead of nesting braces.

flutter_widget_skewer #

A Dart code generator that lets you build Flutter widget trees using method chaining.
No more declarative UI — just chain widgets like skewered food 🍢.


✨ Features #

  • Chain any widget constructor as an extension method
  • Cleaner syntax, less boilerplate
  • Supports both Widget and List<Widget>
  • Works with most Flutter SDK widgets
  • Type-safe, since everything is generated from Flutter SDK

🚀 Getting Started #

Add to your pubspec.yaml:

dependencies:
  flutter_widget_skewer:

Run build runner:

flutter pub run build_runner build

or

dart run build_runner build

Import generated extensions:

import 'package:YOUR_PACKAGE/gen/flutter_widget_skewer.g.dart'';

🛠 Usage #

With flutter_widget_skewer, you can write:

    Text('Hello Widget')
        .container(
            padding: const EdgeInsets.all(8),
            color: Colors.grey,
            alignment: Alignment.center)
        .opacity(opacity: 0.5)
        .rotatedBox(quarterTurns: 1)
        .card(margin: EdgeInsets.all(16), clipBehavior: Clip.antiAlias)
        .inkWell(onTap: () {}, focusNode: FocusNode())
        .ignorePointer(ignoring: false)
        .hero(tag: UniqueKey());

Instead of writing:

    Hero(
      tag: UniqueKey(),
      child: IgnorePointer(
        ignoring: false,
        child: InkWell(
          onTap: () {},
          focusNode: FocusNode(),
          child: Card(
            margin: EdgeInsets.all(16),
            clipBehavior: Clip.antiAlias,
            child: RotatedBox(
              quarterTurns: 1,
              child: Opacity(
                opacity: 0.5,
                child: Container(
                  padding: const EdgeInsets.all(8),
                  color: Colors.grey,
                  alignment: Alignment.center,
                  child: Text('Hello Widget'),
                ),
              ),
            ),
          ),
        ),
      ),
    );

🆚 Comparison #

Cleaner, flatter, easier to read.
No more bracket hell 🎉


⛓️ Chaining with List<Widget> #

flutter_widget_skewer not only supports chaining on a single Widget,
but also on a List<Widget> — useful for constructors that take multiple children.

For example:

final items = [
  Text('Item 1'),
  Text('Item 2'),
  Text('Item 3'),
];

/// Instead of:
Column(
  children: items,
);

/// You can chain directly:
items.column();

This also works with widgets that take slivers:

final slivers = [
  SliverAppBar(title: Text('Hello')),
  SliverList(delegate: SliverChildListDelegate([...]))
];

slivers.customScrollView();

👉 This makes it easy to go from a list of widgets straight into layout widgets without extra boilerplate.


⚠️ Limitations #

Currently, the following widgets are not generated by flutter_widget_skewer:

  • CupertinoTextSelectionToolbar
  • TextSelectionToolbar

These widgets have unique constructor, which make them technically difficult to support with the current generator.

(They are not commonly used in widget composition, but if you need them, feel free to open an issue or contribute a PR!)


🤝 Contributing #

Issues and PRs are welcome!
If you find unsupported widgets or have ideas for improvement, feel free to contribute.


📄 License #

MIT

5
likes
0
points
24
downloads

Publisher

verified publisherzyzdev.dev

Weekly Downloads

A Dart code generator that makes Flutter widgets chainable like skewers. With widget_skewer, you can build widget trees with extension methods instead of nesting braces.

Repository (GitHub)
View/report issues

Topics

#build-runner #codegen

License

unknown (license)

Dependencies

analyzer, build, build_runner, collection, path

More

Packages that depend on flutter_widget_skewer