如何解决在 flutter swiper 中编辑分页
我想为颤动中的 swiper 制作自定义分页。我想在分页中显示 2 个单词而不是点或分数,谁能告诉我更好的方法,因为在我的代码中,我无法在单击自定义分页时更改页面。
我的代码:-
Swiper(
controller: swiperController,itemCount: 2,itemBuilder: (context,index){
return index==0?A(context):B(context); //Here A and B are 2 pages to swipe between
},pagination: new SwiperPagination(
margin: new EdgeInsets.all(0.0),builder: new SwiperCustomPagination(builder:
(BuildContext context,SwiperPluginConfig config) {
return Container(
padding: EdgeInsets.only(bottom: 10),child: config.activeIndex==0?Text.rich(
TextSpan(text: "",style: TextStyle(color: Colors.white54),children: [
TextSpan(text: "First ",style: TextStyle(fontSize: 25.0,fontWeight: FontWeight.bold),),TextSpan(text: " Second ",recognizer: TapGestureRecognizer()..onTap=(){},style: TextStyle(fontSize: 17.0,)
])
):Text.rich(
TextSpan(text: "",TextSpan(text: " Second ",)
])
),);
})),
解决方法
使用 pageview.builder() 可能有更好的选择,但如果您想更改此代码,只需使用 TextSpan 的识别器属性即可。
|
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。