728x90 반응형 전체 글105 플러터 함수 동시 실행 import 'dart:isolate'; int num = 10; void change(var value) { num = value; print("change : ${num}"); } void main() { Isolate.spawn(change, 12); change(9990); } 2022. 11. 15. flutter 함수 동시 실행 isolate 쓰레드 예제 import 'dart:io'; import 'dart:async'; import 'dart:isolate'; void download(var msg) { Future(() { for (int i = 0; i < 5; i++) { sleep(Duration(seconds: 1)); print("download함수 : ${i}"); } }); } main() { //동시 실행하고 싶을 때 isolate는 어떤 독립적인 쓰레드 Isolate.spawn(download, "헨로우"); for (int i = 0; i < 5; i++) { sleep(Duration(seconds: 1)); print("main함수 : ${i}"); } } 출처: 메타코딩 2022. 11. 15. flutter for문 반복문 import 'dart:io'; import 'dart:async'; void download() { for (int i = 0; i < 5; i++) { sleep(Duration(seconds: 1)); print("download함수 : ${i}"); } } main() { //독립적인 스레드 //isolate.spawn(download, "헬로우"); for (int i = 0; i < 5; i++) { sleep(Duration(seconds: 1)); print("main함수 : ${i}"); } } 출처: 메타코딩 2022. 11. 15. Could not find a file named "pubspec.yaml" 해당 프로젝트 터미널 창에서 flutter pub cache clean 2022. 11. 9. 이전 1 ··· 18 19 20 21 22 23 24 ··· 27 다음 728x90 반응형