selection_mode 0.0.6 copy "selection_mode: ^0.0.6" to clipboard
selection_mode: ^0.0.6 copied to clipboard

A Flutter package for multi-item selection with range selection

example/lib/main.dart

import 'package:flutter/material.dart';

import 'basic_list_demo.dart';
import 'file_manager_demo.dart';
import 'mixed_selection_demo.dart';
import 'grid_selection_demo.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Selection Mode Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(primarySwatch: Colors.blue, useMaterial3: true),
      home: const DemoHomePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Selection Mode Package'),
        centerTitle: true,
      ),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            const Text(
              'Demo Examples',
              style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
            ),
            const SizedBox(height: 8),
            const Text(
              'Explore different use cases and configurations',
              style: TextStyle(color: Colors.grey),
            ),
            const SizedBox(height: 24),
            Expanded(
              child: ListView(
                children: [
                  _DemoCard(
                    title: 'Basic List Selection',
                    description: 'Simple list with manual selection mode',
                    icon: Icons.list,
                    onTap: () => _navigateTo(context, const BasicListDemo()),
                  ),
                  const SizedBox(height: 16),
                  _DemoCard(
                    title: 'Grid Photo Gallery',
                    description: 'Photo grid with default behavior',
                    icon: Icons.photo_library,
                    onTap: () =>
                        _navigateTo(context, const GridSelectionDemo()),
                  ),
                  const SizedBox(height: 16),
                  _DemoCard(
                    title: 'Mixed Selection List',
                    description:
                        'Contact list with auto toggle and constraints',
                    icon: Icons.contacts,
                    onTap: () =>
                        _navigateTo(context, const MixedSelectionDemo()),
                  ),
                  const SizedBox(height: 16),
                  _DemoCard(
                    title: 'File Manager',
                    description: 'File list with keyboard shortcuts',
                    icon: Icons.folder,
                    onTap: () => _navigateTo(
                      context,
                      const FileManagerDemo(),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

  void _navigateTo(BuildContext context, Widget page) {
    Navigator.push(context, MaterialPageRoute(builder: (context) => page));
  }
}

class _DemoCard extends StatelessWidget {
  const _DemoCard({
    required this.title,
    required this.description,
    required this.icon,
    required this.onTap,
  });

  final String title;
  final String description;
  final IconData icon;
  final VoidCallback onTap;

  @override
  Widget build(BuildContext context) {
    return Card(
      elevation: 2,
      child: InkWell(
        onTap: onTap,
        borderRadius: BorderRadius.circular(12),
        child: Padding(
          padding: const EdgeInsets.all(20),
          child: Row(
            children: [
              Container(
                padding: const EdgeInsets.all(12),
                decoration: BoxDecoration(
                  color: Theme.of(context).primaryColor.withValues(alpha: 0.1),
                  borderRadius: BorderRadius.circular(8),
                ),
                child: Icon(
                  icon,
                  size: 32,
                  color: Theme.of(context).primaryColor,
                ),
              ),
              const SizedBox(width: 16),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      title,
                      style: TextStyle(
                        fontSize: 18,
                        fontWeight: FontWeight.w600,
                      ),
                    ),
                    const SizedBox(height: 4),
                    Text(
                      description,
                      style: TextStyle(color: Colors.grey[600], fontSize: 14),
                    ),
                  ],
                ),
              ),
              Icon(Icons.chevron_right),
            ],
          ),
        ),
      ),
    );
  }
}
3
likes
160
points
35
downloads

Publisher

verified publisherdegenk.com

Weekly Downloads

A Flutter package for multi-item selection with range selection

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, meta

More

Packages that depend on selection_mode