date_picker_scroll 3.8.2
date_picker_scroll: ^3.8.2 copied to clipboard
A customizable and easy-to-use date picker library for Flutter. Compatible with Android & iOS & Web.
import 'package:flutter/material.dart';
import 'package:date_picker_scroll/date_picker_scroll.dart';
void main() {
runApp(const MaterialApp(home: MyApp()));
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
DateTime _selectedDate = DateTime.now();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Scroll Date Picker Example"),
centerTitle: true,
),
body: Column(
children: [
Container(
height: 100,
alignment: Alignment.center,
child: Text(
"$_selectedDate",
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
),
Container(
alignment: Alignment.centerRight,
padding: const EdgeInsets.only(right: 48),
child: TextButton(
onPressed: () {
setState(() {
_selectedDate = DateTime.now();
});
},
child: const Text(
"TODAY",
style: TextStyle(color: Colors.red),
),
),
),
SizedBox(
height: 250,
child: ScrollDatePicker(
selectedDate: _selectedDate,
locale: const Locale('en'),
onDateTimeChanged: (DateTime value) {
setState(() {
_selectedDate = value;
});
},
),
),
],
),
);
}
}