lottie-flutter icon indicating copy to clipboard operation
lottie-flutter copied to clipboard

problem with forward in listview

Open iranandroid opened this issue 3 years ago • 0 comments

Hi eveyone I have a listview like below code:

ListView.builder(
                        physics: BouncingScrollPhysics(),
                        itemCount: controller.liveStreamList.length,
                        itemBuilder: (context, index) {
                          LiveStreamModel model =
                              controller.liveStreamList[index];

                          model.animationController = AnimationController(vsync: this);

                          return Container(
                            margin: EdgeInsets.fromLTRB(10, 5, 10, 5),
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(9),
                              gradient: controller.selectedIndex == index
                                  ? LinearGradient(
                                      colors: [
                                        drawerSelectedStartIconColor
                                            .withOpacity(0.34),
                                        drawerSelectedEndIconColor
                                            .withOpacity(0.34),
                                      ],
                                      begin: const FractionalOffset(0.0, 0.0),
                                      end: const FractionalOffset(1.0, 0.0),
                                      stops: [0.0, 1.0],
                                      tileMode: TileMode.clamp)
                                  : null,
                            ),
                            child: Material(
                              type: MaterialType.transparency,
                              color: Colors.transparent,
                              child: ListTile(
                                leading: SizedBox(
                                  width: 35,
                                  height: 35,
                                  child: FadeInImage(
                                    image: NetworkImage(model.stream_icon!),
                                    placeholder: AssetImage(
                                        'assets/images/png/tele.png'),
                                    imageErrorBuilder:
                                        (context, error, stackTrace) {
                                      return Image.asset(
                                          'assets/images/png/tele.png',
                                          fit: BoxFit.fitWidth);
                                    },
                                  ),
                                ),
                                trailing: Focus(
                                  focusNode: model.focusNode,
                                  child: Lottie.asset(
                                    'assets/lottie/like.json',
                                    repeat: false,
                                    reverse: false,
                                    animate: false,
                                    controller: model.animationController,
                                    onLoaded: (composition) {
                                      model.animationController!
                                        .duration = composition.duration;
                                    },
                                  ),
                                ),
                                shape: RoundedRectangleBorder(
                                    borderRadius: BorderRadius.circular(9)),
                                title: Text(
                                  model.name!,
                                  style: TextStyle(
                                      color: white,
                                      fontSize: 12,
                                      fontFamily: 'IranYekan'),
                                ),
                                onTap: () {
                                  controller.selectedIndex = index;
                                  controller.initVlcPlayer(false);
                                  controller.showChannelMenu();
                                },
                              ),
                            ),
                          );
                        },
                      )

and i start animation with this code:

model.animationController!.forward();

animation start successfully but when animation has finished, animation nav to start and wait to press button to start i wanna stop animation to end, how to is it?

iranandroid avatar May 06 '22 09:05 iranandroid