HorizontalDatePicker class

{@tool snippet} This is a sample of a HorizontalDatePicker widget. It supports you can create a DatePicker with flexible count of items from begin to end by itemCount. By itemCount its can split into days, hours, minutes, seconds, that makes you can use this widget in many situations.

           HorizontalDatePicker(
                begin: DateTime.now(),
                end: DateTime.now().add(Duration(days: 40)),
                selected: DateTime.now(),
                onSelected: (item) {
                },
                itemBuilder: (DateTime itemValue, DateTime? selected) {
                  var isSelected =
                      selected?.difference(itemValue).inMilliseconds == 0;
                  return Text(
                    itemValue.formatted(pattern: "EEE\ndd/MM\nHH:mm:ss"),
                    style: TextStyle(
                      color: isSelected ? Colors.white : Colors.black54,
                      fontSize: 12,
                    ),
                    textAlign: TextAlign.center,
                  );
                },
                itemCount: 40,
                itemSpacing: 12,
            )

{@end-tool}

Inheritance

Constructors

HorizontalDatePicker({Key? key, required DateTime begin, required DateTime end, DateTime? selected, bool needFocus = true, double itemHeight = 55, double itemWidth = 55, double itemSpacing = 0, dynamic onSelected(DateTime selected)?, Color selectedColor = Colors.orangeAccent, Color unSelectedColor = Colors.white, required Widget itemBuilder(DateTime itemValue, DateTime? selected), required int itemCount, Curve focusAnimationCurve = Curves.elasticOut, Duration focusAnimationDuration = const Duration(milliseconds: 200)})
  • begin is the begin DateTime.
  • end is the end DateTime.
  • selected is the selected DateTime.
  • needFocus if true {default} the selected item will be scrolled to the center of ListView.
  • itemHeight is height of date item, whole this widget also.
  • itemWidth is width of date item.
  • itemSpacing is the spacing between date items.
  • onSelected is the callback when users are pressed on an item.
  • selectedColor is the background color of selected item.
  • unSelectedColor is the background color of unselected item.
  • itemBuilder is the function that create the date items.
  • itemCount is total of items, it's used to calculate how many duration (step) between every item.
  • focusAnimationCurve use for animation when needFocus is true.
  • focusAnimationDuration use for animation when needFocus is true.
  • const

    Properties

    begin DateTime
    final
    end DateTime
    final
    focusAnimationCurve Curve
    final
    focusAnimationDuration Duration
    final
    hashCode int
    The hash code for this object.
    no setterinherited
    itemBuilder Widget Function(DateTime itemValue, DateTime? selected)
    final
    itemCount int
    final
    itemHeight double
    final
    itemSpacing double
    final
    itemWidth double
    final
    key Key?
    Controls how one widget replaces another widget in the tree.
    finalinherited
    needFocus bool
    final
    onSelected → (dynamic Function(DateTime selected)?)
    final
    runtimeType Type
    A representation of the runtime type of the object.
    no setterinherited
    selected DateTime?
    final
    selectedColor Color
    final
    unSelectedColor Color
    final

    Methods

    createElement() StatefulElement
    Creates a StatefulElement to manage this widget's location in the tree.
    inherited
    createState() → _HorizontalDatePickerState
    Creates the mutable state for this widget at a given location in the tree.
    override
    debugDescribeChildren() List<DiagnosticsNode>
    Returns a list of DiagnosticsNode objects describing this node's children.
    inherited
    debugFillProperties(DiagnosticPropertiesBuilder properties) → void
    Add additional properties associated with the node.
    inherited
    noSuchMethod(Invocation invocation) → dynamic
    Invoked when a nonexistent method or property is accessed.
    inherited
    toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
    Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
    inherited
    toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
    A string representation of this object.
    inherited
    toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
    Returns a string representation of this node and its descendants.
    inherited
    toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
    Returns a one-line detailed description of the object.
    inherited
    toStringShort() String
    A short, textual description of this widget.
    inherited

    Operators

    operator ==(Object other) bool
    The equality operator.
    inherited