flutter_custom_month_picker_new 0.0.2
flutter_custom_month_picker_new: ^0.0.2 copied to clipboard
This package is designed to make it easy to use a month and year picker in Flutter with a fancy design.
example/lib/main.dart
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_custom_month_picker_new/flutter_custom_month_picker.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int month = 3, year = 2023;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Flutter Month Picker Demo'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
showMonthPicker(context, onSelected: (month, year) {
if (kDebugMode) {
print('Selected month: $month, year: $year');
}
setState(() {
this.month = month;
this.year = year;
});
},
initialSelectedMonth: month,
initialSelectedYear: year,
firstEnabledMonth: 3,
lastEnabledMonth: 10,
firstYear: 2000,
size: const Size(520, 250),
lastYear: 2025,
selectButtonText: 'OK',
cancelButtonText: 'Cancel',
selectionColor: Colors.blue,
yearSelectorTextColor: Colors.white,
textColor: Colors.black,
contentBackgroundColor: Colors.white,
buttonsTextColor: Colors.white,
dialogBackgroundColor: Colors.blue,
locale: const Locale("pt"),
);
},
child: const Text('Show Month Picker')),
Text('Selected month: $month, year: $year')
],
),
),
);
}
}