public override Widget build(BuildContext context) { var attachmentUrLs = this.game.attachmentURLs; if (attachmentUrLs.isNullOrEmpty()) { return(new Container()); } Widget swiperContent; if (attachmentUrLs.Count == 1) { var imageUrl = attachmentUrLs.FirstOrDefault(); swiperContent = new GestureDetector( onTap: () => { }, child: new PlaceholderImage( imageUrl: imageUrl, fit: BoxFit.fill, useCachedNetworkImage: true, color: CColorUtils.GetSpecificDarkColorFromId(id: imageUrl) ) ); } else { swiperContent = new Swiper.Swiper( (cxt, index) => { var imageUrl = attachmentUrLs[index: index]; return(new PlaceholderImage( CImageUtils.SizeToScreenImageUrl(imageUrl: imageUrl), fit: BoxFit.fill, useCachedNetworkImage: true, color: CColorUtils.GetSpecificDarkColorFromId(id: imageUrl) )); }, itemCount: attachmentUrLs.Count, autoplay: true, onTap: index => { }, pagination: new SwiperPagination(margin: EdgeInsets.only(bottom: 5)) ); } return(new Container( child: new AspectRatio( aspectRatio: 16 / 9f, child: swiperContent ) )); }
public override void didUpdateWidget(StatefulWidget _oldWidget) { Swiper oldWidget = _oldWidget as Swiper; base.didUpdateWidget(oldWidget); if (this._isPageViewLayout()) { if (this._pageController == null || (this.widget.index != oldWidget.index || this.widget.loop != oldWidget.loop || this.widget.itemCount != oldWidget.itemCount || this.widget.viewportFraction != oldWidget.viewportFraction || this._getReverse(this.widget) != this._getReverse(oldWidget))) { this._pageController = new TransformerPageController( initialPage: this.widget.index, loop: this.widget.loop, itemCount: this.widget.itemCount, reverse: this._getReverse(this.widget), viewportFraction: this.widget.viewportFraction); } } else { Window.instance.scheduleMicrotask(() => { if (this._pageController != null) { this._pageController.dispose(); this._pageController = null; } }); } if (this.widget.index != null && this.widget.index != this._activeIndex) { this._activeIndex = this.widget.index.Value; } }
bool _getReverse(Swiper widget) { return(widget.transformer == null ? false : widget.transformer.reverse); }