<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] ## Future ### catchError or onError catchError ``` Future.delayed(Duration(seconds: 2),(){ //return "hi world!"; throw AssertionError("Error"); }).then((data){ //執行成功會走到這里 print("success"); }).catchError((e){ //執行失敗會走到這里 print(e); }); ``` onError ``` Future.delayed(Duration(seconds: 2), () { //return "hi world!"; throw AssertionError("Error"); }).then((data) { print("success"); }, onError: (e) { print(e); }); ``` ### wait 等待多個返回結果 ``` Future.wait([ // 2秒后返回結果 Future.delayed(Duration(seconds: 2), () { return "hello"; }), // 4秒后返回結果 Future.delayed(Duration(seconds: 4), () { return " world"; }) ]).then((results){ print(results[0]+results[1]); }).catchError((e){ print(e); }); ``` ### whenComplete 不管是否成功,都會執行 whenComplete ``` Future.delayed(Duration(seconds: 2),(){ //return "hi world!"; throw AssertionError("Error"); }).then((data){ //執行成功會走到這里 print(data); }).catchError((e){ //執行失敗會走到這里 print(e); }).whenComplete((){ //無論成功或失敗都會走到這里 }); ``` ## Stream 可以接收多個異步操作的結果(成功或失敗)。 Stream 常用于會多次讀取數據的異步任務場景,如網絡內容下載、文件讀寫等. ``` Stream.fromFutures([ // 1秒后返回結果 Future.delayed(Duration(seconds: 1), () { return "hello 1"; }), // 拋出一個異常 Future.delayed(Duration(seconds: 2),(){ throw AssertionError("Error"); }), // 3秒后返回結果 Future.delayed(Duration(seconds: 3), () { return "hello 3"; }) ]).listen((data){ print(data); }, onError: (e){ print(e.message); },onDone: (){ }); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看