vit_combo_box 4.0.1 copy "vit_combo_box: ^4.0.1" to clipboard
vit_combo_box: ^4.0.1 copied to clipboard

A collection of very flexible ComboBoxes/Dropdrop.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:vit_combo_box/theme/style/combo_box_style.dart';
import 'package:vit_combo_box/theme/style/vit_combo_box_style.dart';
import 'package:vit_combo_box/vit_combo_box.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: const Text('Vit combo box'),
      ),
      body: const MyApp(),
    ),
  ));
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  DateTime? selectedDate;
  Set<DateTime> selectedDates = {};
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    var set = List.generate(20, (index) {
      return DateTime(2000 + index);
    }).toSet();
    itemBuilder(DateTime item) => Text('Year ${item.year}');
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Column(
        children: [
          // Regular combo box
          VitComboBox.itemBuilder(
            options: set,
            selection: selectedDate,
            itemBuilder: itemBuilder,
            onSelected: (key) {
              setState(() {
                selectedDate = key;
              });
              return null;
            },
            label: 'Date',
          ),

          const SizedBox(height: 20),

          VitComboBox.itemBuilder(
            options: set,
            selection: selectedDate,
            itemBuilder: itemBuilder,
            onSelected: (key) {
              setState(() {
                selectedDate = key;
              });
              return null;
            },
            enabled: false,
            label: 'Disabled',
          ),

          const SizedBox(height: 20),

          VitComboBoxTheme(
            data: VitComboBoxStyle(
              comboBox: ComboBoxStyle(
                decoration: BoxDecoration(
                  color: Colors.purple.shade100,
                ),
              ),
            ),
            child: VitComboBox.itemBuilder(
              options: const {true, false},
              label: 'With decoration from theme',
              itemBuilder: (item) {
                return Text(item.toString());
              },
              onSelected: (key) {
                return null;
              },
            ),
          ),

          const SizedBox(height: 20),

          // Combo box with check boxes.
          CheckedComboBox<DateTime>(
            options: set,
            itemBuilder: (item) {
              return Text('Year ${item.year}');
            },
            selectedItems: selectedDates,
            onSelected: (item, selected) {
              if (selected) {
                selectedDates.add(item);
              } else {
                selectedDates.remove(item);
              }
            },
            onClose: () {
              setState(() {});
            },
            label: 'Combo box with check boxes',
          ),

          const SizedBox(height: 20),

          FutureComboBox.eternal(
            label: 'Combo box that needs to load some data [ It never gets them 😔 ]',
          ),
        ],
      ),
    );
  }
}
0
likes
0
pub points
63%
popularity

Publisher

unverified uploader

A collection of very flexible ComboBoxes/Dropdrop.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on vit_combo_box