Is it possible to change child of reorderable list in flutter?

62 views Asked by At

i have reorderable list of title and details when i select and reorder then all child of list only show titles and after complete reorder all child show title and details in flutter i have this code but my selected and focused child show all details and title else child show only titles

                          ReorderableListView(
                              physics: const NeverScrollableScrollPhysics(),
                              shrinkWrap: true,
                              onReorder: (int oldIndex, int newIndex) {
                                controller.reorderWidgets(oldIndex, newIndex);
                              },
                              children: List.generate(controller.exerciseList.length, (index) =>
                                  InkWell(
                                    key: ValueKey("valueKey${Random().nextInt(100000)}"),
                                    onTap: (){
                                      controller.isLongPress.value = !controller.isLongPress.value;
                                    },
                                    child: Container(
                                    padding: const EdgeInsets.symmetric(vertical: 15),
                                    margin: const EdgeInsets.symmetric(vertical: 7),
                                    decoration: BoxDecoration(
                                      borderRadius: BorderRadius.circular(10),
                                      border: Border.all(
                                          color: ColorRes.yellowDark.withOpacity(1),
                                          width: 0.5),
                                    ),
                                    child: controller.isLongPress.value ? Column(
                                      children: [
                                        Padding(
                                          padding: const EdgeInsets.symmetric(horizontal: 15),
                                          child: Row(
                                            children: [
                                              Container(
                                                height: Get.height * 0.06,
                                                width: Get.height * 0.06,
                                                decoration: BoxDecoration(
                                                    borderRadius: BorderRadius.circular(10),
                                                    border: Border.all(
                                                        color: ColorRes.yellowDark
                                                            .withOpacity(1),
                                                        width: 1)),
                                                clipBehavior: Clip.hardEdge,
                                                child: ClipRRect(
                                                  borderRadius: BorderRadius.circular(9),
                                                  child: CachedNetworkImage(imageUrl:  controller.exerciseList[index].exerciseImage ?? "",fit: BoxFit.fill,
                                                      placeholder: (context, url) => Image.asset(AssetRes.galleryIcon,scale: 8),
                                                      errorWidget: (context, url, error) => Image.asset(AssetRes.galleryIcon,scale: 8)),
                                                ),
                                              ),
                                              SizedBox(width: Get.width * 0.04),
                                              SizedBox(
                                                width: Get.width * 0.6,
                                                child: Column(
                                                  crossAxisAlignment: CrossAxisAlignment.start,
                                                  children: [
                                                    Text((controller.exerciseList[index].exerciseName ?? "").toUpperCase(),
                                                        maxLines: 1,
                                                        overflow: TextOverflow.ellipsis,
                                                        style: interMedium(
                                                            fontSize: 15,
                                                            fontWeight: FontWeight.w500,
                                                            color: ColorRes.color111111)),
                                                    const SizedBox(height: 3),
                                                    Container(
                                                        height: 1,
                                                        width: 50,
                                                        color:
                                                        ColorRes.yellowDark.withOpacity(1)),
                                                  ],
                                                ),
                                              ),
                                              const Spacer(),
                                              InkWell(
                                                  onTap: () {
                                                    int count = 0;
                                                    for(var e in (controller.exerciseList[index].setsList ?? [])){
                                                      if(e["type"] == "set"){
                                                        count++;
                                                      }
                                                    }
                                                    controller.setsCount -= count;
                                                    controller.exerciseList[index].setsList?.clear();
                                                    controller.exerciseList.removeAt(index);
                                                    controller.types.removeAt(index);
                                                    controller.sets.removeAt(index);
                                                    editWorkOutController
                                                        .update(["edit_workout"]);
                                                  },
                                                  child: Image.asset(AssetRes.deleteIcon, scale: 2)),
                                            ],
                                          ),
                                        ),
                                      ],
                                    ) : Column(
                                      children: [
                                        Padding(
                                          padding: const EdgeInsets.symmetric(horizontal: 15),
                                          child: Row(
                                            children: [
                                              Container(
                                                height: Get.height * 0.06,
                                                width: Get.height * 0.06,
                                                decoration: BoxDecoration(
                                                    borderRadius: BorderRadius.circular(10),
                                                    border: Border.all(
                                                        color: ColorRes.yellowDark
                                                            .withOpacity(1),
                                                        width: 1)),
                                                clipBehavior: Clip.hardEdge,
                                                child: ClipRRect(
                                                  borderRadius: BorderRadius.circular(9),
                                                  child: CachedNetworkImage(imageUrl:  controller.exerciseList[index].exerciseImage ?? "",fit: BoxFit.fill,
                                                      placeholder: (context, url) => Image.asset(AssetRes.galleryIcon,scale: 8),
                                                      errorWidget: (context, url, error) => Image.asset(AssetRes.galleryIcon,scale: 8)),
                                                ),
                                              ),
                                              SizedBox(width: Get.width * 0.04),
                                              SizedBox(
                                                width: Get.width * 0.6,
                                                child: Column(
                                                  crossAxisAlignment: CrossAxisAlignment.start,
                                                  children: [
                                                    Text((controller.exerciseList[index].exerciseName ?? "").toUpperCase() ,
                                                        maxLines: 1,
                                                        overflow: TextOverflow.ellipsis,
                                                        style: interMedium(
                                                            fontSize: 15,
                                                            fontWeight: FontWeight.w500,
                                                            color: ColorRes.color111111)),
                                                    const SizedBox(height: 3),
                                                    Container(
                                                        height: 1,
                                                        width: 50,
                                                        color:
                                                        ColorRes.yellowDark.withOpacity(1)),
                                                  ],
                                                ),
                                              ),
                                              const Spacer(),
                                              InkWell(
                                                  onTap: () {
                                                    int count = 0;
                                                    for(var e in (controller.exerciseList[index].setsList ?? [])){
                                                      if(e["type"] == "set"){
                                                        count++;
                                                      }
                                                    }
                                                    controller.setsCount -= count;
                                                    controller.exerciseList[index].setsList?.clear();
                                                    controller.exerciseList.removeAt(index);
                                                    controller.types.removeAt(index);
                                                    editWorkOutController
                                                        .update(["edit_workout"]);
                                                  },
                                                  child: Image.asset(AssetRes.deleteIcon, scale: 2)),
                                            ],
                                          ),
                                        ),
                                        SizedBox(height: Get.height * 0.02),
                                        SizedBox(
                                          width: Get.width - 30,
                                          child: Padding(
                                            padding: const EdgeInsets.only(left: 30).copyWith(right: 40),
                                            child: "details
                                            ],
                                          ),
                                        ),
                                      ],
                                    ),
                                ),
                                  ),
                                ),
                            )

in this code reorder list focused child not convert

0

There are 0 answers