month_picker_dialog 0.0.3 copy "month_picker_dialog: ^0.0.3" to clipboard
month_picker_dialog: ^0.0.3 copied to clipboard

outdated

Internationalized dialog for picking a single month from a year from an infinite list of years.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:month_picker_dialog/month_picker_dialog.dart';

void main() => runApp(MyApp(
      initialDate: DateTime.now(),
    ));

class MyApp extends StatefulWidget {
  final DateTime initialDate;

  const MyApp({Key key, @required this.initialDate}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  DateTime selectedDate;

  @override
  void initState() {
    super.initState();
    selectedDate = widget.initialDate;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: [
        Locale('en'),
        Locale('zh'),
        Locale('fr'),
        Locale('es'),
        Locale('de'),
        Locale('ru'),
        Locale('ja'),
        Locale('ar'),
        Locale('fa'),
      ],
      theme: ThemeData(
          primarySwatch: Colors.amber, accentColor: Colors.blueAccent),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Month Picker Example App'),
        ),
        body: Center(
          child: Text(
            'Year: ${selectedDate?.year}\nMonth: ${selectedDate?.month}',
            style: Theme.of(context).textTheme.display1,
            textAlign: TextAlign.center,
          ),
        ),
        floatingActionButton: Builder(
          builder: (context) => FloatingActionButton(
                onPressed: () {
                  showMonthPicker(
                          context: context,
                          initialDate: selectedDate ?? widget.initialDate)
                      .then((date) => setState(() {
                            selectedDate = date;
                          }));
                },
                child: Icon(Icons.calendar_today),
              ),
        ),
      ),
    );
  }
}
140
likes
0
pub points
98%
popularity

Publisher

unverified uploader

Internationalized dialog for picking a single month from a year from an infinite list of years.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, flutter_localizations, intl

More

Packages that depend on month_picker_dialog