multiselect_dropdown_with_select_all 0.4.5 copy "multiselect_dropdown_with_select_all: ^0.4.5" to clipboard
multiselect_dropdown_with_select_all: ^0.4.5 copied to clipboard

The Multi-select Dropdown with Select All streamlines bulk selections, reducing clicks and enhancing user experience with easy integration and customization.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:multiselect_dropdown_with_select_all/multiselect_dropdown_with_select_all.dart';
// Import the file with the custom widget

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Multi-Select Dropdown Example')),
        body: MultiSelectForm(),
      ),
    );
  }
}

class MultiSelectForm extends StatefulWidget {
  @override
  _MultiSelectFormState createState() => _MultiSelectFormState();
}

class _MultiSelectFormState extends State<MultiSelectForm> {
  final _formKey = GlobalKey<FormState>();
  // List<String> items = ['Option 1', 'Option 2','Option 4','Option 5','Option 6','Option 2','Option 2', 'Option 3', 'Option 3', 'Option 3', 'Option 3', 'Option 3'];
  List<String> selectedItems = [];

  void _handleSelectionChange(List<String> newSelection) {
    setState(() {
      selectedItems = newSelection;
    });
    print('Selected Items: $selectedItems');
  }

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(16.0),
      child: Form(
        key: _formKey,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            SizedBox(
              width: 155,
              child: MultiSelectDropdown(
                items: [
                  MultiSelectItem('1', 'Option 1'),
                  MultiSelectItem('2', 'Option 2'),
                  MultiSelectItem('3', 'Option 3'),
                  MultiSelectItem('4', 'Option 4'),
                  MultiSelectItem('5', 'Option 5'),
                  MultiSelectItem('7', 'Option 6'),
                ],
                initialSelectedValues: selectedItems,
                hint: 'Select Options',
                // listTitle: 'Items',
                // listTitleFontSize: 23,
                // listTitleColor: Colors.green,
                showCheckboxInSingleSelect: true,
                // selectAllflag: true,
                isMultiSelect: false,
                useRadioButton: true,
                onChanged: (selectedItems) {
                  print(selectedItems);
                },
              ),
            ),
            SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                if (_formKey.currentState!.validate()) {
                  // Form is valid, handle submission
                  print('Final Selected Items: $selectedItems');
                }
              },
              child: Text('Submit'),
            ),
          ],
        ),
      ),
    );
  }
}
5
likes
160
points
27
downloads

Publisher

verified publisherfaceboss.online

Weekly Downloads

The Multi-select Dropdown with Select All streamlines bulk selections, reducing clicks and enhancing user experience with easy integration and customization.

Homepage

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on multiselect_dropdown_with_select_all