widgets_spacing 0.0.5 copy "widgets_spacing: ^0.0.5" to clipboard
widgets_spacing: ^0.0.5 copied to clipboard

Insert spacing between widgets. Especially for Column and Row in Flutter.

Widgets Spacing Library #

The widgets_spacing library provides utility functions and extensions for adding consistent spacing between widgets in a Flutter application. This library uses the gap package to insert gaps between widgets.

Features #

  • Custom Spacing: Easily define spacing between widgets with a configurable multiplier.
  • List Extension: Add spacing to a list of widgets using an extension method.
  • Flexible Spacing: Specify different sizes for gaps between widgets.

Usage #

Import the Library #

import 'package:widgets_spacing/widgets_spacing.dart';

Basic Usage #

The spacing function returns the default spacing (8.0) multiplied by the given size.

final double defaultSpacing = spacing(); // 4.0
final double doubleSpacing = spacing(2); // 8.0

Adding Spacing Between Widgets #

Use the widgetsSpacing function to add gaps between widgets.

final widgets = [
  Text('First'),
  Text('Second'),
  Text('Third'),
];

final spacedWidgets = widgetsSpacing(widgets, size: 2);

// Use the spacedWidgets in your widget tree
Column(
  children: spacedWidgets,
);

Extension Method #

Use the withSpace extension method on a list of widgets to add gaps.

final widgets = [
  Text('First'),
  Text('Second'),
  Text('Third'),
];

final spacedWidgets = widgets.withSpace(2);

// Use the spacedWidgets in your widget tree
Column(
  children: spacedWidgets,
);

Row(
  children: spacedWidgets,
);

Example #

Here's a complete example demonstrating how to use the widgets_spacing library:

import 'package:flutter/material.dart';
import 'package:widgets_spacing/widgets_spacing.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Widgets Spacing Example')),
        body: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            children: [
              Text('First'),
              Text('Second'),
              Text('Third')
            ].withSpace(2),
          ),
        ),
      ),
    );
  }
}

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Feel free to adjust the installation instructions if your package is already available on pub.dev. If it is, you can replace the installation section with the standard pub.dev installation instructions:

1
likes
0
points
51
downloads

Publisher

verified publishereuisoft.com

Weekly Downloads

Insert spacing between widgets. Especially for Column and Row in Flutter.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, gap

More

Packages that depend on widgets_spacing