Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlipClock countdown decrease more than 1 second each second #12

Open
phoenixd110 opened this issue Feb 15, 2019 · 0 comments
Open

FlipClock countdown decrease more than 1 second each second #12

phoenixd110 opened this issue Feb 15, 2019 · 0 comments

Comments

@phoenixd110
Copy link

hi
i have a strange problem
when i run my code, the flipclock runs countdown correctly
then when i scroll horizontal listview to the end, when i scroll the list view again to the start point, i see that the countdown interval is 2 seconds

when i repeat this action the interval increases to 3, 4, 5 and ...

here is my code

  getAuctionProducts() async {
    // Animations
    controller = new AnimationController(vsync: this, duration: Duration(milliseconds: 2000));
    opacity = Tween(begin: 0.0, end: 1.0).animate(new CurvedAnimation(parent: controller, curve: Curves.easeInOut));

    if (await checkInternetConnection() == true) {
      GetData getData = new GetData();
      getData.get(AuctionsJsonLocation).then((dynamic result) {
        if (result['data'] != null && result['data'] != '') {
          for (var auctionProductItem in getData.jsonToMap(result['data'])['result']) {
            auctionProductItems.add(
              GestureDetector(
                child: Container(
                  width: 180,
                  margin: EdgeInsets.all(4),
                  decoration: BoxDecoration(
                    color: Colors.white,
                    border: Border.all(
                      color: Color(0xFFCCCCCC),
                    ),
                    borderRadius: BorderRadius.all(Radius.circular(5)),
                  ),
                  child: Column(
                    children: <Widget>[
                      Stack(alignment: Alignment.topLeft, children: [
                        Container(
                          width: 180,
                          height: 135,
                          child: ClipRRect(
                            borderRadius: new BorderRadius.vertical(top: Radius.circular(5)),
                            child: CachedNetworkImage(
                              imageUrl: auctionProductItem['image'],
                              placeholder: Container(
                                alignment: Alignment.center,
                                width: 20,
                                height: 20,
                                child: CircularProgressIndicator(
                                  valueColor: AlwaysStoppedAnimation<Color>(Color(0xFFCCCCCC)),
                                ),
                              ),
                              errorWidget: Icon(Icons.error),
                              fit: BoxFit.cover,
                            ),
                          ),
                        ),
                        Directionality(
                          textDirection: TextDirection.ltr,
                          child: Padding(
	                          padding: EdgeInsets.all(2.0),
	                          child: FlipClock.countdown(
		                          width: 14,
		                          height: 18,
		                          spacing: EdgeInsets.all(1),
		                          duration: Duration(seconds: ((auctionProductItem['auctionExpireDate'] - auctionProductItem['now']) % 86400)),
		                          digitColor: Color(0xFFFFFFFF),
		                          backgroundColor: Color(0xCC000000),
		                          digitSize: 12.0,
		                          borderRadius: const BorderRadius.all(Radius.circular(2.0)),
                            ),
                          ),
                        ),
                      ]),
                      Container(
                        height: 35,
                        child: Padding(
                          padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 5.0),
                          child: RichText(
                            text: TextSpan(text: auctionProductItem['title'], style: TextStyle(color: Colors.black, fontFamily: "IranYekan")),
                            maxLines: 2,
                            textAlign: TextAlign.start,
                          ),
                        ),
                      ),
                      auctionProductItem['oldPrice'] > 0
                          ? Container(
                              height: 20,
                              child: Text(
                                numberFormat(auctionProductItem['oldPrice']) + ' تومان',
                                textAlign: TextAlign.start,
                                style: TextStyle(color: Color(0xFFb71e3f), decorationStyle: TextDecorationStyle.dashed),
                              ),
                            )
                          : Container(),
                      Container(
                        height: 20,
                        child: Text(
                          numberFormat(auctionProductItem['price']) + ' تومان',
                          textAlign: TextAlign.start,
                          style: TextStyle(color: Colors.green, decorationStyle: TextDecorationStyle.dashed),
                        ),
                      ),
                    ],
                  ),
                ),
                onTap: () {
                  print('You Tapped Product ' + auctionProductItem['id'].toString());
                },
              ),
            );
          }

          setState(() {
            auctionProducts = FadeTransition(
              opacity: opacity,
              child: Column(
                children: <Widget>[
                  headingTitle(
                    text: 'پیشنهاد شگفت انگیز',
                    color: Color(0xFFb71e3f),
                    backgroundColor: Color(0xFFfff2d7),
                    icon: Icon(FontAwesomeIcons.percent_regular, color: Color(0xFFb71e3f), size: 16),
                  ),
                  Container(
                    height: 220,
                    child: ListView(
                      shrinkWrap: true,
                      scrollDirection: Axis.horizontal,
                      children: auctionProductItems,
                    ),
                  ),
                ],
              ),
            );
          });
        }
      });
    } else {
      showAlert(context: context, title: "خطا در اتصال به اینترنت", description: "دستگاه خود را به اینترنت متصل کنید", actions: <Widget>[
        FlatButton(
          child: Text('دوباره سعی کن'),
          onPressed: () {
            getSliders();
            Navigator.of(context, rootNavigator: true).pop();
          },
        ),
        FlatButton(
          child: Text('خروج'),
          onPressed: () {
            exit(0);
          },
        ),
      ]);
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant