Skip to content

Instantly share code, notes, and snippets.

@702x
Created August 18, 2020 16:04
Show Gist options
  • Save 702x/24a798189ac096e688f8301f0e2381f2 to your computer and use it in GitHub Desktop.
Save 702x/24a798189ac096e688f8301f0e2381f2 to your computer and use it in GitHub Desktop.
import 'dart:io';
import 'package:flutter/material.dart';
class With10SecondDelay extends StatelessWidget {
runningFunction() {
int sum = 0;
for (int i = 1; i <= 10; i++) {
sleep(Duration(seconds: 1));
print(i);
sum += i;
}
return "total sum is $sum";
}
pauseFunction() {
//pause function is not async
print(runningFunction());
}
@override
Widget build(BuildContext context) {
pauseFunction();
return Material(
child: Center(
child: Center(
child: Text(
"Tnx for waiting 10 seconds : check console for response",
style: TextStyle(
fontSize: 50,
),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment