textformfield_datetime_range_picker 0.0.3
textformfield_datetime_range_picker: ^0.0.3 copied to clipboard
A customizable date and time range picker widget for Flutter applications.
textformfield_datetime_range_picker #
A customizable date and time range picker widget for Flutter applications.
The TextFormFieldDateTimeRangePicker
allows users to select a range of dates and times. It supports three modes: full date-time, time-only, and date-only selection. This widget is useful for scenarios where you need users to specify a range of dates and/or times, such as booking systems, scheduling apps, or event management.
💰 You can help me by Donating #
Demo #
Demo timeonly | Demo fullDateTime | Demo dateonly |
---|---|---|
![]() |
![]() |
![]() |
Features #
- Three selection modes: full date-time, time only, and date only
- Customizable time range (minimum and maximum hours)
- Customizable icon, title, and hint text
- Automatic validation to ensure end date/time is always after start date/time
- Callback for range changes
Supported platforms #
- Flutter Android
- Flutter iOS
- Flutter web
- Flutter desktop
- Flutter macos
Installation #
- Add
textformfield_datetime_range_picker.dart: <latest-version>
to yourpubspec.yaml
dependencies. And import it: Get the latest version in the 'Installing' tab on pub.flutter-io.cn
dependencies:
textformfield_datetime_range_picker: <latest-version>
flutter pub add textformfield_datetime_range_picker
- Run pub get.
flutter pub get
- Import package.
import 'package:textformfield_datetime_range_picker/textformfield_datetime_range_picker.dart';
Example #
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:textformfield_datetime_range_picker/textformfield_datetime_range_picker.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
var dateTtime = DateTime.now();
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text(
'TextFormField DateTime Range picker',
style: TextStyle(fontSize: 18),
),
),
body: Padding(
padding: const EdgeInsets.all(14.0),
child: Center(
child: TextFormFieldDateTimeRangePicker(
selectedOption: DateTimeOption.fullDateTime,
initialDate: dateTtime,
hintTextDate: 'Select Date',
onChanged: (date) {
setState(() {
dateTtime = date.start;
dateTtime = date.end;
});
},
),
),
),
),
);
}
}
Example Use Bloc #
TextFormFieldDateTimeRangePicker(
selectedOption: DateTimeOption.fullDateTime
initialDate: state.dateTime ?? DateTime.now(),
hintTextDate: 'Select Date',
onChanged: (date) {
context.read<SecurityFormBloc>().add(
SecurityFormEvent.dateTimeChanged(
dateTime: date.start,
endTime: date.end,
),
);
},
),
License #
MIT
Contributing #
Pull requests are welcome.