Flutter 编辑颤振swiper中的分页
我想为Flitter中的swiper定制分页。如果我想在分页中显示2个单词,而不是点或分数,有人能告诉我更好的方法吗?因为在我的代码中,我不能在单击自定义分页时更改页面 我的代码:-Flutter 编辑颤振swiper中的分页,flutter,dart,swiper,Flutter,Dart,Swiper,我想为Flitter中的swiper定制分页。如果我想在分页中显示2个单词,而不是点或分数,有人能告诉我更好的方法吗?因为在我的代码中,我不能在单击自定义分页时更改页面 我的代码:- Swiper( controller: swiperController, itemCount: 2, itemBuilder: (context,index){ return index==0?A(context):B(conte
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: "",style: TextStyle(color: Colors.white54),children: [
TextSpan(text: "First ",style: TextStyle(fontSize: 17.0,),),
TextSpan(text: " Second ",style: TextStyle(fontSize: 25.0,fontWeight: FontWeight.bold),)
])
),
);
})),
),
使用pageview.builder()可能会有更好的选择,但如果您想对此代码进行更改,只需使用TextSpan的识别器属性即可
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=(){swiperController.next();},
//added recognizer over here
style: TextStyle(fontSize: 17.0,),)
])
):Text.rich(
TextSpan(text: "",style: TextStyle(color: Colors.white54),children: [
TextSpan(
text: "First ",
recognizer: TapGestureRecognizer()..onTap=(){swiperController.next();},
//added recognizer over here
style: TextStyle(fontSize: 17.0,),
),
TextSpan(text: " Second ",style: TextStyle(fontSize: 25.0,fontWeight: FontWeight.bold),)
])
),
);
})