//多個異步並行處理 同步回掉 Future.wait([ Future.delayed(new Duration(seconds: 2),(){ return "hello"; }), Future.delayed(new Duration(seconds: 4),(){ return "world!"; }) ]).then((results){ log(results[0]+results[1]); }).catchError((e){ print(e); });
//串行處理數據
void task() async {
try {
String id = await login('158666666666', '1234556');
print('登錄成功,用戶id爲${id}');
String userInfo = await getUserInfo(id);
print('獲取用戶信息成功,結果爲${userInfo}');
saveUserInfo(userInfo);
print('保存用戶信息成功');
} catch (e) {
print(e);
}