TickingWidget class
A widget that rebuilds itself at a given interval. This widget is useful for building widgets that need to be updated at a given interval. For example, this widget can be used to build clocks, timers, stopwatches, and countdowns. This widget can be used to build any widget that needs to be updated at a given interval. Example:
TickingWidget(
mode: TickingMode.second,
builder: (context, currentTime, child) {
// This widget will rebuild every second.
return Text(currentTime.toString());
},
),
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- TickingWidget
- Available Extensions
Constructors
- TickingWidget({Key? key, TickingWidgetBuilder? builder, Widget? child, required TickingMode mode, bool autoStart = true})
-
Creates a new TickingWidget.
const
Properties
- autoStart → bool
-
If true, the ticker will start automatically when the widget is initialized.
If false, the ticker will not start automatically when the widget is initialized.
The default value is true.
This can be changed at runtime using TickingInterface.startTicker and
TickingInterface.stopTicker methods.
final
- builder → TickingWidgetBuilder?
-
The builder function that is used to build the ticking widget.
This function is called every time the widget needs to be rebuilt.
final
- child → Widget?
-
The child widget that is passed to the TickingWidget.
If the builder is not provided, the child must be provided.
If both builder and child are provided, the builder will be used
and the child will be passed to the builder function.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- mode → TickingMode
-
The mode of ticking. It can be millisecond, second, minute, or hour.
This is used to determine when to rebuild the widget.
For example, if the mode is set to TickingMode.second,
the widget will rebuild every second.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< TickingWidget> -
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
Static Methods
-
maybeOf(
BuildContext context) → TickingInterface? - Returns the TickingInterface of the nearest TickingWidget ancestor. This method can be used to access the TickingInterface of the nearest TickingWidget ancestor to control the ticking of the widget. Example:
-
of(
BuildContext context) → TickingInterface - Returns the TickingInterface of the nearest TickingWidget ancestor. This method can be used to access the TickingInterface of the nearest TickingWidget ancestor to control the ticking of the widget. Example: