title: is there a way to make a flutter switch button keep printing until the button is clicked again(disabeled)
body: <p>I am using a flutter switch plugin to enable (toggle on) for my app to keep performing a task until the switch is disabled.
  But I am stuck trying to implement a function for that.</p>
  <p>below is my function to perform the task. But it is not working, (even though it starts working, I can't stop it.</p>
  <pre><code>&gt;    onToggle: (value) {
  &gt;           setState(() {
  &gt;           isRecording = value;
  &gt;           });
  &gt;                 while (value ==true){
  &gt;                 print(&quot;data is been recorded&quot;);
  &gt;                 
  &gt;                 }
  &gt; 
  &gt;           },
  
  I would really appreciate any suggestion or help with this problem. thanks in advance
  </code></pre>