Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 编辑颤振swiper中的分页_Flutter_Dart_Swiper - Fatal编程技术网

Flutter 编辑颤振swiper中的分页

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

我想为Flitter中的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: "",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),)
                      ])
                  ),
                );
              })