Json 颤振/省道显示驱动程序历史订单,并在单击时从列表视图中删除项目

Json 颤振/省道显示驱动程序历史订单,并在单击时从列表视图中删除项目,json,flutter,listview,dart,Json,Flutter,Listview,Dart,我正在为我的商店编写一个送货应用程序。它有3个驱动程序。我将显示来自WooCommerceAPI(json)的订单,他们将选择想要交付的订单。有人可以告诉我们如何做这些事情: 显示每个驱动程序的历史顺序的最佳方式是什么 当一个驱动程序选择交付一个订单时,他/她“请求”该订单,然后该订单从所有其他驱动程序的列表视图中退出,或者使可单击容器“请求”不再可单击 从json url获取数据的代码: Future<List<Technician>> getTechies() asy

我正在为我的商店编写一个送货应用程序。它有3个驱动程序。我将显示来自WooCommerceAPI(json)的订单,他们将选择想要交付的订单。有人可以告诉我们如何做这些事情:

  • 显示每个驱动程序的历史顺序的最佳方式是什么
  • 当一个驱动程序选择交付一个订单时,他/她“请求”该订单,然后该订单从所有其他驱动程序的列表视图中退出,或者使可单击容器“请求”不再可单击
  • 从json url获取数据的代码:

    Future<List<Technician>> getTechies() async {
        try {
          var data = await http.get("url");
          var jsonData = json.decode(data.body);
    
          List<Technician> techies = [];
    
          for (var u in jsonData) {
            Technician myTechy = Technician(u["userId"].toString(), u["id"].toString(), u["tittle"], u["body"]);
    
            techies.add(myTechy);
          }
          return techies;
    
        } catch(e) {
          print(e);
        }
      }
    }
    
    Future getTechies()异步{
    试一试{
    var data=wait http.get(“url”);
    var jsonData=json.decode(data.body);
    列出技术人员=[];
    用于(jsonData中的变量u){
    技师myTechy=技师(u[“用户id”].toString(),u[“id”].toString(),u[“title”],u[“body”]);
    techies.add(myTechy);
    }
    返回技术人员;
    }捕获(e){
    印刷品(e);
    }
    }
    }
    
    显示订单的代码:

    Container(
                      padding: EdgeInsets.only(top: 550, bottom: 50),
                      child: FutureBuilder(
                          future: getTechies(),
                          builder: (BuildContext context, AsyncSnapshot snapshot) {
                            print(snapshot.data);
                            if (snapshot.data == null) {
                              return Container(
                                  child: Center(
                                      child: Text("Loading...", style: TextStyle(fontSize: 30),)
                                  )
                              );
                            } else {
                              return ListView.builder(
                                  scrollDirection: Axis.horizontal,
                                  shrinkWrap: true,
                                  itemCount: snapshot.data.length,
                                  itemBuilder: (BuildContext context, int index){
                                    return
                                      InkWell( // on tap...
                                          child:
                                          Container(
                                              padding: EdgeInsets.all(10),
                                              margin: EdgeInsets.only(right: 20),
                                              width: 180,
                                              height:200,
                                              decoration: BoxDecoration(
                                                borderRadius: BorderRadius.all(Radius.circular(20)),
                                                color: Colors.white,
                                                boxShadow: [
                                                  BoxShadow(
                                                    color: Colors.grey,
                                                    blurRadius: 0.5,
                                                  ),],
                                              ),
                                              child:
                                              Column(
                                                //crossAxisAlignment: CrossAxisAlignment.start,
                                                  children: <Widget>[
    
                                                    Column(
                                                      crossAxisAlignment: CrossAxisAlignment.start,
                                                      children: <Widget>[
                                                        SizedBox(height: 5,),
                                                        Text("Store name"  + snapshot.data[index].id.toString(),textAlign: TextAlign.center, style: TextStyle(fontSize: 19, fontWeight: FontWeight.bold)),
                                                        SizedBox(height: 10,),
                                                        Text("AS: street name, " + snapshot.data[index].id.toString(), style: TextStyle(fontSize: 15)),
                                                        SizedBox(height: 10,),
                                                        Text("AC: street name, " + snapshot.data[index].userId.toString(), style: TextStyle(fontSize: 15)),
                                                        SizedBox(height: 30,),
                                                      ],
                                                    ),
    
                                                    GestureDetector( //on Long Press...
                                                      child:
                                                      Container(
                                                          alignment: Alignment.bottomCenter,
                                                          width: 120.0,
                                                          height: 40.0,
                                                          decoration: BoxDecoration(
                                                            borderRadius: BorderRadius.all(Radius.circular(10)),
                                                            color: Color(0xffeb5c68),
                                                          ),
                                                          child:
                                                          Column(
                                                              mainAxisAlignment: MainAxisAlignment.center,
                                                              children: <Widget>[
    
                                                                Text("REQUEST", textAlign: TextAlign.center,style: TextStyle(color: Colors.white),),
                                                              ]
                                                          )
                                                      ),
                                                      onLongPress: (){
    
                                                        Navigator.push(
                                                            context,
                                                            MaterialPageRoute(builder: (context) => orderspage(snapshot.data[index])));
    
                                                        
                                                      },
                                                    )
                                                  ]
                                              )
                                          ),
    
                                          onTap: () {
                                            
                                          }
                                      );
                                  }
                              );
                            }
                          }
                      )
                  ),
                ],
              )
          ),
        );
      }
    
    容器(
    填充:仅限边缘设置(顶部:550,底部:50),
    孩子:未来建设者(
    future:getTechies(),
    生成器:(BuildContext上下文,异步快照){
    打印(快照数据);
    如果(snapshot.data==null){
    返回容器(
    儿童:中心(
    子项:文本(“加载…”,样式:TextStyle(fontSize:30),)
    )
    );
    }否则{
    返回ListView.builder(
    滚动方向:轴水平,
    收缩膜:对,
    itemCount:snapshot.data.length,
    itemBuilder:(构建上下文,int索引){
    返回
    墨水池(//打开。。。
    儿童:
    容器(
    填充:边缘设置。全部(10),
    页边距:仅限边集(右:20),
    宽度:180,
    身高:200,
    装饰:盒子装饰(
    borderRadius:borderRadius.all(半径圆形(20)),
    颜色:颜色,白色,
    boxShadow:[
    箱形阴影(
    颜色:颜色。灰色,
    半径:0.5,
    ),],
    ),
    儿童:
    纵队(
    //crossAxisAlignment:crossAxisAlignment.start,
    儿童:[
    纵队(
    crossAxisAlignment:crossAxisAlignment.start,
    儿童:[
    尺寸箱(高度:5,),
    Text(“存储名称”+快照.data[index].id.toString(),textAlign:textAlign.center,样式:TextStyle(fontSize:19,fontWeight:fontWeight.bold)),
    尺寸箱(高度:10,),
    Text(“AS:street name,”+snapshot.data[index].id.toString(),style:TextStyle(fontSize:15)),
    尺寸箱(高度:10,),
    Text(“AC:street name,”+snapshot.data[index].userId.toString(),style:TextStyle(fontSize:15)),
    尺寸箱(高度:30,),
    ],
    ),
    手势检测器(//长按时。。。
    儿童:
    容器(
    对齐:对齐.bottomCenter,
    宽度:120.0,
    身高:40.0,
    装饰:盒子装饰(
    borderRadius:borderRadius.all(半径圆形(10)),
    颜色:颜色(0xffeb5c68),
    ),
    儿童:
    纵队(
    mainAxisAlignment:mainAxisAlignment.center,
    儿童:[
    文本(“请求”,文本对齐:文本对齐。居中,样式:文本样式(颜色:Colors.white),),
    ]
    )
    ),
    onLongPress:(){
    导航器。推(
    上下文