smart_wrap 0.0.8

SDKflutter
Platformandroidioswindowslinuxmacosweb

A flexible widget that allows creating rows, columns, and wrap layouts with configurable properties.

📦 SmartWrap - Flexible Layout Widget

SmartWrap is a versatile Flutter widget that lets you create dynamic layouts using Row, Column, or Wrap, with customizable alignment, spacing, and layout properties.

🚀 Features

  • Row, Column, and Wrap layout options in one widget!
  • Customize:
    • MainAxisAlignment
    • CrossAxisAlignment
    • MainAxisSize
  • Control:
    • TextDirection and VerticalDirection for Row and Column.
    • spacing and runSpacing for Wrap.

📥 Installation

Add this to your pubspec.yaml:

dependencies:
  smart_wrap: ^0.0.8

Then, run:

flutter pub get

💡 Usage

Here’s how to use SmartWrap in your Flutter app:

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('SmartWrap Example')),
        body: Center(
          child: SmartWrap(
            type: WrapType.wrap, // Choose between Row, Column, and Wrap
            spacing: 10.0,
            runSpacing: 10.0,
            wrapAlignment: Alignment.center,
            children: [
              Container(width: 50, height: 50, color: Colors.red),
              Container(width: 50, height: 50, color: Colors.green),
              Container(width: 50, height: 50, color: Colors.blue),
              Container(width: 50, height: 50, color: Colors.orange),
            ],
          ),
        ),
      ),
    );
  }
}

📊 Available Parameters:

ParameterDescription
typeChoose between WrapType.row, WrapType.column, or WrapType.wrap.
childrenList of child widgets to display.
mainAxisAlignmentAlign children along the main axis (for Row and Column).
crossAxisAlignmentAlign children along the cross axis (for Row and Column).
mainAxisSizeThe size of the main axis (for Row and Column).
textDirectionText alignment in horizontal direction (for Row and Column).
verticalDirectionControls the vertical direction (for Row and Column).
spacingHorizontal spacing between children in Wrap.
runSpacingVertical spacing between lines in Wrap.
wrapAlignmentAlignment for the Wrap widget.

🧪 Example

1. Wrap Example:

SmartWrap(
  type: WrapType.wrap,
  spacing: 10.0,
  runSpacing: 10.0,
  children: [
    Container(width: 50, height: 50, color: Colors.red),
    Container(width: 50, height: 50, color: Colors.green),
    Container(width: 50, height: 50, color: Colors.blue),
  ],
)

2. Row Example:

SmartWrap(
  type: WrapType.row,
  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  children: [
    Container(width: 50, height: 50, color: Colors.red),
    Container(width: 50, height: 50, color: Colors.green),
    Container(width: 50, height: 50, color: Colors.blue),
  ],
)

3. Column Example:

SmartWrap(
  type: WrapType.column,
  crossAxisAlignment: CrossAxisAlignment.center,
  children: [
    Container(width: 50, height: 50, color: Colors.red),
    Container(width: 50, height: 50, color: Colors.green),
    Container(width: 50, height: 50, color: Colors.blue),
  ],
)

✨ Conclusion

SmartWrap is designed to simplify layout management in Flutter, giving you the power to switch between Row, Column, and Wrap with ease, while offering full control over alignment and spacing!

Contributions and feedback are welcome!


Author

Developed with ❤️ by Sanoop Das. Connect with me on LinkedIn.


Support

If you like this package, please give it a ⭐ on pub.dev and share it with the Flutter community!


Happy Coding!