FrameBudgeter class

Monitors per-frame render times against a target budget.

When frames exceed budgetMs, onDrop is called with the actual frame time. The FrameBudgeter integrates with SchedulerBinding.addTimingsCallback for zero-overhead monitoring that only activates when start is called.

Usage:

final budgeter = FrameBudgeter(
  budgetMs: 16.67,
  onDrop: (ms) => print('Frame drop: ${ms}ms'),
);
budgeter.start();
// ...later...
budgeter.stop();

Constructors

FrameBudgeter({double budgetMs = 16.67, void onDrop(double frameMs)?, void onLowFps(double frameMs)?, int minFpsThreshold = 50})

Properties

budgetMs double
Target frame budget in milliseconds (16.67ms = 60fps, 8.33ms = 120fps).
final
droppedFrames int
Number of frames that exceeded budgetMs since last reset.
no setter
dropRatio double
Ratio of dropped frames 0.0, 1.0.
no setter
estimatedFps double
Estimated current FPS based on drop ratio.
no setter
hashCode int
The hash code for this object.
no setterinherited
isRunning bool
True if monitoring is currently active.
no setter
isUnderperforming bool
True if estimated FPS is below minFpsThreshold.
no setter
minFpsThreshold int
FPS threshold that triggers onLowFps.
final
onDrop → void Function(double frameMs)?
Called when a frame exceeds budgetMs. Receives the actual frame time.
final
onLowFps → void Function(double frameMs)?
Optional callback when FPS falls below minFpsThreshold.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
totalFrames int
Total frames observed since last reset.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Resets accumulated statistics without stopping monitoring.
start() → void
Starts monitoring frame timings.
stop() → void
Stops monitoring and removes the callback.
toString() String
A string representation of this object.
override

Operators

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