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

How to set the dynamic position of swiper coming from api #154

Open
ankitkumar333111 opened this issue Nov 12, 2019 · 3 comments
Open

How to set the dynamic position of swiper coming from api #154

ankitkumar333111 opened this issue Nov 12, 2019 · 3 comments

Comments

@ankitkumar333111
Copy link

It shows the below error-

Unhandled Exception: 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 110 pos 12: '_positions.isNotEmpty': ScrollController not attached to any scroll views.

-----------my code-------

Swiper(
//outer: true,
fade:0.0,
viewportFraction: 0.4,
scale: 0.8,
index: widget.temp-totalTempCount,
itemBuilder: (c, i) {
return Center(child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text((setTemperature(i)).toString(), style: TextStyle(fontSize: 48.0, color: AppTheme.whiteTextColor)),
Text("\u00B0"+ "C", style: TextStyle(fontSize: 32.0, color: AppTheme.whiteTextColor)),
]));
},
onIndexChanged: (int index) {
setState(() {
currentIndex = index;
});
widget.tempChangeCallback(totalTempCount + index);
},
itemCount: 15)

@enzobonggio
Copy link

I'm with the same error. Did you find any solution to this @ankitkumar333111

@d9media
Copy link

d9media commented Apr 15, 2020

The Callback expects a return. Do it like this:

Swiper(
            itemBuilder: (BuildContext context, int index) {
              return slides[index];
            },
            itemCount: slides.length,
            pagination: new SwiperPagination(margin: EdgeInsets.all(15)),
            control: new SwiperControl(),
            layout: SwiperLayout.DEFAULT,
            onIndexChanged: (int index) {
              return setState(() => currentSlide = index);
            }),

@TechSatya
Copy link

Map your array this way;

data[index]["..."]["..."]

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

4 participants