responsive_gridview 1.0.4 copy "responsive_gridview: ^1.0.4" to clipboard
responsive_gridview: ^1.0.4 copied to clipboard

Responsive GridViw For All Platform, Configure custom columns count, Adjust Child and Overall Padding

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Responsive GridView Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Responsive GridView Examples'),
      ),
      body: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              const Text(
                'Basic Grid (2 columns)',
                style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
              ),
              const SizedBox(height: 8),
              ResponsiveGridView(
                column: 2,
                children: List.generate(
                  6,
                  (index) => Container(
                    color: Colors.blue[100 * (index % 9)],
                    height: 100,
                    child: Center(
                      child: Text('Item $index'),
                    ),
                  ),
                ),
              ),
              const SizedBox(height: 24),
              const Text(
                'Grid with Custom Spacing',
                style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
              ),
              const SizedBox(height: 8),
              ResponsiveGridView(
                column: 3,
                padding: const EdgeInsets.all(16),
                verticalSpacing: 16,
                horizontalSpacing: 16,
                children: List.generate(
                  9,
                  (index) => Container(
                    color: Colors.green[100 * (index % 9)],
                    height: 100,
                    child: Center(
                      child: Text('Item $index'),
                    ),
                  ),
                ),
              ),
              const SizedBox(height: 24),
              const Text(
                'Grid with Different Column Counts',
                style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
              ),
              const SizedBox(height: 8),
              ResponsiveGridView(
                column: 4,
                children: List.generate(
                  12,
                  (index) => Container(
                    color: Colors.purple[100 * (index % 9)],
                    height: 100,
                    child: Center(
                      child: Text('Item $index'),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
11
likes
160
points
9
downloads

Publisher

verified publishertherohitsoni.in

Weekly Downloads

Responsive GridViw For All Platform, Configure custom columns count, Adjust Child and Overall Padding

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

cupertino_icons, flutter

More

Packages that depend on responsive_gridview