month_year_dropdown 1.0.2 copy "month_year_dropdown: ^1.0.2" to clipboard
month_year_dropdown: ^1.0.2 copied to clipboard

A Flutter package for creating dropdown menus to select months and years. This package provides a customizable dropdown widget that allows users to choose from a list of months or years, enhancing the [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:month_year_dropdown/month_year.dart';

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

class MyApp extends StatelessWidget {
  final TextEditingController controller1= TextEditingController();
  final TextEditingController controller2= TextEditingController();
  final TextEditingController controller3= TextEditingController();
  final TextEditingController controller4= TextEditingController();

  MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Month Year Dropdown Example'),
        ),
        body: Center(
          child: Padding(
            padding: const EdgeInsets.symmetric(horizontal: 16.0),
            child: Column(

              children: [
                const Text('Month and Year Example'),
                const SizedBox(height: 10,),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Expanded(
                      child: MonthYearDropdown(
                        controller: controller1,
                        padding: const EdgeInsets.all(8.0),
                        itemTextStyle: const TextStyle(color: Colors.black, fontSize: 16),
                        monthsEnable: true,
                        textStyle: const TextStyle(color: Colors.black, fontSize: 18),
                        textCapitalization: TextCapitalization.words,
                        readOnly: true,
                        textInputType: TextInputType.text,
                        autoValidateMode: AutovalidateMode.onUserInteraction,
                        textInputAction: TextInputAction.done,
                        suffixIconColor: Colors.blue,
                        contentPadding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
                        errorText: 'Invalid selection',
                        hintText: 'Tap to select',
                        hintTextStyle: const TextStyle(color: Colors.grey),
                        fillColor: Colors.white,
                        borderColor: Colors.blue,
                        errorBorderColor: Colors.red,
                        borderRadius: BorderRadius.circular(8),
                        innerLabelText: 'Choose Month/Year',
                        innerLabelTextStyle: const TextStyle(color: Colors.black),
                      ),
                    ),
                    const SizedBox(width: 20,),
                    Expanded(
                      child: MonthYearDropdown(
                        controller: controller2,
                        padding: const EdgeInsets.all(8.0),
                        itemTextStyle: const TextStyle(color: Colors.black, fontSize: 16),
                        yearsEnable: true,
                        monthsEnable: false,
                        textStyle: const TextStyle(color: Colors.black, fontSize: 18),
                        textCapitalization: TextCapitalization.words,
                        readOnly: true,
                        textInputType: TextInputType.text,
                        autoValidateMode: AutovalidateMode.onUserInteraction,
                        textInputAction: TextInputAction.done,
                        suffixIconColor: Colors.blue,
                        contentPadding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
                        errorText: 'Invalid selection',
                        hintText: 'Tap to select',
                        hintTextStyle: const TextStyle(color: Colors.grey),
                        fillColor: Colors.white,
                        borderColor: Colors.blue,
                        errorBorderColor: Colors.red,
                        borderRadius: BorderRadius.circular(8),
                        innerLabelText: 'Choose Month/Year',
                        innerLabelTextStyle: const TextStyle(color: Colors.black),
                      ),
                    ),
                  ],
                ),
                const SizedBox(height: 10,),
                const Text('Month Example'),
                const SizedBox(height: 10,),
                MonthYearDropdown(
                  controller: controller3,
                  padding: const EdgeInsets.all(8.0),
                  itemTextStyle: const TextStyle(color: Colors.black, fontSize: 16),
                  monthsEnable: true,
                  textStyle: const TextStyle(color: Colors.black, fontSize: 18),
                  textCapitalization: TextCapitalization.words,
                  readOnly: true,
                  textInputType: TextInputType.text,
                  autoValidateMode: AutovalidateMode.onUserInteraction,
                  textInputAction: TextInputAction.done,
                  suffixIconColor: Colors.blue,
                  contentPadding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
                  errorText: 'Invalid selection',
                  hintText: 'Tap to select',
                  hintTextStyle: const TextStyle(color: Colors.grey),
                  fillColor: Colors.white,
                  borderColor: Colors.blue,
                  errorBorderColor: Colors.red,
                  borderRadius: BorderRadius.circular(8),
                  innerLabelText: 'Choose Month/Year',
                  innerLabelTextStyle: const TextStyle(color: Colors.black),
                ),
                const SizedBox(height: 10,),
                const Text('Year Example'),
                const SizedBox(height: 10,),
                MonthYearDropdown(
                  controller: controller4,
                  padding: const EdgeInsets.all(8.0),
                  itemTextStyle: const TextStyle(color: Colors.black, fontSize: 16),
                  yearsEnable: true,
                  monthsEnable: false,
                  textStyle: const TextStyle(color: Colors.black, fontSize: 18),
                  textCapitalization: TextCapitalization.words,
                  readOnly: true,
                  textInputType: TextInputType.text,
                  autoValidateMode: AutovalidateMode.onUserInteraction,
                  textInputAction: TextInputAction.done,

                  suffixIconColor: Colors.blue,
                  contentPadding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
                  errorText: 'Invalid selection',
                  hintText: 'Tap to select',
                  hintTextStyle: const TextStyle(color: Colors.grey),
                  fillColor: Colors.white,
                  borderColor: Colors.blue,
                  errorBorderColor: Colors.red,
                  borderRadius: BorderRadius.circular(8),
                  innerLabelText: 'Choose Month/Year',
                  innerLabelTextStyle: const TextStyle(color: Colors.black),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
2
likes
130
points
30
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for creating dropdown menus to select months and years. This package provides a customizable dropdown widget that allows users to choose from a list of months or years, enhancing the user experience in date-related inputs.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_screenutil

More

Packages that depend on month_year_dropdown