FpsCounter class
A simple 1-second rolling FPS counter for camera-preview apps.
Call tick once per processed frame; tick returns true at most once
per second (when fps has been refreshed), so the caller can use its
return value to decide whether to trigger a widget rebuild.
Usage:
final _fpsCounter = FpsCounter();
int _fps = 0;
void onFrame() {
if (_fpsCounter.tick() && mounted) {
setState(() => _fps = _fpsCounter.fps);
}
}
Constructors
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Reset all counters. Useful when switching cameras.
-
tick(
) → bool -
Record a frame. Returns
truewhen fps was refreshed (i.e. at most once per second); callers typically guardsetState(...)on the result. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited