import 'dart:isolate';
import 'dart:math';
void main() async {
Stopwatch stopwatch = Stopwatch()..start(); // 시간 측정 시작
print('메인 Isolate에서 주식 데이터 처리 시작');
ReceivePort receivePort = ReceivePort();
// Isolate를 생성하고, 주식 데이터 처리 작업을 위임합니다.
await Isolate.spawn(processStockData, receivePort.sendPort);
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct UplodePostView: View { | |
@State private var text: String = "" | |
var body: some View { | |
NavigationView { | |
Form { | |
Section { | |
TextEditorWithPlaceholder(text: $text, placeholder: "Write something...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
/// 예제 | |
/// List { ... } | |
/// .modifier(ListBackgroundModifier()) | |
/// .background(Color.red) // 원하는 색상 적용 | |
struct ListBackgroundModifier: ViewModifier { | |
@ViewBuilder | |
func body(content: Content) -> some View { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dart에서 ResultType 사용하기 | |
// 출처: https://codewithandrea.com/articles/flutter-exception-handling-try-catch-result-type/ | |
/* 1. 최초 정의 */ | |
/// Base Result class | |
/// [S] represents the type of the success value | |
/// [E] should be [Exception] or a subclass of it | |
sealed class Result<S, E extends Exception> { | |
const Result(); | |
} |
import 'dart:math';
void main() { Stopwatch stopwatch = Stopwatch()..start(); // 시간 측정 시작 print('메인 Isolate에서 주식 데이터 처리 시작'); // 주식 데이터를 가져옵니다. List stockData = fetchStockData(); // 데이터 처리 로직을 수행합니다. 예를 들어, 평균 가격을 계산합니다. double averagePrice = processStockData(stockData); // 처리된 데이터를 출력합니다.
import 'dart:isolate';
String mainIsolate = '';
String newIsolate = '';
String get isMainIsolate =>
(mainIsolate == Isolate.current.hashCode.toString()) ? '🔴' : '🔵';
void main() async {
mainIsolate = Isolate.current.hashCode.toString();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const ExampleApp()); | |
} | |
class ExampleApp extends StatelessWidget { | |
const ExampleApp({super.key}); | |
@override |
NewerOlder