瀏覽代碼

修复其他页导航至接单页点击页面刷新问题

daxu0403 7 年之前
父節點
當前提交
fa207d88c8
共有 1 個文件被更改,包括 18 次插入19 次删除
  1. 18 19
      lib/pages/order_taking_page.dart

+ 18 - 19
lib/pages/order_taking_page.dart

@@ -139,7 +139,6 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
 
   @override
   Widget build(BuildContext context) {
-    super.build(context);
     return Container(
       child: Scaffold(
         appBar: AppBar(
@@ -353,27 +352,27 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
         orderList = [];
         hasNextPage = false;
       });
-      oldLineIdStr = lineIdStr;
-      setKey('lineIdStr', lineIdStr);
       return;
     }
     lineIdStr = lineIdStr.substring(0, lineIdStr.length - 1);
-
-    if (oldLineIdStr == lineIdStr) return;
-    setState(() {
-      orderList = [];
-      hasNextPage = true;
-    });
-    getOrderList(stationId,lineIdStr, page).then((resp) {
-      if (isNotError(context, resp) && this.mounted) {
-        OrderListObj tempObj = OrderListObj.fromJson(resp.data);
-        setState(() {
-          orderList = tempObj.data.items;
-          hasNextPage = tempObj.data.hasNextPage;
-        });
-        oldLineIdStr = lineIdStr;
-        setKey('lineIdStr', lineIdStr);
-      }
+    getKey('oldLineIdStr').then((oldLineIdStr){
+      if(oldLineIdStr == lineIdStr) return;
+      setKey('oldLineIdStr', lineIdStr);
+      setState(() {
+        orderList = [];
+        hasNextPage = true;
+      });
+      getOrderList(stationId,lineIdStr, page).then((resp) {
+        if (isNotError(context, resp) && this.mounted) {
+          OrderListObj tempObj = OrderListObj.fromJson(resp.data);
+          setState(() {
+            orderList = tempObj.data.items;
+            hasNextPage = tempObj.data.hasNextPage;
+          });
+          oldLineIdStr = lineIdStr;
+          setKey('lineIdStr', lineIdStr);
+        }
+      });
     });
   }
 }