flex_grid_layout 1.0.1 copy "flex_grid_layout: ^1.0.1" to clipboard
flex_grid_layout: ^1.0.1 copied to clipboard

Responsive grid that automatically adjusts its items based on available width.

example/example.dart

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

/// Entry point of the example application.
void main() {
  runApp(const MyApp());
}

/// A simple example that demonstrates how to use the [FlexGridLayout] widget.
///
/// This example shows a grid layout with 10 colored boxes, where the number
/// of items per row adapts based on the available width, with spacing between
/// items and rows.
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'FlexGridLayout Example',
      home: Scaffold(
        appBar: AppBar(
          title: const Text('FlexGridLayout Demo'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(16.0),
          // FlexGridLayout dynamically arranges the children into rows
          child: FlexGridLayout(
            minItemWidth: 120, // Minimum width per item
            maxItemsPerRow: 4, // Maximum number of items per row
            spacing: 12, // Horizontal spacing between items
            runSpacing: 12, // Vertical spacing between rows
            children: List.generate(
              10,
              (index) => Container(
                height: 100,
                decoration: BoxDecoration(
                  color: Colors.blueAccent,
                  borderRadius: BorderRadius.circular(12),
                ),
                alignment: Alignment.center,
                child: Text(
                  'Item ${index + 1}',
                  style: const TextStyle(color: Colors.white, fontSize: 16),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
2
likes
160
points
31
downloads

Publisher

verified publisherjhonacode.com

Weekly Downloads

Responsive grid that automatically adjusts its items based on available width.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flex_grid_layout