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 add item image from asset #60

Closed
Nabouste opened this issue Mar 13, 2019 · 3 comments
Closed

How to add item image from asset #60

Nabouste opened this issue Mar 13, 2019 · 3 comments

Comments

@Nabouste
Copy link

hi i want to add 4 custom image from asset.
but i dont know how to implement this.

new Swiper( autoplay: true, itemBuilder: (BuildContext context, int index) { return InkWell( onTap: (){ print("aaaaa"); }, child: new Image.asset( "img/dummy.jpg", fit: BoxFit.fill, ), ); }, itemCount: 4, viewportFraction: 0.8, scale: 0.9, ), ),

the code just showing 1 image from asset.
how to show more than 1 image in this swipper ?
also an implementation using indicator ._.

thanks

@SrOptimus
Copy link

i want to know too

@DanielMenconi
Copy link

anyone?

@ghozay19
Copy link

use this

make list from lokal :
var gambar = "img/dummy.jpg";
final List imgList = [
'img/dummy.jpg',
'img/1.jpg',
'img/2.jpg',
'img/3.jpg',
'img/4.jpg',
];

Call them on swiper
Swiper(
viewportFraction: 0.8,
scale: 0.9,
autoplay: true,
itemCount: imgList.length,
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: () {
switch (index) {
case 0:
print('gambar 0');
break;
case 1:
print('gambar 1');
break;
case 2:
print('gambar 2');
break;
case 3:
print('gambar 3');
break;
case 4:
print('gambar 4');
break;
}
},
child: Image.asset(
imgList[index],
fit: BoxFit.fitWidth,
),
);
},
pagination: SwiperPagination(),
),
),

sorry for bad code.

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