Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

flutter compute

// A top level function
int computationallyExpensiveTask(int value) {
  var sum = 0;
  for (var i = 0; i <= value; i++) {
    sum += i;
  }
  print('finished');
  return sum;
}

// Call the function on another thread, keeping the UI thread free
final sum = await compute(computationallyExpensiveTask, 1000000000);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #flutter #compute
ADD COMMENT
Topic
Name
6+2 =