Skip to content

ContinuousVisualTrackingActivityBodyState

State class for ContinuousVisualTrackingActivityBody

Inheritance

Constructors

ContinuousVisualTrackingActivityBodyState

ContinuousVisualTrackingActivityBodyState(
  1. RPUIContinuousVisualTrackingActivityBody sWidget,
  2. int numberOfTests,
  3. int amountOfDots,
  4. int amountOfTargets,
  5. int dotSize,
  6. Duration trackingSpeed,
)

Properties

amountOfDots

int amountOfDots
final

amountOfTargets

int amountOfTargets
final

conCurrentNum

int conCurrentNum
getter/setter pair

distractors

List<bool> distractors
getter/setter pair

dotSize

int dotSize
final

dots

List<bool> dots
getter/setter pair

finished

bool finished
getter/setter pair

guess

bool guess
getter/setter pair

mistakes

List<int> mistakes
getter/setter pair

numberOfTests

int numberOfTests
final

positions

List<int> positions
getter/setter pair

rng

Random rng
getter/setter pair

sWidget

seconds

int seconds
getter/setter pair

testTimer

Timer? testTimer
getter/setter pair

Timer for the test

trackingSpeed

Duration trackingSpeed
final

visualScoreList

List<int> visualScoreList
getter/setter pair

waiting

bool waiting
getter/setter pair

wrong

int wrong
getter/setter pair

Methods

build

Widget build(
  1. BuildContext context
)
override

Build the main test phase

dispose

void dispose()
override

Called when this object is removed from the tree permanently.

The framework calls this method when this State object will never build again. After the framework calls dispose, the State object is considered unmounted and the mounted property is false. It is an error to call setState at this point. This stage of the lifecycle is terminal: there is no way to remount a State object that has been disposed.

Subclasses should override this method to release any resources retained by this object (e.g., stop any active animations).

If a State's build method depends on an object that can itself change state, for example a ChangeNotifier or Stream, or some other object to which one can subscribe to receive notifications, then be sure to subscribe and unsubscribe properly in initState, didUpdateWidget, and dispose:

  • In initState, subscribe to the object.
  • In didUpdateWidget unsubscribe from the old object and subscribe to the new one if the updated widget configuration requires replacing the object.
  • In dispose, unsubscribe from the object.

Implementations of this method should end with a call to the inherited method, as in super.dispose().

Caveats

This method is not invoked at times where a developer might otherwise expect it, such as application shutdown or dismissal via platform native methods.

Application shutdown

There is no way to predict when application shutdown will happen. For example, a user's battery could catch fire, or the user could drop the device into a swimming pool, or the operating system could unilaterally terminate the application process due to memory pressure.

Applications are responsible for ensuring that they are well-behaved even in the face of a rapid unscheduled termination.

To artificially cause the entire widget tree to be disposed, consider calling runApp with a widget such as SizedBox.shrink.

To listen for platform shutdown messages (and other lifecycle changes), consider the AppLifecycleListener API.

Dismissing Flutter UI via platform native methods

An application may have both Flutter and non-Flutter UI in it. If the application calls non-Flutter methods to remove Flutter based UI such as platform native API to manipulate the platform native navigation stack, the framework does not know if the developer intends to eagerly free resources or not. The widget tree remains mounted and ready to render as soon as it is displayed again.

See the method used to bootstrap the app (e.g. runApp or runWidget) for suggestions on how to release resources more eagerly.

See also:

generatePositions

List<int> generatePositions()

generate new positions for all dots

getDots

List<AnimatedPositioned> getDots(
  1. int amount,
  2. int targetAmount,
  3. BoxConstraints constraints,
  4. int avatarSize,
)

initState

void initState()
override

Called when this object is inserted into the tree.

The framework will call this method exactly once for each State object it creates.

Override this method to perform initialization that depends on the location at which this object was inserted into the tree (i.e., context) or on the widget used to configure this object (i.e., widget).

If a State's build method depends on an object that can itself change state, for example a ChangeNotifier or Stream, or some other object to which one can subscribe to receive notifications, then be sure to subscribe and unsubscribe properly in initState, didUpdateWidget, and dispose:

  • In initState, subscribe to the object.
  • In didUpdateWidget unsubscribe from the old object and subscribe to the new one if the updated widget configuration requires replacing the object.
  • In dispose, unsubscribe from the object.

You should not use BuildContext.dependOnInheritedWidgetOfExactType from this method. However, didChangeDependencies will be called immediately following this method, and BuildContext.dependOnInheritedWidgetOfExactType can be used there.

Implementations of this method should start with a call to the inherited method, as in super.initState().

makeGuess

void makeGuess()

make a guess and check if its correct

resetTest

void resetTest()

reset the test

shuffleDots

void shuffleDots()

find new positions for all dots

startTest

void startTest()

start the test

startTimer

void startTimer()

start the timer