import 'package:oto_cli/oto/data/command_data.dart'; class SchedulerInterval { int interval; bool activate = true; bool progress = false; DataBuild build; Future Function(DataBuild build) executeFunc; SchedulerInterval(this.interval, this.build, this.executeFunc) { startInterval(); } void startInterval() async { while(activate) { await Future.delayed(Duration(milliseconds: interval)); if(!progress) { execute(); } } } void execute() async { if(activate) { progress = true; await executeFunc(build); progress = false; } } }