TurnCountdown class
Styled countdown toward deadline.
Shows remaining time as "12m 34s" or "45s". Turns ColorScheme.error when under 60 seconds. Returns an empty widget once the deadline has passed.
When the device is offline the countdown freezes at the last known value and renders with a pause icon in ColorScheme.onSurfaceVariant so the player knows the timer is not draining locally (though the server clock continues).
Provide style to override the default TextTheme.bodySmall, useful when the countdown should be larger (e.g. inside the game screen).
deadline is an absolute server timestamp in epoch milliseconds, converted here against the synchronized server clock; otherwise a device with a skewed clock would show a countdown that disagrees with when the turn actually expires.
Provide windowMillis (how long the turn was when it began) to enable the soft-deadline margin: the countdown reaches zero slightly before the true deadline so an on-time submit survives network latency. The margin is capped to a fraction of the window so a short one, a three-second reaction window, is not swallowed whole. Omit it (e.g. on at-a-glance home cards) for a truthful, unmargined countdown.
Timing state is owned by TurnTimerBuilder.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- TurnCountdown
Constructors
- TurnCountdown({Key? key, required int deadline, int? windowMillis, TextStyle? style})
-
const
Properties
- deadline → int
-
Absolute server deadline, epoch milliseconds.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- style → TextStyle?
-
final
- windowMillis → int?
-
How long this turn was when it started, in milliseconds.
final
Methods
-
build(
BuildContext context, WidgetRef ref) → Widget - Describes the part of the user interface represented by this widget.
-
createElement(
) → ConsumerStatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _ConsumerState -
Creates the mutable state for this widget at a given location in the tree.
inherited
-
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, int wrapWidth = 65}) → 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