[Dart] 커스텀 스트림
Updated:
개요
async*
로 함수를 선언하고 yield 키워드로 값을 반환
예제
- 코드
-
import 'dart:async'; Stream<int> customStream(int value) async* { yield value; } void main() async { customStream(1).listen( (event) { print(event); }, ); }
-
- 실행 결과
-
1
-