NibPerfOverlay class
A small live FPS counter overlay, intended for use inside debug tooling
such as NibMotionDebugger but usable standalone.
Design notes / engineering judgement
The framework spec only asks for "a frame counter (FPS calculated from
SchedulerBinding.instance.currentFrameTimeStamp)" as part of the debug
overlay, without fully specifying NibPerfOverlay itself. Rather than
sampling currentFrameTimeStamp on every build (which would require a
rebuild every frame just to compute a number nobody needs at 60Hz
granularity), this widget uses
SchedulerBinding.instance.addTimingsCallback, which is the idiomatic
Flutter SDK API for real, post-hoc frame timing data: the engine batches
up FrameTimings and delivers them periodically (roughly once a second
in practice), each carrying the actual totalSpan the frame took from
build to raster completion. That gives a far more meaningful FPS number
than re-deriving it from timestamps sampled at arbitrary build times, and
it only updates roughly once per second — exactly the cadence a human
reads an FPS counter at.
Because updates arrive at ~1Hz rather than every animation frame, this
widget uses a small private State with setState to drive its
repaint. That is a deliberate, narrow exception to this package's
"no setState per animation frame" rule: that rule exists to keep the
core animation pipeline (the thing driving 60-120fps motion) from
rebuilding widgets every frame. This widget is debug-only tooling, is not
part of that pipeline, is not itself being animated, and only rebuilds
about once a second — so a ChangeNotifier/MotionValue-based approach
would add indirection for no real benefit here.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- NibPerfOverlay
- Available extensions
Constructors
- NibPerfOverlay({Key? key, TextStyle? textStyle})
-
Creates a live FPS counter overlay.
const
Properties
- 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
- textStyle → TextStyle?
-
Optional text style override for the FPS readout. Defaults to a small
white monospace-ish style suited for an overlay on dark scrims.
final
Methods
-
animate(
{Object? initial, Object? animate, NibAnim? exit, NibTransition? transition, NibAnim? whileTap, NibAnim? whileHover, Key? key}) → Widget -
Available on Widget, provided by the NibMotionWidgetExtension extension
Wraps this widget in a NibMotion. -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< NibPerfOverlay> -
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
-
revealOnScroll(
{NibAnim? initial, bool once = true}) → Widget -
Available on Widget, provided by the NibMotionWidgetExtension extension
Wraps this widget in a NibScrollReveal. -
shimmer(
{bool enabled = true}) → Widget -
Available on Widget, provided by the NibMotionWidgetExtension extension
Wraps this widget in a NibShimmer. -
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