Insert a value to $form_state
Insert the the value in $form_state:

$form_state-&gt;set('store_value', 1);


And then later for example in submitForm():

$value = $form_state-&gt;get('store_value');


Don't use getValue() or setValue(), because this is for submitted values.

If you are migrating more forms from D7 to D8, use this as reference:

$form_state is now a classed object