smart_time_field_picker 0.0.3 copy "smart_time_field_picker: ^0.0.3" to clipboard
smart_time_field_picker: ^0.0.3 copied to clipboard

A customizable Flutter time picker with TextFormField, supporting 12/24-hour formats, smart input, keyboard navigation, and full theming.

πŸ“¦ smart_time_field_picker #

A customizable Flutter plugin that provides a powerful SmartTimeField-based time picker with support for:


Features #

  • βœ… 12-hour & 24-hour formats
  • πŸ” Searchable dropdown with keyboard support
  • πŸ’» Full keyboard interaction (arrow, enter, escape)
  • 🧠 Smart auto-formatting
  • 🎯 Easily embedded in forms
  • 🎨 Fully themable via InputDecoration & dropdown builder
  • πŸš€ Installation

Installation #

1.Add this to your pubspec.yaml:

dependencies:
 smart_time_field_picker: ^<latest-version>

2.Import the package and use it in your Flutter App. πŸ› οΈ Usage

import 'package:smart_time_field_picker/smart_time_field_picker.dart';

Example usage #

1.Basic SearchFieldDropdown #

⌨️ Keyboard Interaction

  • Arrow Up/Down: Navigate time list
  • Enter: Select highlighted time
  • Escape: Close the dropdown
  • Typing: Supports HHmm format (e.g., 1345 β†’ 1:45 PM)

A GlobalKey<SmartTimeFieldState> is used to uniquely identify and manage the state of a SmartTimeField widget, allowing you to interact with its internal state (e.g., selecting an item or retrieving the selected value) from outside the widget.

final GlobalKey<SmartTimeFieldState<String>> timePickerKey = GlobalKey<SmartTimeFieldState<String>>();

Purpose: The GlobalKey<SmartTimeFieldState> allows you to access the state of the SmartTimeField widget, which is useful when you need to control the dropdown’s behavior programmatically. By associating a key with the SmartTimeField, you can call methods on its state, trigger a rebuild, or update its selected value from a parent widget or another part of your app.

class SmartTimeClass extends StatelessWidget {
  SmartTimeClass({super.key});

  final countryController = OverlayPortalController();

  @override
  Widget build(BuildContext context) {
    return SmartTimeField(
      user12Hr: true,
      readOnly: true,
      controller: countryController,
      textStyle: const TextStyle(
        fontSize: 12,
        fontWeight: FontWeight.w400,
      ),
      onChanged: (String? va) {
        /// add your code.
      },
    );
  }
}

2.πŸ”§ Customization #

  • TimePickerDecoration supports:
  • Dropdown item builder (optional)
  • You can customize how each time slot is displayed with dropdownItemBuilder.
TimePickerDecoration(
  hintText: "Pick a time",
  labelText: "Shift Start",
  prefixIcon: Icon(Icons.access_time),
  border: OutlineInputBorder(),
  focusedBorder: OutlineInputBorder(
    borderSide: BorderSide(color: Colors.blue, width: 1),
  ),
  contentPadding: EdgeInsets.all(12),
)
6
likes
0
points
9
downloads

Publisher

unverified uploader

Weekly Downloads

A customizable Flutter time picker with TextFormField, supporting 12/24-hour formats, smart input, keyboard navigation, and full theming.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cupertino_icons, flutter, mask_text_input_formatter

More

Packages that depend on smart_time_field_picker