apptomate_custom_date_picker 0.0.2
apptomate_custom_date_picker: ^0.0.2 copied to clipboard
CustomDatePicker is an enhanced date selection widget that provides more flexibility and customization options than Flutter's built-in date picker.
example/lib/main.dart
import 'package:apptomate_custom_date_picker/apptomate_custom_date_picker.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const CustomDatePickerWidget(),
);
}
}
class CustomDatePickerWidget extends StatefulWidget {
const CustomDatePickerWidget({Key? key}) : super(key: key);
@override
State<CustomDatePickerWidget> createState() => _CustomDatePickerExampleState();
}
class _CustomDatePickerExampleState extends State<CustomDatePickerWidget> {
DateTime? _selectedDate;
void _handleDateSelected(DateTime? pickedDate) {
if (pickedDate != null) {
setState(() {
_selectedDate = pickedDate;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Custom DatePicker')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (_selectedDate != null)
Text(
"Selected Date: ${_selectedDate!.day}/${_selectedDate!.month}/${_selectedDate!.year}",
style: const TextStyle(fontSize: 18),
),
const SizedBox(height: 16),
CustomDatePicker(
dateWidget: Text("Select Date",style: TextStyle(color: Colors.purple,fontWeight: FontWeight.bold,fontSize: 24),),
initialDate: _selectedDate,
firstDate: DateTime.now(),
lastDate: DateTime(2100),
dateFormat: 'dd MMM yyyy',
buttonColor: Colors.blue,
textColor: Colors.white,
formattedDate: (date) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Selected Date: ${date.toString()}")),
);
},
backgroundColor: Colors.grey[100]!,
onDateSelected: _handleDateSelected,
),
],
),
),
);
}
}