import 'dart:async'; void main() { testTransformStream(); } testTransformStream() async { Stream stream = Stream<int>.fromIterable([111111, 222222, 333333]); //将数字型转成字符串行 var st = StreamTransformer<int, String>.fromHandlers(handleData: (int data, sink) { if (data == 333333) { sink.add('密码输入正确'); } else { sink.add('密码输入错误'); } }); stream.transform(st).listen((data) { print(data); }, onError: () => print('发生错误')); }
部分素材资源来源网站,本站提供免费下载,如有侵权请联系站长马上删除!