flutter_scroll_date_picker 0.0.1 flutter_scroll_date_picker: ^0.0.1 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:flutter_scroll_date_picker/flutter_scroll_date_picker.dart';
void main() {
runApp(MaterialApp(home: const MyApp()));
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
DateTime _selectedDate = DateTime.now();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Scroll Date Picker Example"),
centerTitle: true,
),
body: Column(
children: [
Container(
height: 100,
alignment: Alignment.center,
child: Text(
"$_selectedDate",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
),
Container(
alignment: Alignment.centerRight,
padding: const EdgeInsets.only(right: 48),
child: TextButton(
onPressed: () {
setState(() {
_selectedDate = DateTime.now();
});
},
child: Text(
"TODAY",
style: TextStyle(color: Colors.red),
),
),
),
SizedBox(
height: 250,
child: ScrollDatePicker(
selectedDate: _selectedDate,
minimumDate: DateTime(2017, 6, 6),
locale: Locale('en'),
onDateTimeChanged: (DateTime value) {
setState(() {
_selectedDate = value;
});
},
),
),
],
),
);
}
}